<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">
	<modelVersion>4.0.0</modelVersion>
	<artifactId>adjuva-getdown</artifactId>
	<name>Adjuva Getdown</name>
	<description>Builds auto updating installers for all OS's.</description>
	<parent>
		<groupId>com.sshtools</groupId>
		<artifactId>adjuva-group</artifactId>
		<version>0.0.1-SNAPSHOT</version>
		<relativePath>../adjuva-group</relativePath>
	</parent>
	<packaging>pom</packaging>


	<properties>
		<!-- The URL where the jars are stored (used by all installers) -->
		<adjuva.home>http://callback.glade.local/adjuva/content/getdown</adjuva.home>

		<!-- TODO: Not used -->
		<buildArch>${os.arch}</buildArch>

		<!-- Temporary files -->
		<staging.dir>${project.build.directory}/staging</staging.dir>

		<!-- Where to find certificates and signing properties -->
		<signingFiles>${basedir}/../certificate</signingFiles>
	</properties>

	<build>
		<plugins>

			<!-- The properties plugin is used to be able to read code signing properties 
				from a file -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<version>1.0-alpha-2</version>
				<executions>
					<execution>
						<phase>initialize</phase>
						<goals>
							<goal>read-project-properties</goal>
						</goals>
						<configuration>
							<files>
								<file>${signingFiles}/certificate.properties</file>
							</files>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<quiet>true</quiet>
				</configuration>
			</plugin>

			<!-- First build the remote update directory and the stub. -->
			<plugin>
				<groupId>org.icestuff</groupId>
				<artifactId>getdown-maven-plugin</artifactId>
				<version>0.0.1-SNAPSHOT</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>updates</goal>
							<goal>stub</goal>
							<goal>applet</goal>
						</goals>
						<configuration>
							<appbase>${adjuva.home}</appbase>
							<libPath>lib</libPath>
							<mainClass>com.sshtools.adjuva.client.Adjuva</mainClass>
							<outputJarVersions>false</outputJarVersions>
							<verbose>true</verbose>
							<jvmargs>
								<jvmarg>-Dadjuva.forceEmbedded=false</jvmarg>
								<jvmarg>-Djna.nosys=true</jvmarg>
								<!-- Horrible Swing rendering on Windows.  -->
								<jvmarg>-Dsun.java2d.d3d=false</jvmarg>
								
							</jvmargs>

							<!-- This is a pom project, so the Main won't be in this artifact. 
								Future versions may not have this problem -->
							<ignoreMissingMain>true</ignoreMissingMain>

							<ui>
								<name>Adjuva</name>
								<icons>
									<icon>${basedir}/src/images/adjuva.png</icon>
								</icons>
								<progressImage>${basedir}/src/images/progress.png</progressImage>
								<backgroundImage>${basedir}/src/images/splash.png</backgroundImage>
								<progress>80, 244, 196, 11</progress>
								<progressText>FFFFFF</progressText>
								<statusText>FFFFFF</statusText>
								<status>20, 10, 316, 64</status>
								<textShadow>111111</textShadow>
							</ui>

							<sign>
								<keystore>${signingFiles}/${certificate.keystore}</keystore>
								<keypass>${certificate.password}</keypass>
								<storepass>${certificate.password}</storepass>
								<storetype>${certificate.storetype}</storetype>
								<alias>${certificate.alias}</alias>
								<verify>true</verify>
							</sign>

						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- Now from the stub we create some platform specific installers to 
				give the user shortcuts etc. -->

			<!-- First a Deb for Debian and based systems such as Ubuntu, Mint -->

			<plugin>
				<artifactId>jdeb</artifactId>
				<groupId>org.vafer</groupId>
				<version>1.2</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>jdeb</goal>
						</goals>
						<configuration>
						</configuration>
					</execution>
				</executions>
				<dependencies>
				</dependencies>
				<configuration>
					<skipPOMs>false</skipPOMs>
					<installDir>/usr/lib/adjuva</installDir>
					<deb>${project.basedir}/target/adjuva.deb</deb>
					<dataSet>
						<data>
							<type>directory</type>
							<src>target/getdown-stub</src>
							<includes>*.*</includes>
							<mapper>
								<type>perm</type>
								<strip>1</strip>
								<prefix>/usr/lib/adjuva</prefix>
								<user>root</user>
								<group>root</group>
								<filemode>755</filemode>
							</mapper>
						</data>
						<data>
							<type>directory</type>
							<src>${basedir}/src/scripts</src>
							<includes>*</includes>
							<mapper>
								<type>perm</type>
								<strip>1</strip>
								<prefix>/usr/bin</prefix>
								<user>root</user>
								<group>root</group>
								<filemode>755</filemode>
							</mapper>
						</data>
						<data>
							<type>directory</type>
							<src>${basedir}/src/images</src>
							<includes>adjuva.png</includes>
							<mapper>
								<type>perm</type>
								<strip>1</strip>
								<prefix>/usr/share/pixmaps</prefix>
								<user>root</user>
								<group>root</group>
								<filemode>755</filemode>
							</mapper>
						</data>
						<data>
							<type>directory</type>
							<src>${basedir}/src/applications</src>
							<includes>*</includes>
							<mapper>
								<type>perm</type>
								<strip>1</strip>
								<prefix>/usr/share/applications</prefix>
								<user>root</user>
								<group>root</group>
								<filemode>755</filemode>
							</mapper>
						</data>
					</dataSet>
				</configuration>
			</plugin>

			<!-- Now an RPM -->

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>rpm-maven-plugin</artifactId>
				<version>2.1-alpha-4</version>
				<extensions>true</extensions>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>attached-rpm</goal>
						</goals>
						<configuration>
						</configuration>
					</execution>
				</executions>
				<configuration>
					<name>adjuva</name>
					<group>Application/Internet</group>
					<packager>SSHTools</packager>
					<copyright>2014 SSHTools</copyright><!-- <projVersion></projVersion> --><!-- <release>0</release> -->
					<prefix>/usr</prefix>
					<defineStatements>
						<defineStatement>_unpackaged_files_terminate_build 0</defineStatement>
					</defineStatements>
					<requires>
						<require>java &gt;= 1.7.0</require>
					</requires>
					<mappings>
						<mapping>
							<directoryIncluded>false</directoryIncluded>
							<directory>/usr/bin</directory>
							<filemode>755</filemode>
							<username>root</username>
							<groupname>root</groupname>
							<sources>
								<source>
									<location>${basedir}/src/scripts/adjuva</location>
								</source>
							</sources>
						</mapping>
						<mapping>
							<directory>/usr/share/applications</directory>
							<directoryIncluded>false</directoryIncluded>
							<filemode>755</filemode>
							<username>root</username>
							<groupname>root</groupname>
							<sources>
								<source>
									<location>${basedir}/src/applications/adjuva.desktop</location>
								</source>
							</sources>
						</mapping>
						<mapping>
							<directory>/usr/share/pixmaps</directory>
							<directoryIncluded>false</directoryIncluded>
							<filemode>755</filemode>
							<username>root</username>
							<groupname>root</groupname>
							<sources>
								<source>
									<location>${basedir}/src/images/adjuva.png</location>
								</source>
							</sources>
						</mapping>

						<mapping>
							<directory>/usr/lib/adjuva</directory>
							<filemode>755</filemode>
							<username>root</username>
							<groupname>root</groupname>
							<sources>
								<source>
									<location>${basedir}/target/getdown-stub</location>
									<includes>
										<include>**/*</include>
									</includes>
								</source>
							</sources>
						</mapping>
					</mappings>
				</configuration>

			</plugin>

			<!-- The RPM is output in the rpm build tree. We want it at the root with 
				the other built files, and renamed slightly. As the RPM plugin has no way 
				of setting this (that I can see), we move it using Ant -->
			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.7</version>
				<executions>
					<execution>
						<phase>package</phase>
						<configuration>
							<target>
								<copy todir="target">
									<fileset dir="target/rpm/adjuva/RPMS/noarch">
										<include name="*.rpm" />
									</fileset>
									<mapper type="regexp" from="^([\w]*)-.*$$" to="\1.noarch.rpm" />
								</copy>
							</target>
						</configuration>
						<goals>
							<goal>run</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- Now for Windows -->

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>nsis-maven-plugin</artifactId>
				<version>1.0-alpha-1</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>generate-headerfile</goal>
							<goal>make</goal>
						</goals>
						<configuration>
							<outputFile>SetupAdjuva.exe</outputFile>
							<scriptFile>src/nsis/adjuva.nsi</scriptFile>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- And now OS X -->

			<!-- <plugin>
				<groupId>org.codehaus.mojo</groupId>
			    <artifactId>osxappbundle-maven-plugin</artifactId>
			    <version>1.0-alpha-3-maverickopensource</version>
				<configuration>
					<buildDirectory>target/Adjuva</buildDirectory>
					<bundleName>Adjuva</bundleName>
					<zipFile>${basedir}/target/adjuva-app.zip</zipFile>
					<excludeArtifacts>true</excludeArtifacts>
					<javaApplicationStub>${basedir}/src/stubs/osx-stub</javaApplicationStub>
					<mainClass>com.threerings.getdown.launcher.GetdownApp</mainClass>
					<additionalClasspath>
						<path>getdown.jar</path>
					</additionalClasspath>
					<additionalResources>
						<fileSet>
							<directory>${basedir}/target/getdown-stub</directory>
							<includes>
								<include>**/*</include>
							</includes>
						</fileSet>
					</additionalResources>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>bundle</goal>
						</goals>
					</execution>
				</executions>
			</plugin> -->
		</plugins>
	</build>
	<pluginRepositories>
		<pluginRepository>
			<id>getdown-maven-plugin-mvn-repo</id>
			<url>https://raw.github.com/rockfireredmoon/getdown-maven-plugin/mvn-repo/</url>
			<snapshots>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>
	<dependencies>
		<dependency>
			<groupId>com.sshtools</groupId>
			<artifactId>adjuva-client</artifactId>
			<version>${project.version}</version>
			<scope>compile</scope>
		</dependency>
	</dependencies>
</project>