<?xml version="1.0" encoding="UTF-8"?>
<!--

    The MIT License
    Copyright © 2023 Landeshauptstadt München | it@M

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.

-->
<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>de.muenchen.oss.appswitcher</groupId>
	<artifactId>appswitcher-vaadin</artifactId>
	<version>1.0.2</version>
	<name>appswitcher-vaadin</name>
	<description>Appswitcher for Vaadin</description>
	<url>https://github.com/it-at-m/appswitcher-vaadin</url>

	<properties>
		<!-- Main Dependencies -->
		<vaadin.version>24.4.12</vaadin.version>
		<jetty.version>11.0.24</jetty.version>

		<maven.compiler.source>17</maven.compiler.source>
		<maven.compiler.target>17</maven.compiler.target>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

		<itm-codeformat.version>1.0.10</itm-codeformat.version>
	</properties>

	<organization>
		<name>Landeshauptstadt München - it@M</name>
		<url>https://muenchen.digital/it-at-m/</url>
	</organization>

	<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 used by many Vaadin add-ons -->
		<repository>
			<id>Vaadin Directory</id>
			<url>https://maven.vaadin.com/vaadin-addons</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>

	<scm>
		<url>https://github.com/it-at-m/appswitcher-vaadin</url>
		<connection>scm:git:https://github.com/it-at-m/appswitcher-vaadin.git</connection>
		<developerConnection>
			scm:git:https://github.com/it-at-m/appswitcher-vaadin.git</developerConnection>
		<tag>v1.0.2</tag>
	</scm>


	<dependencies>
		<dependency>
			<groupId>com.vaadin</groupId>
			<artifactId>vaadin-core</artifactId>
		</dependency>
		<dependency>
			<groupId>com.vaadin.componentfactory</groupId>
			<artifactId>popup</artifactId>
			<version>24.0.5</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.github.bonigarcia</groupId>
			<artifactId>webdrivermanager</artifactId>
			<version>5.9.2</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<defaultGoal>jetty:run</defaultGoal>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.4.2</version>
				<configuration>
					<archive>
						<index>true</index>
						<manifest>
							<addClasspath>false</addClasspath>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
						</manifest>
						<manifestEntries>
							<Vaadin-Package-Version>1</Vaadin-Package-Version>
						</manifestEntries>
					</archive>
					<!-- Generated file that shouldn't be included in add-ons -->
					<excludes>
						<exclude>META-INF/VAADIN/config/flow-build-info.json</exclude>
					</excludes>
				</configuration>
			</plugin>
			<!--
             Take care of synchronizing java dependencies and imports in
             package.json and main.js files.
             It also creates webpack.config.js if not exists yet.
             -->
			<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>
					<scan>2</scan>
					<!-- Use test scope because the UI/test classes are in
                        the test package. -->
					<useTestScope>true</useTestScope>
					<supportedPackagings>
						<supportedPackaging>jar</supportedPackaging>
					</supportedPackagings>
					<systemProperties>
						<vaadin.frontend.hotdeploy>true</vaadin.frontend.hotdeploy>
					</systemProperties>
				</configuration>
			</plugin>
			<!-- license plugin -->
			<plugin>
				<groupId>com.mycila</groupId>
				<artifactId>license-maven-plugin</artifactId>
				<version>4.6</version>
				<configuration>
					<properties>
						<owner>Landeshauptstadt München | it@M</owner>
						<year>2023</year>
					</properties>
					<licenseSets>
						<licenseSet>
							<header>
								com/mycila/maven/plugin/license/templates/MIT.txt</header>
							<includes>
								<include>**/*.java</include>
								<include>**/*.xml</include>
								<include>**/*.yml</include>
								<include>**/*.properties</include>
							</includes>
							<excludes>
								<exclude>**/LICENSE</exclude>
								<exclude>**/README</exclude>
								<exclude>**/src/test/resources/**</exclude>
								<exclude>**/src/main/resources/**</exclude>
							</excludes>
						</licenseSet>
					</licenseSets>
					<mapping>
						<java>SLASHSTAR_STYLE</java>
					</mapping>
					<dependencyEnforce>true</dependencyEnforce>
					<dependencyPolicies>
						<dependencyPolicy>
							<type>LICENSE_NAME</type>
							<rule>APPROVE</rule>
							<value>Apache License, Version 2.0</value>
						</dependencyPolicy>
						<dependencyPolicy>
							<type>LICENSE_NAME</type>
							<rule>APPROVE</rule>
							<value>Apache License Version 2.0</value>
						</dependencyPolicy>
						<dependencyPolicy>
							<type>LICENSE_NAME</type>
							<rule>APPROVE</rule>
							<value>The Apache Software License, Version 2.0</value>
						</dependencyPolicy>
						<dependencyPolicy>
							<type>LICENSE_NAME</type>
							<rule>APPROVE</rule>
							<value>MIT License</value>
						</dependencyPolicy>
						<dependencyPolicy>
							<type>LICENSE_NAME</type>
							<rule>APPROVE</rule>
							<value>The MIT License</value>
						</dependencyPolicy>
					</dependencyPolicies>
				</configuration>
				<executions>
					<execution>
						<id>check-license-headers</id>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<!-- Nexus Staging Plugin -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<version>3.1.1</version>
				<configuration>
					<useReleaseProfile>false</useReleaseProfile>
					<releaseProfiles>release</releaseProfiles>
					<goals>deploy</goals>
					<tagNameFormat>v@{project.version}</tagNameFormat>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.diffplug.spotless</groupId>
				<artifactId>spotless-maven-plugin</artifactId>
				<version>2.33.0</version>
				<dependencies>
					<dependency>
						<groupId>de.muenchen.oss</groupId>
						<artifactId>itm-java-codeformat</artifactId>
						<version>${itm-codeformat.version}</version>
					</dependency>
				</dependencies>
				<configuration>
					<java>
						<includes>
							<include>src/main/java/**/*.java</include> <!-- Check
							application code -->
							<include>src/test/java/**/*.java</include> <!-- Check
							application tests code -->
						</includes>
						<eclipse>
							<file>
								itm-java-codeformat/java_codestyle_formatter.xml</file>
						</eclipse>
						<trimTrailingWhitespace />
						<endWithNewline />
					</java>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

		</plugins>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.sonatype.central</groupId>
					<artifactId>central-publishing-maven-plugin</artifactId>
					<version>0.6.0</version>
					<extensions>true</extensions>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>

	<profiles>
		<profile>
			<id>release</id>
			<build>
				<plugins>
					<!-- maven versions plugin-->
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>versions-maven-plugin</artifactId>
						<version>2.17.1</version>
					</plugin>
					<!-- Source plugin -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-source-plugin</artifactId>
						<version>3.3.1</version>
						<executions>
							<execution>
								<id>attach-sources</id>
								<goals>
									<goal>jar-no-fork</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

					<!-- Javadoc plugin -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-javadoc-plugin</artifactId>
						<version>3.10.0</version>
						<executions>
							<execution>
								<id>attach-javadocs</id>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<doclint>none</doclint>
							<sourceFileIncludes>
								<sourceFileInclude>**/*.java</sourceFileInclude>
							</sourceFileIncludes>
						</configuration>
					</plugin>

					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>3.4.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>

					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-assembly-plugin</artifactId>
						<version>3.7.1</version>
						<configuration>
							<appendAssemblyId>false</appendAssemblyId>
							<descriptors>
								<descriptor>src/main/assembly/assembly.xml</descriptor>
							</descriptors>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>single</goal>
								</goals>
								<phase>package</phase>
							</execution>
						</executions>
					</plugin>

					<!-- publish to central -->
					<plugin>
						<groupId>org.sonatype.central</groupId>
						<artifactId>central-publishing-maven-plugin</artifactId>
						<configuration>
							<autoPublish>true</autoPublish>
							<tokenAuth>true</tokenAuth>
							<deploymentName>
								${project.groupId}:${project.version}</deploymentName>
						</configuration>
					</plugin>
					
					<!-- GPG plugin -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>3.2.6</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
								<configuration>
									<!-- Prevent `gpg` from using pinentry
									programs -->
									<gpgArguments>
										<arg>--pinentry-mode</arg>
										<arg>loopback</arg>
									</gpgArguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!-- Production mode is activated using -Pproduction -->
			<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>build-frontend</goal>
								</goals>
								<phase>compile</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<id>it</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.eclipse.jetty</groupId>
						<artifactId>jetty-maven-plugin</artifactId>
						<configuration>
							<scan>0</scan>
							<stopPort>8081</stopPort>
							<useTestScope>true</useTestScope>
							<supportedPackagings>
								<supportedPackaging>jar</supportedPackaging>
							</supportedPackagings>
							<stopWait>15</stopWait>
							<stopKey>${project.artifactId}</stopKey>
						</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>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<skip>true</skip>
						</configuration>
					</plugin>

					<!-- Runs the integration tests (*IT) after the server is
					started -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-failsafe-plugin</artifactId>
						<version>3.5.0</version>
						<executions>
							<execution>
								<goals>
									<goal>integration-test</goal>
									<goal>verify</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<trimStackTrace>false</trimStackTrace>
							<enableAssertions>true</enableAssertions>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<licenses>
		<license>
			<name>MIT License</name>
		</license>
	</licenses>

	<developers>
		<developer>
			<name>Michael Prankl</name>
			<organization>Landeshauptstadt München</organization>
			<url>https://github.com/eidottermihi</url>
			<roles>
				<role>initiator</role>
			</roles>
		</developer>
	</developers>

</project>
