<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.jkube</groupId>
	<artifactId>parent</artifactId>
	<version>0.0.6</version>
	<name>org-jkube-parent-pom</name>
	<description>Definition of parent pom for JKube</description>
	<url>http://www.jkube.org</url>
	<licenses>
		<license>
			<name>MIT License</name>
			<url>http://www.opensource.org/licenses/mit-license.php</url>
			<distribution>repo</distribution>
		</license>
	</licenses>
	<developers>
		<developer>
			<name>Jan Kneissler</name>
			<email>j@kneissler.com</email>
		</developer>
	</developers>
	<scm>
		<connection>scm:git:git://bitbucket.org/jkubeorg/parent.git</connection>
		<developerConnection>scm:git:ssh://bitbucket.org:jkubeorg/parent.git</developerConnection>
		<url>https://bitbucket.org/simpligility/jkubeorg/parent/src</url>
	</scm>
	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>15</java.version>
		<junit.version>5.5.2</junit.version>
		<maven.plugin.version>3.8.0</maven.plugin.version>
		<main.class>MAIN_CLASS_UNDEFINED</main.class>
		<jar.name>main</jar.name>

		<!-- Docker -->
		<dockerfile-maven-plugin.version>1.4.13</dockerfile-maven-plugin.version>
		<dockerfile.build.squash>false</dockerfile.build.squash>
		<docker.repo>docker.io</docker.repo>
		<docker.repo.user>jkube</docker.repo.user>
		<docker.repo.password>DOCKER_REPO_PASSWORD</docker.repo.password>
		<dockerfile.skip>true</dockerfile.skip>
		<docker.image>parent-pom</docker.image>
		<git.branch>master</git.branch>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
	</properties>
	<packaging>pom</packaging>
	<build>
		<extensions>
			<extension>
				<groupId>org.apache.maven.wagon</groupId>
				<artifactId>wagon-ssh</artifactId>
				<version>3.0.0</version>
			</extension>
		</extensions>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven.plugin.version}</version>
				<configuration>
					<release>${java.version}</release>
					<forceJavacCompilerUse>true</forceJavacCompilerUse>
				</configuration>
			</plugin>
<!--			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				-->
				<!-- latest version (2.20.1) does not work well with JUnit5 -->
<!--				<version>2.19.1</version>
				<dependencies>
					<dependency>
						<groupId>org.junit.platform</groupId>
						<artifactId>junit-platform-surefire-provider</artifactId>
						<version>1.0.3</version>
					</dependency>
					<dependency>
						<groupId>org.junit.jupiter</groupId>
						<artifactId>junit-jupiter-engine</artifactId>
						<version>${junit.version}</version>
					</dependency>
				</dependencies>
			</plugin>-->
			<plugin>
				<!-- the following tells maven to write pom version into manifest -->
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.1.2</version>
				<configuration>
					<archive>
						<manifest>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>2.3</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<transformers>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<manifestEntries>
										<Main-Class>${main.class}</Main-Class>
									</manifestEntries>
								</transformer>
							</transformers>
							<artifactSet />
							<outputFile>${project.build.directory}/${jar.name}.jar</outputFile>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>3.0.0</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>src/main/autogen</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- create and push a docker file -->
			<plugin>
				<groupId>com.spotify</groupId>
				<artifactId>dockerfile-maven-plugin</artifactId>
				<version>${dockerfile-maven-plugin.version}</version>
				<executions>
					<execution>
						<id>build</id>
						<phase>package</phase>
						<goals>
							<goal>build</goal>
							<goal>push</goal>
						</goals>
						<configuration>
							<tag>${git.branch}-${project.version}</tag>
						</configuration>
					</execution>
					<execution>
						<id>tag</id>
						<phase>package</phase>
						<goals>
							<goal>tag</goal>
							<goal>push</goal>
						</goals>
						<configuration>
							<tag>${git.branch}</tag>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<username>${docker.repo.user}</username>
					<password>${docker.repo.password}</password>
					<repository>${docker.repo}/${docker.repo.user}/${docker.image}</repository>
					<tag>${project.version}</tag>
					<buildArgs>
						<JAR_FILE>target/${jar.name}.jar</JAR_FILE>
					</buildArgs>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>2.2.1</version>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar-no-fork</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.9.1</version>
				<configuration>
				<source>${java.version}</source>
				</configuration>
				<executions>
					<execution>
						<id>attach-javadocs</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-gpg-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>sign-artifacts</id>
						<phase>verify</phase>
						<goals>
							<goal>sign</goal>
						</goals>
						<configuration>
							<gpgArguments>
								<arg>--pinentry-mode</arg>
								<arg>loopback</arg>
							</gpgArguments>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.sonatype.plugins</groupId>
				<artifactId>nexus-staging-maven-plugin</artifactId>
				<version>1.6.8</version>
				<extensions>true</extensions>
				<configuration>
					<serverId>ossrh</serverId>
					<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
					<autoReleaseAfterClose>true</autoReleaseAfterClose>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<distributionManagement>
		<snapshotRepository>
			<id>ossrh</id>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
		<repository>
			<id>ossrh</id>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
		</repository>
	</distributionManagement>
</project>
