<?xml version="1.0" encoding="UTF-8"?><!-- Copyright 2015-2017 floragunn 
	GmbH Licensed under the Apache License, Version 2.0 (the "License"); you 
	may not use this file except in compliance with the License. You may obtain 
	a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless 
	required by applicable law or agreed to in writing, software distributed 
	under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 
	OR CONDITIONS OF ANY KIND, either express or implied. See the License for 
	the specific language governing permissions and limitations under the License. -->

<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.floragunn</groupId>
	<artifactId>sg-upgrade-tool</artifactId>
	<packaging>jar</packaging>
	<name>Search Guard Upgrade Tool</name>
	<version>${revision}</version>

	<properties>
		<revision>master-SNAPSHOT</revision>
		<elasticsearch.version>9.5.2</elasticsearch.version>
		<sg.test-version>main-SNAPSHOT</sg.test-version>
		<maven.compiler.source>17</maven.compiler.source>
		<maven.compiler.target>17</maven.compiler.target>
		<maven.compiler.release>17</maven.compiler.release>
		<license.excludedGroups>.*floragunn.*</license.excludedGroups>
		<license.excludedScopes>test,provided</license.excludedScopes>
        <log4j2.version>2.26.1</log4j2.version>
        <testcontainers.version>2.0.5</testcontainers.version>
	</properties>

	<repositories>
		<repository>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<id>central</id>
			<url>https://repo.maven.apache.org/maven2</url>
		</repository>
		<repository>
			<id>sonatype-nexus-snapshots</id>
			<name>Sonatype Nexus Snapshots</name>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>release</id>
			<url>https://maven.search-guard.com/search-guard-flx-release</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>snapshot</id>
			<url>https://maven.search-guard.com/search-guard-flx-snapshot</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
			</snapshots>
		</repository>
        <repository>
            <id>util-release</id>
            <url>https://maven.search-guard.com:443/util</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
		<repository>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
			<id>third-party</id>
			<url>https://maven.search-guard.com:443/third-party</url>
		</repository>
		<repository>
			<id>elasticsearch-releases</id>
			<url>https://artifacts.elastic.co/maven</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
	<distributionManagement>
		<repository>
			<id>release</id>
			<name>Release repository</name>
			<url>https://maven.search-guard.com:443/search-guard-flx-release</url>
		</repository>
		<snapshotRepository>
			<id>snapshot</id>
			<name>Snapshot repository</name>
			<url>https://maven.search-guard.com:443/search-guard-flx-snapshot</url>
		</snapshotRepository>
	</distributionManagement>

	<dependencies>

		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>33.7.1-jre</version>
			<exclusions>
				<exclusion>
					<groupId>com.google.guava</groupId>
					<artifactId>listenablefuture</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>commons-validator</groupId>
			<artifactId>commons-validator</artifactId>
			<version>1.11.0</version>
			<exclusions>
				<exclusion>
					<!--commons-beanutils in version 1.11.0 or newer is required-->
					<groupId>commons-beanutils</groupId>
					<artifactId>commons-beanutils</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>commons-beanutils</groupId>
			<artifactId>commons-beanutils</artifactId>
			<version>1.11.0</version>
		</dependency>

		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.5.14</version>
		</dependency>

		<dependency>
			<groupId>info.picocli</groupId>
			<artifactId>picocli</artifactId>
			<version>4.7.7</version>
		</dependency>

		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>codova</artifactId>
			<version>[1.10.1,)</version>
		</dependency>

		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>fluent-collections</artifactId>
			<version>[1.0.0,)</version>
		</dependency>

		<dependency>
			<groupId>org.bouncycastle</groupId>
			<artifactId>bcprov-jdk18on</artifactId>
			<version>1.85.2</version>
		</dependency>

		<dependency>
			<groupId>org.bouncycastle</groupId>
			<artifactId>bcpg-jdk18on</artifactId>
			<version>1.85</version>
		</dependency>

		<dependency>
			<groupId>org.bouncycastle</groupId>
			<artifactId>bcpkix-jdk18on</artifactId>
			<version>1.85</version>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.21.6</version>
		</dependency>

		<dependency>
			<groupId>com.fasterxml.jackson.dataformat</groupId>
			<artifactId>jackson-dataformat-yaml</artifactId>
			<version>2.21.6</version>
			<exclusions>
				<exclusion>
					<artifactId>jackson-databind</artifactId>
					<groupId>com.fasterxml.jackson.core</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-api</artifactId>
			<version>2.0.18</version>
		</dependency>
		
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-jdk14</artifactId>
			<version>2.0.18</version>
		</dependency>

		<!-- ### Test Dependencies ### -->
		<!-- Declared unconditionally so that the *IT sources always compile; they are only executed by the
		     integration-tests profile, which needs a reachable Docker daemon. -->
		<dependency>
			<groupId>org.testcontainers</groupId>
			<artifactId>testcontainers</artifactId>
			<version>${testcontainers.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<version>6.1.3</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-migrationsupport</artifactId>
			<version>6.1.3</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.wiremock</groupId>
			<artifactId>wiremock</artifactId>
			<version>3.13.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>com.jayway.jsonpath</groupId>
			<artifactId>json-path</artifactId>
			<version>3.0.0</version>
			<exclusions>
				<exclusion>
					<groupId>net.minidev</groupId>
					<artifactId>json-smart</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>net.minidev</groupId>
			<artifactId>json-smart</artifactId>
			<version>2.6.0</version>
			<!-- replacement for com.jayway.jsonpath:json-path -->
		</dependency>

		<dependency>
			<groupId>org.elasticsearch</groupId>
			<artifactId>elasticsearch</artifactId>
			<scope>test</scope>
			<version>${elasticsearch.version}</version>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch.plugin</groupId>
			<artifactId>lang-mustache</artifactId>
			<scope>test</scope>
			<version>${elasticsearch.version}</version>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch.plugin</groupId>
			<artifactId>percolator</artifactId>
			<version>${elasticsearch.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch.plugin</groupId>
			<artifactId>parent-join</artifactId>
			<version>${elasticsearch.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch.plugin</groupId>
			<artifactId>reindex</artifactId>
			<version>${elasticsearch.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch</groupId>
			<artifactId>elasticsearch-ssl-config</artifactId>
			<version>${elasticsearch.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.elasticsearch.plugin</groupId>
			<artifactId>rest-root</artifactId>
			<version>${elasticsearch.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.github.spullara.mustache.java</groupId>
			<artifactId>compiler</artifactId>
			<version>0.9.14</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>search-guard-flx-security</artifactId>
			<scope>test</scope>
			<version>${sg.test-version}</version>
		</dependency>
		
		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>search-guard-flx-ssl</artifactId>
			<scope>test</scope>
			<version>${sg.test-version}</version>
		</dependency>		

		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>search-guard-flx-support</artifactId>
			<scope>test</scope>
			<version>${sg.test-version}</version>
		</dependency>


		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>search-guard-flx-security</artifactId>
			<classifier>tests</classifier>
			<scope>test</scope>
			<version>${sg.test-version}</version>
		</dependency>

		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>dlic-search-guard-flx-security</artifactId>
			<scope>test</scope>
			<version>${sg.test-version}</version>
		</dependency>
		
		<dependency>
			<groupId>com.floragunn</groupId>
			<artifactId>dlic-search-guard-flx-fe-multi-tenancy</artifactId>
			<scope>test</scope>
			<version>${sg.test-version}</version>
		</dependency>		
	
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<scope>test</scope>
			<version>2.22.0</version>
		</dependency>

		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-api</artifactId>
			<version>${log4j2.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.apache.logging.log4j</groupId>
			<artifactId>log4j-core</artifactId>
			<version>${log4j2.version}</version>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.awaitility</groupId>
			<artifactId>awaitility</artifactId>
			<version>4.3.0</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-junit-jupiter</artifactId>
			<version>5.23.0</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<version>5.23.0</version>
			<scope>test</scope>
			<exclusions>
				<!-- Java 21 is not supported by byte-buddy version used by mockito 5.23.0 -->
				<exclusion>
					<groupId>net.bytebuddy</groupId>
					<artifactId>byte-buddy</artifactId>
				</exclusion>
				<exclusion>
					<groupId>net.bytebuddy</groupId>
					<artifactId>byte-buddy-agent</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<!-- replacement for byte-buddy used by mockito -->
			<groupId>net.bytebuddy</groupId>
			<artifactId>byte-buddy</artifactId>
			<version>1.18.12-jdk5</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<!-- replacement for byte-buddy used by mockito -->
			<groupId>net.bytebuddy</groupId>
			<artifactId>byte-buddy-agent</artifactId>
			<version>1.18.12-jdk5</version>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-enforcer-plugin</artifactId>
				<version>3.6.3</version>
				<executions>
					<execution>
						<id>enforce-java-and-maven</id>
						<goals>
							<goal>enforce</goal>
						</goals>
						<configuration>
							<rules>
								<requireJavaVersion>
									<version>[17,)</version>
								</requireJavaVersion>
								<requireMavenVersion>
									<version>[3.8.1,)</version>
								</requireMavenVersion>
							</rules>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>0.8.15</version>
				<executions>
					<execution>
						<id>prepare-agent</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
						<configuration>
							<propertyName>surefireArgLine</propertyName>
						</configuration>
					</execution>
					<execution>
						<id>default-report</id>
						<goals>
							<goal>report</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.15.0</version>
				<configuration>
					<showDeprecation>true</showDeprecation>
					<showWarnings>true</showWarnings>
					<annotationProcessorPaths>
						<path>
							<groupId>info.picocli</groupId>
							<artifactId>picocli-codegen</artifactId>
							<version>4.7.7</version>
						</path>
					</annotationProcessorPaths>
					<compilerArgs>
						<arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
					</compilerArgs>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>3.5.6</version>
				<configuration>
					<argLine>-Xmx3072m ${surefireArgLine}</argLine>
					<includes>
						<include>**/*.java</include>
					</includes>
					<!--
					  The include above is broad enough to pick up the *IT classes as well. Those need a Docker daemon
					  and belong to failsafe and the integration-tests profile, so surefire - and with it the ordinary
					  build job in CI - has to leave them alone.
					-->
					<excludes>
						<exclude>**/*IT.java</exclude>
					</excludes>
					<trimStackTrace>false</trimStackTrace>
					<classpathDependencyExcludes>
						<classpathDependencyExclude>org.apache.logging.log4j:log4j-to-slf4j</classpathDependencyExclude>
					</classpathDependencyExcludes>
					<forkCount>1</forkCount>
					<reuseForks>false</reuseForks>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.8.0</version>

				<executions>
					<execution>
						<id>sg-upgrade-tool</id>
						<phase>package</phase>
						<configuration>
							<appendAssemblyId>false</appendAssemblyId>
							<tarLongFileMode>posix</tarLongFileMode>
							<outputDirectory>target/releases/</outputDirectory>
							<descriptors>
								<descriptor>src/main/assemblies/sg-upgrade-tool.xml</descriptor>
							</descriptors>
						</configuration>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>license-maven-plugin</artifactId>
				<version>2.7.1</version>

				<executions>
					<execution>
						<id>sg-upgrade-tool-license</id>
						<configuration>
							<licenseMerges>
								<licenseMerge>Apache License, Version 2.0|Apache Public License 2.0|The Apache Software License, Version 2.0|Apache 2.0|The Apache Software License, version 2.0</licenseMerge>
								<licenseMerge>MIT License|The MIT License</licenseMerge>
							</licenseMerges>
						</configuration>
						<goals>
							<goal>add-third-party</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.6.2</version>
				<executions>
					<execution>
						<phase>package</phase>
						<configuration>
							<outputDirectory>target/releases/</outputDirectory>
							<shadedArtifactAttached>true</shadedArtifactAttached>
							<shadedClassifierName>shaded</shadedClassifierName>
							<minimizeJar>true</minimizeJar>
							<transformers>
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer" />
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
								<transformer
									implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
									<mainClass>com.floragunn.searchguard.upgradetool.UpgradeTool</mainClass>
								</transformer>
							</transformers>
							<createDependencyReducedPom>false</createDependencyReducedPom>
							<filters>
								<filter>
									<artifact>*:*</artifact>
									<excludes>
										<exclude>module-info.class</exclude>
										<exclude>META-INF/*.SF</exclude>
										<exclude>META-INF/*.DSA</exclude>
										<exclude>META-INF/*.RSA</exclude>
									</excludes>
								</filter>
								<filter>
									<artifact>commons-logging:commons-logging</artifact>
									<includes>
										<include>**</include>
									</includes>
								</filter>
							</filters>
						</configuration>
						<goals>
							<goal>shade</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.skife.maven</groupId>
				<artifactId>really-executable-jar-maven-plugin</artifactId>
				<version>2.1.1</version>
				<configuration>
					<classifier>shaded</classifier>
					<flags>-Xmx1G</flags>
					<programFile>./sg-upgrade-tool.sh</programFile>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>really-executable-jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>3.6.1</version>
				<executions>
					<execution>
						<id>attach-artifacts</id>
						<phase>package</phase>
						<goals>
							<goal>attach-artifact</goal>
						</goals>
						<configuration>
							<artifacts>
								<artifact>
									<file>${basedir}/target/releases/sg-upgrade-tool.sh</file>
									<type>sh</type>
								</artifact>
							</artifacts>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<profiles>
		<!--
		  Container based integration tests against a real Elasticsearch node with Search Guard installed.
		  Off by default because they need a reachable Docker daemon and pull a ~2 GB image:

		      mvn verify -Pintegration-tests

		  There is one image per Elasticsearch major, pinned in SearchGuardImage, and the cross-major tests
		  take one data directory through a sequence of them. Each default can be overridden for a whole run:

		      mvn verify -Pintegration-tests -Dsg.it.es9.image=<full image reference>

		  A single test pins its own images by overriding upgradeSequence(). The properties are empty here on
		  purpose - empty means "use the default in SearchGuardImage", so defaults live in one place.
		-->
		<profile>
			<id>integration-tests</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-failsafe-plugin</artifactId>
						<version>3.5.6</version>
						<configuration>
							<argLine>-Xmx1536m</argLine>
							<trimStackTrace>false</trimStackTrace>
							<includes>
								<include>**/*IT.java</include>
							</includes>
							<systemPropertyVariables>
								<sg.it.es7.image>${sg.it.es7.image}</sg.it.es7.image>
								<sg.it.es8.image>${sg.it.es8.image}</sg.it.es8.image>
								<sg.it.es9.image>${sg.it.es9.image}</sg.it.es9.image>
							</systemPropertyVariables>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>integration-test</goal>
									<goal>verify</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
			<properties>
				<!-- Empty by default: SearchGuardImage then falls back to the version it pins for that major. -->
				<sg.it.es7.image />
				<sg.it.es8.image />
				<sg.it.es9.image />
			</properties>
		</profile>
	</profiles>

</project>
