-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.xml
95 lines (85 loc) · 3.99 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?xml version="1.0" encoding="UTF-8"?>
<project default="create_production_jar1" name="Create JAR files for Screen-Courter">
<!-- Assumes the class files are already built (which Eclipse does) -->
<property file="config.properties" />
<!-- TODO: Version the Mac version if need be. If you update here, also update in Applet.java -->
<property name="win-version" value="1.2"/>
<property name="linux-version" value="1.1"/>
<target name="build_jar">
<echo message="Copying apache files..." />
<!-- Copy all the needed apache class files into the jar (temporary?) -->
<copy todir="build/org/apache">
<fileset dir="lib/org/apache"/>
</copy>
<echo message="Copying applet config file..." />
<copy file="config.properties" todir="build" />
<echo message="Copying log4j config file..." />
<copy file="logs/log4j.properties" todir="build" />
<echo message="Building build/applet.jar ..." />
<property name="version.num" value="0.8"/>
<buildnumber />
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss" />
</tstamp>
<jar destfile="build/applet.jar" filesetmanifest="mergewithoutmain" basedir="build" includes="com/**,org/**,config.*,log4j.*">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value=".Applet"/>
<attribute name="Implementation-Version" value="${version.num}-b${build.number}"/>
<attribute name="Built-Date" value="${TODAY}"/>
</manifest>
</jar>
</target>
<target name="sign_jar" depends="build_jar">
<!-- Assumes key store is already setup -->
<echo message="Signing build/applet.jar ..." />
<exec dir="build" executable="jarsigner">
<arg value="-verbose" />
<arg value="-storepass" />
<arg value="${keystore.storepass}" />
<arg value="-keypass" />
<arg value="${keystore.keypass}" />
<arg value="applet.jar" />
<arg value="${keystore.alias}" />
</exec>
</target>
<target name="create_test_page" depends="sign_jar">
<copy file="build/applet.jar" todir="${test.path}"/>
<copy file="bin-mac.jar" todir="${test.path}"/>
<copy file="bin-windows-v${win-version}.jar" todir="${test.path}"/>
<copy file="bin-linux-v${linux-version}.jar" todir="${test.path}"/>
<copy file="src/template.html" tofile="${test.path}index.html" overwrite="true" />
<!-- Random number used to prevent browser caching -->
<random max="100000000" property="randomValue"></random>
<replace file="${test.path}index.html" token="@@@UNIQUE@@@" value="${randomValue}"/>
<replace file="${test.path}index.html" token="@@@POST_URL@@@" value="${test.post_url}"/>
<replace file="${test.path}index.html" token="@@@HEIGHT@@@" value="${test.applet_height}"/>
<replace file="${test.path}index.html" token="@@@WIDTH@@@" value="${test.applet_width}"/>
</target>
<target name="create_production_jar1" depends="sign_jar">
<copy file="build/applet.jar" todir="${build.production1}"/>
<copy file="bin-mac.jar" todir="${build.production1}"/>
<copy file="bin-windows-v${win-version}.jar" todir="${build.production1}"/>
<copy file="bin-linux-v${linux-version}.jar" todir="${build.production1}"/>
</target>
<target name="create_production_jar2" depends="sign_jar">
<copy file="build/applet.jar" todir="${build.production2}"/>
<copy file="bin-mac.jar" todir="${build.production2}"/>
<copy file="bin-windows-v${win-version}.jar" todir="${build.production2}"/>
<copy file="bin-linux-v${linux-version}.jar" todir="${build.production2}"/>
</target>
<!-- Taken from: http://docs.huihoo.com/apache/apachecon/eu2007/extending_ant.pdf -->
<scriptdef language="javascript" manager="javax" name="random">
<attribute name="max"/>
<attribute name="property"/>
var max=attributes.get("max");
var property=attributes.get("property");
if(max==null || property==null) {
self.fail("'property' or 'max' is not set")
} else {
var result=java.util.Random().nextInt(max);
self.log("Generated random number " + result);
project.setNewProperty(property, result);
}
</scriptdef>
</project>