<!-- Copyright (c) 2013 LogonBox Limited. All rights reserved. This program 
	and the accompanying materials are made available under the terms of the 
	GNU Public License v3.0 which accompanies this distribution, and is available 
	at http://www.gnu.org/licenses/gpl.html -->
<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>
	<parent>
		<artifactId>logonbox-desktop-vpn-clients</artifactId>
		<groupId>com.logonbox</groupId>
		<version>2.4.0-SNAPSHOT</version>
		<relativePath>..</relativePath>
	</parent>
	<artifactId>client-logonbox-vpn-installer</artifactId>
	<packaging>pom</packaging>
	<name>LogonBox - VPN Client Installer</name>
	<properties>
		<build.phase>nightly</build.phase>
		<build.mediaTypes>windows,unixInstaller,macos,macosFolder,windowsArchive,unixArchive,linuxRPM,linuxDeb,macosArchive,macosFolderArchive</build.mediaTypes>
	</properties>
	<build>
		<plugins>

			<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}/hypersocket.build.properties</file>
								<file>${user.home}/.hypersocket.build.properties</file>
							</files>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<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>true</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>true</failIfNoMatch>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.coderplus.maven.plugins</groupId>
				<artifactId>copy-rename-maven-plugin</artifactId>
				<version>1.0.1</version>
				<executions>
					<execution>
						<id>copy-file</id>
						<phase>generate-sources</phase>
						<goals>
							<goal>copy</goal>
						</goals>
						<configuration>
							<sourceFile>../CHANGES.md</sourceFile>
							<destinationFile>target/CHANGES.md</destinationFile>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>com.google.code.maven-replacer-plugin</groupId>
				<artifactId>replacer</artifactId>
				<version>1.5.2</version>
				<executions>
					<execution>
						<phase>generate-sources</phase>
						<goals>
							<goal>replace</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<file>${basedir}/target/CHANGES.md</file>
					<replacements>
						<replacement>
							<token>## SNAPSHOT</token>
							<value>## ${product.version}-${build.number}</value>
						</replacement>
					</replacements>
				</configuration>
			</plugin>
		</plugins>
	</build>

	<dependencies>
		<dependency>
			<groupId>com.logonbox</groupId>
			<artifactId>client-logonbox-vpn-service</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.logonbox</groupId>
			<artifactId>client-logonbox-vpn-gui-jfx</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.logonbox</groupId>
			<artifactId>client-logonbox-vpn-cli</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.logonbox</groupId>
			<artifactId>client-logonbox-vpn-dbconvert</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.sshtools</groupId>
			<artifactId>forker-wrapper</artifactId>
			<version>1.8-SNAPSHOT</version>
		</dependency>
	</dependencies>

	<profiles>

		<profile>
			<id>build-install4j-logonbox-vpn-client</id>
			<build>
				<plugins>
					<!-- We don't actually need to deploy the .sh, .deb. .exe etc to Artifactory,
				    they are copied to S3 -->
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-deploy-plugin</artifactId>
						<configuration>
							<skip>true</skip>
						</configuration>
					</plugin>

					<!-- Clean target/extensions etc -->
					<plugin>
						<artifactId>maven-clean-plugin</artifactId>
						<version>3.1.0</version>
						<executions>
							<execution>
								<id>clean-extensions</id>
								<phase>clean</phase>
								<goals>
									<goal>clean</goal>
								</goals>
								<configuration>
									<filesets>
										<fileset>
											<directory>target/cli</directory>
										</fileset>
										<fileset>
											<directory>target/service</directory>
										</fileset>
										<fileset>
											<directory>target/gui</directory>
										</fileset>
										<fileset>
											<directory>target/dbconvert</directory>
										</fileset>
									</filesets>
								</configuration>
							</execution>
						</executions>
					</plugin>

					<!-- Generate target/extensions etc -->
					<plugin>
						<groupId>com.logonbox</groupId>
						<artifactId>logonbox-plugin-generator</artifactId>
						<executions>
							<execution>
								<id>copy-cli</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/cli</output>
									<artifacts>
										<artifact>com.logonbox:client-logonbox-vpn-cli:${project.version}</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-converter</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/converter</output>
									<artifacts>
										<artifact>com.logonbox:client-logonbox-vpn-dbconvert:${project.version}</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-gui</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<output>${project.build.directory}/gui</output>
									<includeVersion>false</includeVersion>
									<artifacts>
										<artifact>com.logonbox:client-logonbox-vpn-gui-jfx:${project.version}</artifact>
									</artifacts>

									<!-- Copy these to separate directories -->
									<excludeClassifiers>
										<excludeClassifier>linux</excludeClassifier>
										<excludeClassifier>win</excludeClassifier>
										<excludeClassifier>mac</excludeClassifier>
									</excludeClassifiers>


								</configuration>
							</execution>
							<execution>
								<id>copy-gui-jfx-win</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/gui/win</output>
									<transitive>false</transitive>
									<artifacts>
										<artifact>org.openjfx:javafx-controls:${javafx.version}:jar:win</artifact>
										<artifact>org.openjfx:javafx-base:${javafx.version}:jar:win</artifact>
										<artifact>org.openjfx:javafx-fxml:${javafx.version}:jar:win</artifact>
										<artifact>org.openjfx:javafx-graphics:${javafx.version}:jar:win</artifact>
										<artifact>org.openjfx:javafx-media:${javafx.version}:jar:win</artifact>
										<artifact>org.openjfx:javafx-web:${javafx.version}:jar:win</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-gui-jfx-linux</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/gui/linux</output>
									<transitive>false</transitive>
									<artifacts>
										<artifact>org.openjfx:javafx-controls:${javafx.version}:jar:linux</artifact>
										<artifact>org.openjfx:javafx-base:${javafx.version}:jar:linux</artifact>
										<artifact>org.openjfx:javafx-fxml:${javafx.version}:jar:linux</artifact>
										<artifact>org.openjfx:javafx-graphics:${javafx.version}:jar:linux</artifact>
										<artifact>org.openjfx:javafx-media:${javafx.version}:jar:linux</artifact>
										<artifact>org.openjfx:javafx-web:${javafx.version}:jar:linux</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-gui-jfx-linux-arm32-monocle</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/gui/linux-arm32-monocle</output>
									<transitive>false</transitive>
									<artifacts>
										<artifact>org.openjfx:javafx-controls:${javafx.version}:jar:linux-arm32-monocle</artifact>
										<artifact>org.openjfx:javafx-base:${javafx.version}:jar:linux-arm32-monocle</artifact>
										<artifact>org.openjfx:javafx-fxml:${javafx.version}:jar:linux-arm32-monocle</artifact>
										<artifact>org.openjfx:javafx-graphics:${javafx.version}:jar:linux-arm32-monocle</artifact>
										<artifact>org.openjfx:javafx-media:${javafx.version}:jar:linux-arm32-monocle</artifact>
										<artifact>org.openjfx:javafx-web:${javafx.version}:jar:linux-arm32-monocle</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-gui-jfx-linux-aarch64</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/gui/linux-aarch64</output>
									<transitive>false</transitive>
									<artifacts>
										<artifact>org.openjfx:javafx-controls:${javafx.version}:jar:linux-aarch64</artifact>
										<artifact>org.openjfx:javafx-base:${javafx.version}:jar:linux-aarch64</artifact>
										<artifact>org.openjfx:javafx-fxml:${javafx.version}:jar:linux-aarch64</artifact>
										<artifact>org.openjfx:javafx-graphics:${javafx.version}:jar:linux-aarch64</artifact>
										<artifact>org.openjfx:javafx-media:${javafx.version}:jar:linux-aarch64</artifact>
										<artifact>org.openjfx:javafx-web:${javafx.version}:jar:linux-aarch64</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-gui-jfx-mac</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/gui/mac</output>
									<transitive>false</transitive>
									<artifacts>
										<artifact>org.openjfx:javafx-controls:${javafx.version}:jar:mac</artifact>
										<artifact>org.openjfx:javafx-base:${javafx.version}:jar:mac</artifact>
										<artifact>org.openjfx:javafx-fxml:${javafx.version}:jar:mac</artifact>
										<artifact>org.openjfx:javafx-graphics:${javafx.version}:jar:mac</artifact>
										<artifact>org.openjfx:javafx-media:${javafx.version}:jar:mac</artifact>
										<artifact>org.openjfx:javafx-web:${javafx.version}:jar:mac</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-gui-jfx-mac-aarch64</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/gui/mac-aarch64</output>
									<transitive>false</transitive>
									<artifacts>
										<artifact>org.openjfx:javafx-controls:${javafx.version}:jar:mac-aarch64</artifact>
										<artifact>org.openjfx:javafx-base:${javafx.version}:jar:mac-aarch64</artifact>
										<artifact>org.openjfx:javafx-fxml:${javafx.version}:jar:mac-aarch64</artifact>
										<artifact>org.openjfx:javafx-graphics:${javafx.version}:jar:mac-aarch64</artifact>
										<artifact>org.openjfx:javafx-media:${javafx.version}:jar:mac-aarch64</artifact>
										<artifact>org.openjfx:javafx-web:${javafx.version}:jar:mac-aarch64</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>copy-service</id>
								<phase>package</phase>
								<goals>
									<goal>get-artifacts</goal>
								</goals>
								<configuration>
									<includeVersion>false</includeVersion>
									<output>${project.build.directory}/service</output>
									<artifacts>
										<artifact>com.logonbox:client-logonbox-vpn-service:${project.version}</artifact>
									</artifacts>
								</configuration>
							</execution>
							<execution>
								<id>deploy-deb-packages</id>
								<phase>deploy</phase>
								<goals>
									<goal>upload-packages</goal>
								</goals>
								<configuration>
									<bucketName>logonbox-packages</bucketName>
									<keyPrefix>logonbox-vpn-client/${product.version}-${build.number}</keyPrefix>
									<files>
										<directory>${project.basedir}/target/media</directory>
										<includes>
											<include>*</include>
										</includes>
									</files>
								</configuration>
							</execution>
							<execution>
								<id>deploy-updates-xml</id>
								<phase>deploy</phase>
								<goals>
									<goal>copy-s3-objects</goal>
								</goals>
								<configuration>
									<sourceBucketName>logonbox-packages</sourceBucketName>
									<sourceKey>logonbox-vpn-client/${product.version}-${build.number}/updates.xml</sourceKey>
									<destinationKey>logonbox-vpn-client/${build.phase}/updates.xml</destinationKey>
								</configuration>
							</execution>
						</executions>
					</plugin>

					<!-- Create Installers -->
					<plugin>
						<groupId>org.sonatype.install4j</groupId>
						<artifactId>install4j-maven-plugin</artifactId>
						<version>1.1.2</version>
						<executions>
							<execution>
								<id>compile-client-installer</id>
								<phase>package</phase>
								<goals>
									<goal>compile</goal>
								</goals>
								<configuration>
									<projectFile>${project.basedir}/client.install4j</projectFile>
									<attach>true</attach>
									<release>${product.version}-${build.number}</release>
									<mediaTypes>${build.mediaTypes}</mediaTypes>
									<variables>
										<build.phase>${build.phase}</build.phase>
									</variables>
									<jvmArguments>
										<jvmArgument>-Xmx2048m</jvmArgument>
									</jvmArguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<repositories>
		<!-- For Forker -->
		<repository>
			<id>opensource-releases</id>
			<url>https://artifactory.jadaptive.com/opensource-releases</url>
			<releases />
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>opensource-snapshots</id>
			<url>https://artifactory.jadaptive.com/opensource-snapshots</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots />
		</repository>
		<repository>
			<id>ext-snapshots-local</id>
			<name>ext-snapshots-local</name>
			<url>https://artifactory.jadaptive.com/ext-snapshots-local</url>
			<snapshots />
			<releases>
				<enabled>false</enabled>
			</releases>
		</repository>
	</repositories>
</project>