<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>org.vaadin.addons.componentfactory</groupId>
	<artifactId>vcf-leaflet</artifactId>
	<version>1.0.1</version>
	<name>Leaflet</name>
	<description>Integration of Leaflet Map for Vaadin Flow</description>
	<scm>
		<url>https://github.com/vaadin-component-factory/vcf-leaflet</url>
		<connection>scm:git:git://https://github.com/vaadin-component-factory/vcf-leaflet.git</connection>
		<developerConnection>scm:git:git@https://github.com/vaadin-component-factory/vcf-leaflet.git</developerConnection>
	</scm>
	<properties>
		<vaadin.version>14.10.11</vaadin.version>

		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

		<drivers.dir>${project.basedir}/drivers</drivers.dir>

		<jetty.version>9.4.36.v20210114</jetty.version>
		<webapp-runner.version>9.0.31.0</webapp-runner.version>

		<maven-war-plugin.version>3.2.3</maven-war-plugin.version>
		<heroku-maven-plugin>3.0.1</heroku-maven-plugin>
	</properties>
	<organization>
		<name>Vaadin Ltd</name>
        <url>https://vaadin.com/</url>
	</organization>
	<licenses>
		<license>
			<name>Apache 2</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.vaadin</groupId>
				<artifactId>vaadin-bom</artifactId>
				<type>pom</type>
				<scope>import</scope>
				<version>${vaadin.version}</version>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<repositories>
		<repository>
			<id>central</id>
			<url>https://repo.maven.apache.org/maven2</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>Vaadin Directory</id>
			<url>https://maven.vaadin.com/vaadin-addons</url>
		</repository>
		<!-- Repository needed for prerelease versions of Vaadin -->
		<repository>
			<id>Vaadin prereleases</id>
			<url>https://maven.vaadin.com/vaadin-prereleases</url>
		</repository>
		<!-- Repository needed for the snapshot versions of Vaadin -->
		<repository>
			<id>vaadin-snapshots</id>
			<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
		</repository>
	</repositories>

	<pluginRepositories>
		<pluginRepository>
			<id>central</id>
			<url>https://repo.maven.apache.org/maven2</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</pluginRepository>
		<!-- Repository needed for prerelease versions of Vaadin -->
		<pluginRepository>
			<id>Vaadin prereleases</id>
			<url>https://maven.vaadin.com/vaadin-prereleases</url>
		</pluginRepository>
		<pluginRepository>
			<id>vaadin-snapshots</id>
			<url>https://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
			<releases>
				<enabled>false</enabled>
			</releases>
		</pluginRepository>
	</pluginRepositories>

	<dependencies>
		<dependency>
			<groupId>com.vaadin</groupId>
			<!-- Replace artifactId with vaadin-core to use only free components -->
			<artifactId>vaadin</artifactId>
			<exclusions>
				<!-- Webjars are only needed when running in Vaadin 13 compatibility 
					mode in V14. Your add-on can support npm in the same version mode and V13 
					compatiblity mode at the same time, or with separate versions. Any V13 version 
					should work with the compatibility mode in V14. -->
				<exclusion>
					<groupId>com.vaadin.webjar</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.insites</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.polymer</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.polymerelements</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.vaadin</groupId>
					<artifactId>*</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.webjars.bowergithub.webcomponents</groupId>
					<artifactId>*</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>de.grundid.opendatalab</groupId>
			<artifactId>geojson-jackson</artifactId>
			<version>1.13</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-log4j12</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>2.13.2</version>
			<scope>test</scope>
		</dependency>
		<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
		<dependency>
			<groupId>javax.servlet</groupId>
			<artifactId>javax.servlet-api</artifactId>
			<version>3.1.0</version>
			<scope>provided</scope>
		</dependency>
		
		<dependency>
		    <groupId>org.projectlombok</groupId>
		    <artifactId>lombok</artifactId>
		    <version>1.18.30</version>
		    <scope>provided</scope>
		</dependency>

		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-testbench</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<defaultGoal>jetty:run</defaultGoal>
		<plugins>
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<version>3.1.0</version>
				<configuration>
					<filesets>
						<fileset>
							<directory>node_modules</directory>
						</fileset>
						<fileset>
							<directory>${basedir}</directory>
							<includes>
								<include>package.json</include>
								<include>package-lock.json</include>
								<include>pnpm-lock.yaml</include>
								<include>webpack.config.js</include>
								<include>webpack.generated.js</include>
							</includes>
						</fileset>
					</filesets>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.1.0</version>
				<configuration>
					<archive>
						<index>true</index>
						<manifest>
							<addClasspath>false</addClasspath>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
						</manifest>
						<manifestEntries>
							<Vaadin-Package-Version>1</Vaadin-Package-Version>
						</manifestEntries>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.vaadin</groupId>
				<artifactId>vaadin-maven-plugin</artifactId>
				<version>${vaadin.version}</version>
				<executions>
					<execution>
						<goals>
							<goal>prepare-frontend</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.eclipse.jetty</groupId>
				<artifactId>jetty-maven-plugin</artifactId>
				<version>${jetty.version}</version>
				<configuration>
					<scanIntervalSeconds>3</scanIntervalSeconds>
					<!-- Use test scope because the UI/demo classes are in the test package. -->
					<useTestScope>true</useTestScope>
					<supportedPackagings>
						<supportedPackaging>jar</supportedPackaging>
					</supportedPackagings>
				</configuration>
			</plugin>

		</plugins>
	</build>

	<profiles>

		<!-- Vaadin Directory Profile -->
		<profile>
			<id>directory</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-assembly-plugin</artifactId>
						<version>3.1.0</version>
						<configuration>
							<appendAssemblyId>false</appendAssemblyId>
							<descriptors>
								<descriptor>assembly/assembly.xml</descriptor>
							</descriptors>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>single</goal>
								</goals>
								<phase>install</phase>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-source-plugin</artifactId>
						<version>3.0.1</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<phase>verify</phase>
								<goals>
									<goal>jar-no-fork</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
