<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>
		<groupId>org.cryptomator</groupId>
		<artifactId>main</artifactId>
		<version>0.8.1</version>
	</parent>
	<artifactId>installer-win-portable</artifactId>
	<packaging>pom</packaging>
	<name>Cryptomator (Portable) Windows installer</name>

	<properties>
		<javafx.application.name>Cryptomator</javafx.application.name>
		<exec.mainClass>org.cryptomator.ui.Cryptomator</exec.mainClass>
		<javafx.tools.ant.jar>${java.home}/../lib/ant-javafx.jar</javafx.tools.ant.jar>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.cryptomator</groupId>
			<artifactId>ui</artifactId>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-dependency-plugin</artifactId>
				<executions>
					<execution>
						<id>copy-libs</id>
						<phase>prepare-package</phase>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-antrun-plugin</artifactId>
				<version>1.7</version>
				<executions>
					<execution>
						<id>create-deployment-bundle</id>
						<phase>install</phase>
						<goals>
							<goal>run</goal>
						</goals>
						<configuration>
							<target xmlns:fx="javafx:com.sun.javafx.tools.ant">
								<taskdef uri="javafx:com.sun.javafx.tools.ant" resource="com/sun/javafx/tools/ant/antlib.xml" classpath="${project.basedir}:${javafx.tools.ant.jar}" />
								
								<!-- Define application to build -->
								<fx:application id="fxApp" name="${javafx.application.name}" version="${project.version}" mainClass="${exec.mainClass}" />
								
								<!-- Create main application jar -->
								<fx:jar destfile="${project.build.directory}/Cryptomator-${project.parent.version}.jar">
									<fx:application refid="fxApp" />
									<fx:fileset dir="${project.build.directory}" includes="libs/ui-${project.version}.jar"/>
									<fx:resources>
										<fx:fileset dir="${project.build.directory}" type="jar" includes="libs/*.jar" excludes="libs/ui-${project.version}.jar" />
									</fx:resources>
									<fx:manifest>
										<fx:attribute name="Implementation-Vendor" value="cryptomator.org" />
										<fx:attribute name="Implementation-Version" value="${project.version}" />
									</fx:manifest>
								</fx:jar>

								<!-- Create native package -->
								<fx:deploy nativeBundles="exe" outdir="${project.build.directory}" outfile="Cryptomator-${project.parent.version}" verbose="true">
									<fx:application refid="fxApp"/>
									<fx:info title="${javafx.application.name}" vendor="cryptomator.org" copyright="cryptomator.org" license="MIT" category="Utility" />
									<fx:platform javafx="2.2+" j2se="8.0">
										<fx:property name="settingsPath" value="./settings.json" />
										<fx:property name="logPath" value="cryptomator.log" />
									</fx:platform>
									<fx:resources>
										<fx:fileset dir="${project.build.directory}" type="jar" includes="Cryptomator-${project.parent.version}.jar"/>
                                    	<fx:fileset dir="${project.build.directory}" type="jar" includes="libs/*.jar" excludes="libs/ui-${project.version}.jar"/>
									</fx:resources>
									<fx:permissions elevated="false" />
									<fx:preferences install="false" menu="false" shortcut="false" />
								</fx:deploy>
							</target>
						</configuration>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>
</project>