<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>key-management-sshteam</artifactId>

    <parent>
	    <groupId>com.sshtools</groupId>
	    <artifactId>key-management</artifactId>
	    <version>1.1.0-SNAPSHOT</version>
        <relativePath>../</relativePath>
    </parent>

	<properties>
		<build.mediaTypes>windows,unixInstaller,macos,macosFolder,windowsArchive,unixArchive,linuxRPM,linuxDeb,macosArchive,macosFolderArchive</build.mediaTypes>
		<build.install4j.project>${project.basedir}/installer.install4j</build.install4j.project>
		<build.projectProperties>${basedir}/jadaptive.build.properties</build.projectProperties>
		<build.userProperties>${user.home}/.jadaptive.build.properties</build.userProperties>
		
		<maverick.synergy.version>3.1.0-SNAPSHOT</maverick.synergy.version>
		<install4j.home>_SET_IN_HOME_DOT_JADAPTIVE_DOT_BUILD_DOT_PROPERTIES_</install4j.home>
		<install4j.licenseKey>_SET_IN_HOME_DOT_JADAPTIVE_DOT_BUILD_DOT_PROPERTIES_</install4j.licenseKey>
		<install4j.appleId>_SET_IN_HOME_DOT_JADAPTIVE_DOT_BUILD_DOT_PROPERTIES_</install4j.appleId>
		<install4j.appleIdPassword>_SET_HOME_IN_DOT_JADAPTIVE_DOT_BUILD_DOT_PROPERTIES_</install4j.appleIdPassword>
		
		<graalvm.version>21.2.0</graalvm.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>key-management-lib</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.sshtools.hotfixes</groupId>
			<artifactId>maverick-synergy-client</artifactId>
			<version>${maverick.synergy.version}</version>
		</dependency>
		<dependency>
			<groupId>com.sshtools.hotfixes</groupId>
			<artifactId>maverick-bc</artifactId>
			<version>${maverick.synergy.version}</version>
		</dependency>
		<dependency>
			<groupId>info.picocli</groupId>
			<artifactId>picocli</artifactId>
			<version>4.6.3</version>
		</dependency>
		<dependency>
		    <groupId>org.slf4j</groupId>
		    <artifactId>slf4j-nop</artifactId>
		    <version>1.7.36</version>
		    <scope>provided</scope>
		</dependency>

	</dependencies>
	
	<profiles>
		<!-- Graal Native Image -->
		<profile>
			<id>native-image</id>
			

			<distributionManagement>
				<!-- These are for the jars of natively compiled commands -->
				<repository>
					<id>libs-releases-local</id>
					<name>libs-releases</name>
					<url>https://artifactory.jadaptive.com/libs-releases-local</url>
				</repository>
				<snapshotRepository>
					<id>libs-snapshots-local</id>
					<name>libs-snapshots</name>
					<url>https://artifactory.jadaptive.com/libs-snapshots-local</url>
				</snapshotRepository>
			</distributionManagement>
	
			<dependencies>
				<dependency>
					<groupId>org.graalvm.sdk</groupId>
					<artifactId>graal-sdk</artifactId>
					<version>${graalvm.version}</version>
					<scope>provided</scope>
				</dependency>
				<dependency>
					<groupId>com.install4j</groupId>
					<artifactId>install4j-runtime</artifactId>
					<version>10.0.4</version>
				</dependency>
			</dependencies>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-antrun-plugin</artifactId>
						<executions>
							<execution>
								<id>create-exe-dir</id>
								<configuration>
									<tasks>
										<mkdir dir="${project.build.directory}/exe" />
									</tasks>
								</configuration>
								<phase>package</phase>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.graalvm.nativeimage</groupId>
						<artifactId>native-image-maven-plugin</artifactId>
						<version>${graalvm.version}</version>
						<executions>
							<execution>
								<id>registerRemoteAssign-native-image</id>
								<goals>
									<goal>native-image</goal>
								</goals>
								<phase>package</phase>
								<configuration>
									<mainClass>com.sshteam.commands.RegisterRemoteAssign</mainClass>
									<skip>false</skip>
									<imageName>registerRemoteAssign</imageName>
									<outputDirectory>${project.build.directory}/exe</outputDirectory>
									<buildArgs>--allow-incomplete-classpath
										--report-unsupported-elements-at-runtime
									</buildArgs>
								</configuration>
							</execution>
							<execution>
								<id>unregisterRemoteAssign-native-image</id>
								<goals>
									<goal>native-image</goal>
								</goals>
								<phase>package</phase>
								<configuration>
									<mainClass>com.sshteam.commands.UnregisterRemoteAssign</mainClass>
									<skip>false</skip>
									<imageName>unregisterRemoteAssign</imageName>
									<outputDirectory>${project.build.directory}/exe</outputDirectory>
									<buildArgs>--allow-incomplete-classpath
										--report-unsupported-elements-at-runtime
									</buildArgs>
								</configuration>
							</execution>
							<execution>
								<id>authorizedKeys-native-image</id>
								<goals>
									<goal>native-image</goal>
								</goals>
								<phase>package</phase>
								<configuration>
									<mainClass>com.sshteam.commands.AuthorizedKeys</mainClass>
									<skip>false</skip>
									<imageName>authorizedKeys</imageName>
									<outputDirectory>${project.build.directory}/exe</outputDirectory>
									<buildArgs>--allow-incomplete-classpath
										--report-unsupported-elements-at-runtime
									</buildArgs>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jar-plugin</artifactId>
						<version>3.3.0</version>
						<executions>
							<execution>
								<phase>package</phase>
								<goals>
									<goal>jar</goal>
								</goals>
								<configuration>
									<archive>
										<addMavenDescriptor>false</addMavenDescriptor>
										<forced>true</forced>
									</archive>
									<classifier>${build.platform}</classifier>
									<classesDirectory>${project.build.directory}/exe</classesDirectory>
									<includes>
										<include>authorizedKeys</include>
										<include>registerRemoteAssign</include>
										<include>unregisterRemoteAssign</include>
									</includes>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>install4j-installers</id>
			<activation>
				<property>
					<name>buildInstaller</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-dependency-plugin</artifactId>
						<configuration>
							<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
						</configuration>
						<executions>
							<execution>
								<id>copy-linux-amd64</id>
								<phase>package</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
								<configuration>
									<outputDirectory>${project.build.directory}/dependencies/linux-amd64</outputDirectory>
									<artifactItems>
										<artifactItem>
											<groupId>com.sshtools</groupId>
											<artifactId>key-management-sshteam</artifactId>
											<classifier>linux-amd64</classifier>
											<version>${project.version}-SNAPSHOT</version>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
							<execution>
								<id>copy-macos-x86_64</id>
								<phase>package</phase>
								<goals>
									<goal>unpack</goal>
								</goals>
								<configuration>
									<outputDirectory>${project.build.directory}/dependencies/macos-x86_64</outputDirectory>
									<artifactItems>
										<artifactItem>
											<groupId>com.sshtools</groupId>
											<artifactId>key-management-sshteam</artifactId>
											<classifier>macos-x86_64</classifier>
											<version>${project.version}-SNAPSHOT</version>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>com.install4j</groupId>
						<artifactId>install4j-maven</artifactId>
						<executions>
							<execution>
								<id>compile-installers</id>
								<phase>package</phase>
								<goals>
									<goal>compile</goal>
								</goals>
								<configuration>
									<variables>
										<build.phase>${build.phase}</build.phase>
									</variables>
									<mediaTypes>${build.mediaTypes}</mediaTypes>
									<projectFile>${project.basedir}/sshteam.install4j</projectFile>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<annotationProcessorPaths>
						<path>
							<groupId>info.picocli</groupId>
							<artifactId>picocli-codegen</artifactId>
							<version>4.6.1</version>
						</path>
					</annotationProcessorPaths>
				</configuration>
			</plugin>
			
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<version>1.0.0</version>
				<executions>
					<execution>
						<phase>initialize</phase>
						<goals>
							<goal>read-project-properties</goal>
						</goals>
						<configuration>
							<quiet>true</quiet>
							<files>
								<file>${basedir}/jadaptive.build.properties</file>
								<file>${user.home}/.jadaptive.build.properties</file>
							</files>
						</configuration>
					</execution>
				</executions>
			</plugin>
			
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>prepare-package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<outputDirectory>target/third-party</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
	<repositories>
		<repository>
			<id>libs-releases</id>
			<name>libs-releases-local</name>
			<releases/>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
			<url>https://artifactory.jadaptive.com/libs-releases-local</url>
		</repository>
		<repository>
			<id>libs-snapshots</id>
			<name>libs-snapshots-local</name>
			<snapshots/>
			<releases>
				<enabled>true</enabled>
			</releases>
			<url>https://artifactory.jadaptive.com/libs-snapshots-local</url>
		</repository>
		<repository>
			<id>ej-technologies</id>
			<url>https://maven.ej-technologies.com/repository</url>
			<releases/>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
</project>
