<project name="webstart">
	<target name="webstart_demo" depends="jars">
		<antcall target="-webstart_demo">
		    <param name="keystore" value="applet/lwjglkeystore"/>
			<param name="alias" value="lwjgl"/>			
			<param name="password" value="123456"/>			
		  </antcall>
	</target>
	
	<target name="webstart_demo-release">
		<input 	message="Please type the password for the keystore" addproperty="sign.pwd"/>

		<antcall target="-webstart_demo">
		    <param name="keystore" value="signing/lwjgl.jks"/>
			<param name="alias" value="lwjgl"/>
			<param name="password" value="${sign.pwd}"/>
		  </antcall>
	</target>	
	
	<!-- Create webstart demo and extension from release files -->
	<target name="-webstart_demo" description="Using released files, creates the necessary files used for jnlp demos">
	
		<!-- delete existing temp -->
		<delete dir="${lwjgl.temp}"/>		
		
		<!-- unzip release to temp dir -->
		<unzip src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}/webstart/temp" overwrite="true"/>
		
		<!-- DEMO SECTION -->
		<move file="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/jar/lwjgl_test.jar" tofile="${lwjgl.temp}/webstart/lwjgl_test.jar"/>
		<jar destfile="${lwjgl.temp}/webstart/lwjgl_test.jar" update="true">
			<manifest>
				<attribute name="Sealed" value="true"/>
			</manifest>
		</jar>				
		<jar destfile="${lwjgl.temp}/webstart/media.jar" basedir="${lwjgl.res}">
			<manifest>
				<attribute name="Sealed" value="true"/>
			</manifest>		
		</jar>
		
		<!-- EXTENSION SECTION -->
		<move todir="${lwjgl.temp}/webstart/${lwjgl.version}/" flatten="true">
			<fileset dir="${lwjgl.temp}/webstart/temp">
				<include name="**/jinput.jar"/>
				<include name="**/lwjgl*.jar"/>
				<exclude name="**/lwjgl_util_applet.jar"/>
				<exclude name="**/lwjgl-debug.jar"/>
			</fileset>
		</move>
		
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl.jar" update="true">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>
		</jar>
		
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/jinput.jar" update="true">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>
		</jar>
		
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl_util.jar" update="true">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>
		</jar>
		
		<!-- create native jars -->
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_windows.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/windows">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>		
		</jar>
		
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_linux.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/linux">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>		
		</jar>
		
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_macosx.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/macosx">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>		
		</jar>
		
		<jar destfile="${lwjgl.temp}/webstart/${lwjgl.version}/native_solaris.jar" basedir="${lwjgl.temp}/webstart/temp/lwjgl-${lwjgl.version}/native/solaris">
			<manifest>
				<attribute name="Specification-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Specification-Version" 		value="${lwjgl.version}"/>
				<attribute name="Specification-Vendor" 			value="lwjgl.org"/>
				<attribute name="Implementation-Title" 			value="LWJGL ${lwjgl.version}"/>
				<attribute name="Implementation-Version" 		value="${lwjgl.version}"/>
				<attribute name="Implementation-Vendor" 		value="lwjgl.org"/>
				<attribute name="Implementation-Vendor-Id" 	value="org.lwjgl"/>
				<attribute name="Extension-Name" 						value="org.lwjgl"/>
				<attribute name="Sealed" value="true"/>
				<attribute name="Trusted-Library" value="true"/>
			</manifest>		
		</jar>
	
		<!-- sign 'em -->
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl.jar" 						alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/lwjgl_util.jar" 			alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/jinput.jar" 					alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_solaris.jar" 	alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_linux.jar" 		alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_macosx.jar" 		alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		<signjar jar="${lwjgl.temp}/webstart/${lwjgl.version}/native_windows.jar" 	alias="${alias}" keystore="${keystore}" storepass="${password}"/>
		
		<!-- copy over extension jnlp file -->
		<copy todir="${lwjgl.temp}/webstart/${lwjgl.version}">
    	<fileset dir="${lwjgl.web}/webstart">
    		<include name="extension.jnlp"/>
    	</fileset>
    	<filterset>
      	<filter token="LWJGL_VERSION" value="${lwjgl.version}"/>
    	</filterset>
  	</copy>
		
		<!-- nuke extracted dir -->
		<delete dir="${lwjgl.temp}/webstart/temp"/>

	</target>
</project>