<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-install4j</artifactId>

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

	<properties>
		
		<build.phase>continuous</build.phase>	
		<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>
	</properties>

	<dependencies>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>key-management-jfx</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>key-management-commands</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>${project.groupId}</groupId>
			<artifactId>key-management-sshteam</artifactId>
			<version>${project.version}</version>
		</dependency>
	</dependencies>
	
	<build>
		<plugins>
			
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<executions>
					<!-- The build number. This will be set to ZERO if BUILD_NUMBER is not 
			set. Jenkins will set BUILD_NUMBER, or you can set it in the environment 
			before running maven for build testing. -->
					<execution>
						<id>build-number-property</id>
						<goals>
							<goal>regex-property</goal>
						</goals>
						<phase>initialize</phase>
						<configuration>
							<!-- Set build.number to zero if it is blank. This uses a bit of regular 
					expression trickery. Because Jenkins supplies BUILD_NUMBER as an environment 
					variable, and we also want the build to work outside of Jenkins, then the 
					below is used to set build.number to zero if BUILD_NUMBER is not set. There 
					is no easy way to do this with basic Maven, and build-helper doesn't like 
					empty variables either, so we prefix it with zero, then use capture groups 
					to correct the format for both situations -->
							<name>product.version</name>
							<value>${project.version}</value>
							<regex>^([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9A-Za-z]+)$</regex>
							<replacement>$1.$2.$3</replacement>
							<failIfNoMatch>false</failIfNoMatch>
						</configuration>
					</execution>
					<execution>
						<id>product-version-property</id>
						<goals>
							<goal>regex-property</goal>
						</goals>
						<phase>initialize</phase>
						<configuration>
							<!-- Strip off -SNAPSHOT (or other suffix) -->
							<name>build.number</name>
							<value>0${env.BUILD_NUMBER}</value>
							<regex>^(?:0?)([0-9]+)(?:\$\{env\.BUILD_NUMBER\})?$</regex>
							<replacement>$1</replacement>
							<failIfNoMatch>false</failIfNoMatch>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<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>
			</plugin>
		</plugins>
		
	</build>
	
	
	<profiles>
		<profile>
			<id>mac-jfx</id>
			<activation>
				<os>
					<family>mac</family>
				</os>
			</activation>
			<properties>
				<javafx.os.family>mac</javafx.os.family>
			</properties>
		</profile>
		<profile>
			<id>linux-jfx</id>
			<activation>
				<os>
					<family>linux</family>
				</os>
			</activation>
			<properties>
				<javafx.os.family>linux</javafx.os.family>
			</properties>
		</profile>
		<profile>
			<id>windows-jfx</id>
			<activation>
				<os>
					<family>windows</family>
				</os>
			</activation>
			<properties>
				<javafx.os.family>windows</javafx.os.family>
			</properties>
		</profile>
		<!-- Graal Native Image -->
		<profile>
			<id>native-images</id>
			<build>
				<plugins>
					<plugin>
						<groupId>com.gluonhq</groupId>
						<artifactId>gluonfx-maven-plugin</artifactId>
						<version>1.0.16</version>
						<configuration>
							<mainClass>${main.class}</mainClass>
						</configuration>
						<executions>
							<execution>
								<id>key-management-jfx-native-image</id>
								<?m2e ignore?>
								<phase>package</phase>
								<goals>
									<goal>build</goal>
								</goals>
							</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-dependencies</id>
								<phase>package</phase>
								<goals>
									<goal>copy-dependencies</goal>
								</goals>
								<configuration>
									<stripVersion>true</stripVersion>
									<outputDirectory>${project.build.directory}/dependencies/common</outputDirectory>
									<stripVersion>true</stripVersion>
									<excludeClassifiers>linux,mac,win,jpms</excludeClassifiers>
								</configuration>
							</execution>
							<execution>
								<id>copy-javafx-win</id>
								<phase>package</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<stripVersion>true</stripVersion>
									<outputDirectory>${project.build.directory}/dependencies/win</outputDirectory>
									<artifactItems>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-base</artifactId>
											<version>${javafx.version}</version>
											<classifier>win</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-controls</artifactId>
											<version>${javafx.version}</version>
											<classifier>win</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-graphics</artifactId>
											<version>${javafx.version}</version>
											<classifier>win</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-fxml</artifactId>
											<version>${javafx.version}</version>
											<classifier>win</classifier>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
							<execution>
								<id>copy-javafx-mac</id>
								<phase>package</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<stripVersion>true</stripVersion>
									<outputDirectory>${project.build.directory}/dependencies/mac</outputDirectory>
									<artifactItems>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-base</artifactId>
											<version>${javafx.version}</version>
											<classifier>mac</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-controls</artifactId>
											<version>${javafx.version}</version>
											<classifier>mac</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-graphics</artifactId>
											<version>${javafx.version}</version>
											<classifier>mac</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-fxml</artifactId>
											<version>${javafx.version}</version>
											<classifier>mac</classifier>
										</artifactItem>
									</artifactItems>
								</configuration>
							</execution>
							<execution>
								<id>copy-javafx-linux</id>
								<phase>package</phase>
								<goals>
									<goal>copy</goal>
								</goals>
								<configuration>
									<stripVersion>true</stripVersion>
									<outputDirectory>${project.build.directory}/dependencies/linux</outputDirectory>
									<artifactItems>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-base</artifactId>
											<version>${javafx.version}</version>
											<classifier>linux</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-controls</artifactId>
											<version>${javafx.version}</version>
											<classifier>linux</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-graphics</artifactId>
											<version>${javafx.version}</version>
											<classifier>linux</classifier>
										</artifactItem>
										<artifactItem>
											<groupId>org.openjfx</groupId>
											<artifactId>javafx-fxml</artifactId>
											<version>${javafx.version}</version>
											<classifier>linux</classifier>
										</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>
									<release>${product.version}-${build.number}</release>
									<mediaTypes>${build.mediaTypes}</mediaTypes>
									<projectFile>${project.basedir}/kdeploy.install4j</projectFile>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