<!--					<plugin>-->
<!--						<groupId>org.apache.maven.plugins</groupId>-->
<!--						<artifactId>maven-javadoc-plugin</artifactId>-->
<!--						<version>3.0.1</version>-->
<!--						<executions>-->
<!--							<execution>-->
<!--								<id>attach-javadocs</id>-->
<!--								<phase>verify</phase>-->
<!--								<goals>-->
<!--									<goal>jar</goal>-->
<!--								</goals>-->
<!--							</execution>-->
<!--						</executions>-->
<!--						<configuration>-->
<!--							<quiet>true</quiet>-->
<!--							<additionalparam>-Xdoclint:none</additionalparam>-->
<!--						</configuration>-->
<!--					</plugin>-->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>3.1.2</version>
						<configuration>
							<!-- Generated file that shouldn't be included in add-ons -->
							<excludes>
								<exclude>META-INF/VAADIN/config/flow-build-info.json</exclude>
							</excludes>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Run (demo) in production mode -->
		<profile>
			<id>production</id>
			<properties>
				<vaadin.productionMode>true</vaadin.productionMode>
			</properties>
			<dependencies>
				<dependency>
					<groupId>com.vaadin</groupId>
					<artifactId>flow-server-production-mode</artifactId>
				</dependency>
			</dependencies>

			<build>
				<plugins>
					<plugin>
						<groupId>com.vaadin</groupId>
						<artifactId>vaadin-maven-plugin</artifactId>
						<executions>
							<execution>
								<goals>
									<goal>prepare-frontend</goal>
									<goal>build-frontend</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<optimizeBundle>false</optimizeBundle>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Integration test profile -->
		<profile>
			<id>integration-tests</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.eclipse.jetty</groupId>
						<artifactId>jetty-maven-plugin</artifactId>
						<version>${jetty.version}</version>
						<configuration>
							<scanIntervalSeconds>0</scanIntervalSeconds>
							<supportedPackagings>
								<supportedPackaging>jar</supportedPackaging>
							</supportedPackagings>
							<stopKey>${project.artifactId}</stopKey>
							<stopPort>8081</stopPort>
						</configuration>
						<executions>
							<execution>
								<id>start-jetty</id>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>start</goal>
								</goals>
							</execution>
							<execution>
								<id>stop-jetty</id>
								<phase>post-integration-test</phase>
								<goals>
									<goal>stop</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>com.lazerycode.selenium</groupId>
						<artifactId>driver-binary-downloader-maven-plugin
						</artifactId>
						<version>1.0.17</version>
						<configuration>
							<onlyGetDriversForHostOperatingSystem>
								true
							</onlyGetDriversForHostOperatingSystem>
							<rootStandaloneServerDirectory>
								${drivers.dir}/driver
							</rootStandaloneServerDirectory>
							<downloadedZipFileDirectory>
								${drivers.dir}/driver_zips
							</downloadedZipFileDirectory>
							<customRepositoryMap>
								${project.basedir}/drivers.xml
							</customRepositoryMap>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>selenium</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-failsafe-plugin</artifactId>
						<version>2.22.2</version>
						<executions>
							<execution>
								<goals>
									<goal>integration-test</goal>
									<goal>verify</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<trimStackTrace>false</trimStackTrace>
							<enableAssertions>true</enableAssertions>
							<systemPropertyVariables>
								<!-- Pass location of downloaded webdrivers to the tests -->
								<webdriver.chrome.driver>
									${webdriver.chrome.driver}
								</webdriver.chrome.driver>
							</systemPropertyVariables>
						</configuration>
					</plugin>
					<plugin>
						<artifactId>maven-resources-plugin</artifactId>
						<version>3.1.0</version>
						<executions>
							<execution>
								<!-- Since the view class is defined in test, after compilation copy 
									it to the runtime classpath to ensure it gets visited by vaadin-maven-plugin -->
								<id>copy-test-to-classes</id>
								<phase>process-test-classes</phase>
								<goals>
									<goal>copy-resources</goal>
								</goals>
								<configuration>
									<outputDirectory>${project.build.outputDirectory}</outputDirectory>
									<resources>
										<resource>
											<directory>${project.build.testOutputDirectory}</directory>
										</resource>
									</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- build war -->
		<profile>
			<id>war</id>
			<build>
				<finalName>leaflet4vaadin-demo</finalName>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-test-libs</id>
								<phase>generate-resources</phase>
								<goals>
									<goal>copy-dependencies</goal>
								</goals>
								<configuration>
									<outputDirectory>${project.build.directory}/test-libs</outputDirectory>
									<includeScope>test</includeScope>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-war-plugin</artifactId>
						<version>${maven-war-plugin.version}</version>
						<executions>
							<execution>
								<goals>
									<goal>war</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<archive>
								<index>true</index>
								<manifest>
									<addClasspath>false</addClasspath>
									<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
								</manifest>
								<manifestEntries>
									<Vaadin-Package-Version>1</Vaadin-Package-Version>
								</manifestEntries>
							</archive>
							<failOnMissingWebXml>false</failOnMissingWebXml>
							<archiveClasses>false</archiveClasses>
							<webResources>
								<resource>
									<directory>${basedir}/src/test/resources</directory>
									<targetPath>WEB-INF/classes</targetPath>
								</resource>
								<resource>
									<directory>${project.build.directory}/classes/META-INF/VAADIN</directory>
									<targetPath>WEB-INF/classes/META-INF/VAADIN</targetPath>
								</resource>
								<resource>
									<directory>${project.build.directory}/test-classes</directory>
									<targetPath>WEB-INF/classes</targetPath>
								</resource>
								<resource>
									<directory>${project.build.directory}/test-libs</directory>
									<targetPath>WEB-INF/lib</targetPath>
								</resource>
							</webResources>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<!-- Heroku profile -->
		<profile>
			<id>heroku</id>
			<build>
				<plugins>
					<plugin>
						<groupId>com.github.eirslett</groupId>
						<artifactId>frontend-maven-plugin</artifactId>
						<version>1.9.1</version>
						<executions>
							<execution>
								<id>install node and npm</id>
								<goals>
									<goal>install-node-and-npm</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<nodeVersion>v12.16.1</nodeVersion>
						</configuration>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-webapp-runner</id>
								<phase>package</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<artifactItems>
										<artifactItem>
											<groupId>com.heroku</groupId>
											<artifactId>webapp-runner</artifactId>
											<version>${webapp-runner.version}</version>
											<destFileName>webapp-runner.jar</destFileName>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>heroku-deploy</id>
			<build>
				<plugins>
					<plugin>
						<groupId>com.heroku.sdk</groupId>
						<artifactId>heroku-maven-plugin</artifactId>
						<version>${heroku-maven-plugin}</version>
						<executions>
							<execution>
								<goals>
									<goal>deploy-war</goal>
								</goals>
								<phase>install</phase>
							</execution>
						</executions>
						<configuration>
							<appName>${project.artifactId}</appName>
							<warFile>${project.build.directory}/leaflet4vaadin-demo.war</warFile>
							<logProgress>true</logProgress>
							<includeTarget>false</includeTarget>
							<includes>
								<include>${project.build.directory}/leaflet4vaadin-demo.war</include>
							</includes>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

	</profiles>
</project>