<?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>com.google.gerrit.operator</groupId>
	<artifactId>operator</artifactId>
	<version>${revision}</version>

	<name>Gerrit Kubernetes Operator</name>
	<description>Provisions and operates Gerrit instances in Kubernetes</description>
	<packaging>jar</packaging>

	<properties>
		<revision>1.0.0-SNAPSHOT</revision>

		<fabric8.version>6.6.2</fabric8.version>
		<flogger.version>0.7.4</flogger.version>
		<guice.version>5.1.0</guice.version>
		<javaoperatorsdk.version>4.3.3</javaoperatorsdk.version>
		<jetty.version>11.0.15</jetty.version>
		<lombok.version>1.18.28</lombok.version>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
		<docker.registry>docker.io</docker.registry>
		<docker.org>k8sgerrit</docker.org>

		<test.docker.registry>docker.io</test.docker.registry>
		<test.docker.org>k8sgerritdev</test.docker.org>
	</properties>

	<profiles>
		<profile>
			<id>publish</id>
			<build>
				<plugins>
					<plugin>
						<groupId>com.google.cloud.tools</groupId>
						<artifactId>jib-maven-plugin</artifactId>
						<version>3.3.1</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>build</goal>
								</goals>
								<configuration>
									<container>
										<mainClass>com.google.gerrit.k8s.operator.Main</mainClass>
									</container>
									<containerizingMode>packaged</containerizingMode>
									<from>
										<image>gcr.io/distroless/java:11</image>
									</from>
									<to>
										<image>${docker.registry}/${docker.org}/gerrit-operator</image>
										<tags>
											<tag>${project.version}</tag>
										</tags>
									</to>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>integration-test</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.codehaus.mojo</groupId>
						<artifactId>properties-maven-plugin</artifactId>
						<version>1.1.0</version>
						<executions>
							<execution>
								<phase>initialize</phase>
								<goals>
									<goal>read-project-properties</goal>
								</goals>
								<configuration>
									<files>
										<file>${basedir}/test.properties</file>
									</files>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>com.google.cloud.tools</groupId>
						<artifactId>jib-maven-plugin</artifactId>
						<version>3.3.1</version>
						<executions>
							<execution>
								<phase>pre-integration-test</phase>
								<goals>
									<goal>build</goal>
								</goals>
								<configuration>
									<container>
										<mainClass>com.google.gerrit.k8s.operator.Main</mainClass>
									</container>
									<containerizingMode>packaged</containerizingMode>
									<from>
										<image>gcr.io/distroless/java:11</image>
									</from>
									<to>
										<image>
											${test.docker.registry}/${test.docker.org}/gerrit-operator</image>
										<tags>
											<tag>${project.version}</tag>
										</tags>
									</to>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<artifactId>maven-failsafe-plugin</artifactId>
						<version>2.22.2</version>
						<executions>
							<execution>
								<phase>integration-test</phase>
								<goals>
									<goal>integration-test</goal>
									<goal>verify</goal>
								</goals>
								<configuration>
									<includes>
										<include>**/*E2E.java</include>
									</includes>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<dependencies>
		<dependency>
			<groupId>io.javaoperatorsdk</groupId>
			<artifactId>operator-framework</artifactId>
			<version>${javaoperatorsdk.version}</version>
		</dependency>
		<dependency>
			<groupId>io.javaoperatorsdk</groupId>
			<artifactId>micrometer-support</artifactId>
			<version>${javaoperatorsdk.version}</version>
		</dependency>
		<dependency>
			<groupId>io.javaoperatorsdk</groupId>
			<artifactId>operator-framework-junit-5</artifactId>
			<version>${javaoperatorsdk.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.fabric8</groupId>
			<artifactId>kubernetes-client</artifactId>
			<version>${fabric8.version}</version>
		</dependency>
		<dependency>
			<groupId>io.fabric8</groupId>
			<artifactId>istio-client</artifactId>
			<version>${fabric8.version}</version>
		</dependency>
		<dependency>
			<groupId>io.fabric8</groupId>
			<artifactId>crd-generator-apt</artifactId>
			<version>${fabric8.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>io.fabric8</groupId>
			<artifactId>generator-annotations</artifactId>
			<version>${fabric8.version}</version>
		</dependency>
		<dependency>
			<groupId>org.projectlombok</groupId>
			<artifactId>lombok</artifactId>
			<scope>provided</scope>
			<version>${lombok.version}</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-server</artifactId>
			<version>${jetty.version}</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.jetty</groupId>
			<artifactId>jetty-servlet</artifactId>
			<version>${jetty.version}</version>
		</dependency>
		<dependency>
			<groupId>com.google.flogger</groupId>
			<artifactId>flogger</artifactId>
			<version>${flogger.version}</version>
		</dependency>
		<dependency>
			<groupId>com.google.flogger</groupId>
			<artifactId>flogger-log4j2-backend</artifactId>
			<version>${flogger.version}</version>
		</dependency>
		<dependency>
			<groupId>com.google.inject</groupId>
			<artifactId>guice</artifactId>
			<version>${guice.version}</version>
		</dependency>
		<dependency>
			<groupId>com.google.inject.extensions</groupId>
			<artifactId>guice-assistedinject</artifactId>
			<version>${guice.version}</version>
		</dependency>
		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-slf4j-impl</artifactId>
			<version>2.19.0</version>
		</dependency>
		<dependency>
			<groupId>org.eclipse.jgit</groupId>
			<artifactId>org.eclipse.jgit</artifactId>
			<version>6.5.0.202303070854-r</version>
		</dependency>
		<dependency>
			<groupId>org.bouncycastle</groupId>
			<artifactId>bcpkix-jdk18on</artifactId>
			<version>1.73</version>
		</dependency>
		<dependency>
			<groupId>com.urswolfer.gerrit.client.rest</groupId>
			<artifactId>gerrit-rest-java-client</artifactId>
			<version>0.9.5</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<version>4.8.0</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>io.fabric8</groupId>
			<artifactId>kubernetes-server-mock</artifactId>
			<version>${fabric8.version}</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.google.truth</groupId>
			<artifactId>truth</artifactId>
			<version>0.32</version>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-params</artifactId>
			<version>5.9.2</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>io.fabric8</groupId>
				<artifactId>java-generator-maven-plugin</artifactId>
				<version>${fabric8.version}</version>
				<configuration>
					<source>${project.basedir}/src/main/resources/crd/emissary-crds.yaml</source>
					<!-- Generate sundrio @Buildable annotations that generate Builder classes-->
					<extraAnnotations>true</extraAnnotations>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>generate</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>com.spotify.fmt</groupId>
				<artifactId>fmt-maven-plugin</artifactId>
				<version>2.19</version>
				<executions>
					<execution>
						<goals>
							<goal>format</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.2.2</version>
				<configuration>
					<archive>
						<manifest>
							<mainClass>com.google.gerrit.k8s.operator.Main</mainClass>
							<addDefaultImplementationEntries>
								true
							</addDefaultImplementationEntries>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.google.cloud.tools</groupId>
				<artifactId>jib-maven-plugin</artifactId>
				<version>3.3.1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>dockerBuild</goal>
						</goals>
						<configuration>
							<container>
								<mainClass>com.google.gerrit.k8s.operator.Main</mainClass>
							</container>
							<containerizingMode>packaged</containerizingMode>
							<from>
								<image>gcr.io/distroless/java:11</image>
							</from>
							<to>
								<image>gerrit-operator</image>
								<tags>${revision}</tags>
							</to>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<version>3.3.1</version>
				<executions>
					<execution>
						<id>copy-crds</id>
						<phase>package</phase>
						<goals>
							<goal>copy-resources</goal>
						</goals>
						<configuration>
							<outputDirectory>../helm-charts/gerrit-operator-crds/templates</outputDirectory>
							<resources>
								<resource>
									<directory>target/classes/META-INF/fabric8</directory>
									<includes>
										<include>*-v1.yml</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.10.0</version>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.22.2</version>
				<configuration>
					<includes>
						<include>**/*Test.java</include>
					</includes>
					<rerunFailingTestsCount>1</rerunFailingTestsCount>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>3.4.0</version>
				<executions>
					<execution>
						<id>add-source</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>add-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>${project.build.directory}/generated-sources/annotations/</source>
								<source>${project.build.directory}/generated-sources/java/</source>
								<source>${project.build.directory}/generated-test-sources/java/</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>
