<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/maven-v4_0_0.xsd">

	<properties>
		<staging.dir>${project.build.directory}/staging</staging.dir>
		<install4j.home>NOT_CONFIGURED</install4j.home>
		<install4j.winKeystorePassword>NOT_CONFIGURED</install4j.winKeystorePassword>
		<install4j.macKeystorePassword>NOT_CONFIGURED</install4j.macKeystorePassword>
		<build.phase>snapshots</build.phase>
        <build.mediaTypes>windows,unixInstaller,macos,linuxDeb</build.mediaTypes>
		<i4j.updates>https://s3-eu-west-1.amazonaws.com/sshtools-public/unitty/${project.version}/updates.xml</i4j.updates>
	</properties>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>unitty-install4j</artifactId>
	<name>UniTTY Install4J</name>
	<description>Uses Install4J to create installer. Should not be deployed to a public repository.</description>
	<parent>
		<groupId>com.sshtools.unitty</groupId>
		<artifactId>unitty</artifactId>
		<version>3.3.0-SNAPSHOT</version>
		<relativePath>..</relativePath>
	</parent>
	<url>${scmWebRoot}/${project.artifactId}/</url>

	<build>
		<finalName>${project.artifactId}</finalName>
		<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>true</failIfNoMatch>
						</configuration>
					</execution>
					<execution>
						<id>product-version-property</id>
						<goals>
							<goal>regex-property</goal>
						</goals>
						<phase>initialize</phase>
						<configuration>

							<!-- String 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>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<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>

			<!-- prepare dependencies so that izpack jar tag to pickup at compile 
				time -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>package</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<stripVersion>true</stripVersion>
							<outputDirectory>${staging.dir}/dependency</outputDirectory>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<forceCreation>true</forceCreation>
					<archive>
						<manifestEntries>
							<I4J-Updates-Url>${i4j.updates}</I4J-Updates-Url>
						</manifestEntries>
					</archive>
				</configuration>
				<executions>
					<execution>
						<goals>
							<goal>test-jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.sonatype.install4j</groupId>
				<artifactId>install4j-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>install-license</id>
						<phase>package</phase>
						<goals>
							<goal>install-license</goal>
						</goals>
					</execution>
					<execution>
						<id>compile-installers</id>
						<phase>package</phase>
						<goals>
							<goal>compile</goal>
						</goals>
						<configuration>
							<projectFile>${basedir}/src/install4j/unitty.install4j</projectFile>
							<release>${product.version}-${build.number}</release>
							<variables>
								<i4j.updates>${i4j.updates}</i4j.updates>
							</variables>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- Generate target/extensions etc -->
			<plugin>
				<groupId>com.logonbox</groupId>
				<artifactId>logonbox-plugin-generator</artifactId>
				<executions>
					<execution>
						<id>deploy-packages</id>
						<phase>deploy</phase>
						<goals>
							<goal>upload-packages</goal>
						</goals>
						<configuration>
							<bucketName>unitty</bucketName>
							<keyPrefix>${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>unitty</sourceBucketName>
							<sourceKey>${product.version}-${build.number}/updates.xml</sourceKey>
							<destinationKey>${build.phase}/updates.xml</destinationKey>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>properties-maven-plugin</artifactId>
					<version>1.0.0</version>
				</plugin>
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>build-helper-maven-plugin</artifactId>
					<version>3.3.0</version>
				</plugin>
				<plugin>
					<groupId>com.logonbox</groupId>
					<artifactId>logonbox-plugin-generator</artifactId>
					<version>0.9.0-SNAPSHOT</version>
				</plugin>

				<plugin>
					<groupId>org.sonatype.install4j</groupId>
					<artifactId>install4j-maven-plugin</artifactId>
					<version>1.1.2</version>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
	<distributionManagement>
		<repository>
			<id>libs-releases</id>
			<url>http://artifactory.javassh.com/libs-releases-local</url>
		</repository>
		<snapshotRepository>
			<id>libs-snapshots</id>
			<url>http://artifactory.javassh.com/libs-snapshots-local</url>
		</snapshotRepository>
	</distributionManagement>
	<repositories>
		<repository>
			<id>libs-releases</id>
			<url>http://artifactory.javassh.com/libs-releases-local</url>
			<releases />
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>libs-snapshots</id>
			<url>http://artifactory.javassh.com/libs-snapshots-local</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots />
		</repository>
		<repository>
			<id>ej</id>
			<url>https://maven.ej-technologies.com/repository/</url>
			<releases />
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
	<dependencies>
		<dependency>
			<groupId>com.sshtools.unitty</groupId>
			<artifactId>unitty-macosx-app</artifactId>
			<version>${project.version}</version>
		</dependency>
		<dependency>
			<groupId>com.sshtools.unitty</groupId>
			<artifactId>unitty-app</artifactId>
			<version>${project.version}</version>
			<scope>compile</scope>
			<exclusions>
				<exclusion>
					<artifactId>sshapi-ganymed</artifactId>
					<groupId>com.sshtools</groupId>
				</exclusion>
				<exclusion>
					<artifactId>sshapi-j2ssh</artifactId>
					<groupId>com.sshtools</groupId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>com.sshtools</groupId>
			<artifactId>sshapi-maverick-16</artifactId>
			<version>${sshapiVersion}</version>
			<exclusions>
				<exclusion>
					<groupId>net.java.dev.jna</groupId>
					<artifactId>jna</artifactId>
				</exclusion>
				<exclusion>
					<groupId>net.java.dev.jna</groupId>
					<artifactId>jna-platform</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>com.sshtools</groupId>
			<artifactId>sshapi-maverick-16-license</artifactId>
			<version>${sshapiVersion}</version>
		</dependency>
		<dependency>
			<groupId>com.sshtools</groupId>
			<artifactId>sshapi-maverick-synergy-license</artifactId>
			<version>${sshapiVersion}</version>
			<type>pom</type>
			<scope>compile</scope>
		</dependency>

		<dependency>
			<groupId>com.install4j</groupId>
			<artifactId>install4j-runtime</artifactId>
			<version>8.0.2</version>
			<scope>provided</scope>
		</dependency>

	</dependencies>

	<pluginRepositories>
		<pluginRepository>
			<id>libs-releases</id>
			<url>https://artifactory.jadaptive.com/libs-releases-local</url>
			<releases />
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</pluginRepository>
		<pluginRepository>
			<id>libs-snapshots</id>
			<url>https://artifactory.jadaptive.com/libs-snapshots-local</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots />
		</pluginRepository>
	</pluginRepositories>
</project>