<?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>3.0.0</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>25.2.1</vaadin.version>

		<maven.compiler.source>21</maven.compiler.source>
		<maven.compiler.target>21</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>12.1.2</jetty.version>

		<maven-war-plugin.version>3.4.0</maven-war-plugin.version>
	</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>
		</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/jakarta.servlet/jakarta.servlet-api -->
		<dependency>
			<groupId>jakarta.servlet</groupId>
			<artifactId>jakarta.servlet-api</artifactId>
			<version>6.1.0</version>
			<scope>provided</scope>
		</dependency>


		<dependency>
		    <groupId>org.projectlombok</groupId>
		    <artifactId>lombok</artifactId>
		    <version>1.18.30</version>
		    <scope>provided</scope>
		</dependency>

		<!-- Provides dev mode tooling (Vite dev server, dev tools, Copilot).
		     No longer a transitive dependency of vaadin/vaadin-core in Vaadin 25.
		     Only needed to run the demo in development mode. -->
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-dev</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<defaultGoal>jetty:run</defaultGoal>
		<plugins>
			<plugin>
				<artifactId>maven-clean-plugin</artifactId>
				<version>3.1.0</version>
			</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.ee11</groupId>
				<artifactId>jetty-ee11-maven-plugin</artifactId>
				<version>${jetty.version}</version>
				<configuration>
					<scan>2</scan>
					<httpConnector>
					<!--host>localhost</host-->
					<port>9080</port>
				</httpConnector>
					<systemProperties>
						<vaadin.frontend.hotdeploy>true</vaadin.frontend.hotdeploy>
					</systemProperties>
					<!-- 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.ee11</groupId>
						<artifactId>jetty-ee11-maven-plugin</artifactId>
						<version>${jetty.version}</version>
						<configuration>
							<scan>0</scan>
							<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>
	</profiles>
</project>