-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.xml
339 lines (273 loc) · 13.2 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse.ant.import?>
<project basedir="." default="release" name="RevAger">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.8" />
<property name="source" value="1.8" />
<property name="dir.src" location="src" />
<property name="dir.lib" location="lib" />
<property name="dir.lib.dev" location="lib-dev" />
<property name="dir.build" location="build" />
<property name="dir.dist" location="dist" />
<property name="dir.build.test" location="${dir.build}/org/revager/test" />
<property name="dir.build.resources.build" location="${dir.build}/org/revager/resources/build" />
<property file="${dir.src}/org/revager/resources/appResources.properties" />
<!-- Directory where build resources (images etc.) can be found -->
<property name="dir.src.resources.build" value="${dir.src}/org/revager/resources/build" />
<!-- Directory where DMG images can be temporarily mounted -->
<property name="dir.dmg.mount" value="/tmp" />
<property name="lib.derby" location="${dir.lib}/derby.jar" />
<property name="lib.iText" location="${dir.lib}/iText-2.1.7.jar" />
<property name="lib.commons-lang3" location="${dir.lib}/commons-lang3-3.6.jar" />
<property name="lib.jinput" location="${dir.lib}/jinput-2.0.7.jar" />
<property name="lib.jinput.naive" location="${dir.lib}/jinput-native-files/" />
<property name="lib.jutils" location="${dir.lib}/jutils-1.0.0.jar" />
<property name="lib.junit" location="${dir.lib.dev}/junit-4.7.jar" />
<property name="lib.swingx" location="${dir.lib.dev}/swingx-1.6.1.jar" />
<property name="lib.gettexttasks" location="${dir.lib.dev}/gettext-ant-tasks-0.9.7.jar" />
<property name="lib.launch4j.linux" location="${dir.lib.dev}/launch4j/launch4j-3.0.1-linux.tgz" />
<property name="lib.launch4j.windows" location="${dir.lib.dev}/launch4j/launch4j-3.0.1-win32.zip" />
<property name="lib.launch4j.macosx" location="${dir.lib.dev}/launch4j/launch4j-3.0.1-macosx.tgz" />
<property name="lib.launch4j.solaris" location="${dir.lib.dev}/launch4j/launch4j-3.0.1-solaris-sparc.tgz" />
<path id="RevAger.classpath">
<pathelement location="${lib.build}" />
<pathelement location="${lib.derby}" />
<pathelement location="${lib.iText}" />
<pathelement location="${lib.commons-lang3}" />
<pathelement location="${lib.jinput}" />
<pathelement location="${lib.jinput.naive}" />
<pathelement location="${lib.jutils}" />
<pathelement location="${lib.junit}" />
<pathelement location="${lib.swingx}" />
</path>
<!-- -->
<!-- Some conditions to detect the current OS -->
<!-- -->
<condition property="isSolaris">
<or>
<os name="SunOS" />
<os name="Solaris" />
</or>
</condition>
<condition property="isWindows">
<or>
<os name="Windows 2000" />
<os name="Windows XP" />
<os name="Windows 2003" />
<os name="Windows Vista" />
<os name="Windows 7" />
</or>
</condition>
<condition property="isLinux">
<os name="Linux" />
</condition>
<condition property="isMacOSX">
<os name="Mac OS X" />
</condition>
<condition property="isLaunch4jAvailable">
<available file="${dir.lib.dev}/launch4j/launch4j" />
</condition>
<!-- -->
<!-- Gettext-related targets -->
<!-- (http://code.google.com/p/gettext-commons/wiki/GettextAntTasksManual) -->
<!-- -->
<target name="lang-init" description="Load the gettext tasks">
<taskdef name="gettext-extract" classname="org.xnap.commons.ant.gettext.GettextExtractKeysTask" classpath="${lib.gettexttasks}" />
<taskdef name="gettext-merge" classname="org.xnap.commons.ant.gettext.GettextMergeKeysTask" classpath="${lib.gettexttasks}" />
<taskdef name="gettext-generate-default" classname="org.xnap.commons.ant.gettext.GenerateDefaultBundleTask" classpath="${lib.gettexttasks}" />
<taskdef name="gettext-dist" classname="org.xnap.commons.ant.gettext.GettextDistTask" classpath="${lib.gettexttasks}" />
</target>
<target name="lang-update" description="Extract and merge the language files" depends="lang-init">
<!-- Extract strings from Java sources and store them inside a .pot file -->
<gettext-extract keysFile="lang.pot" poDirectory="lang" keywords="-k -ktranslate --from-code=UTF-8 --no-wrap">
<fileset dir="${dir.src}" includes="**/*.java" />
</gettext-extract>
<!-- Generate properties files -->
<gettext-dist targetBundle="${path.lang}" outputFormat="properties" poDirectory="lang" outputDirectory="${dir.src}" percentage="75" />
<!-- Some clean-up -->
<delete file="./messages.mo" />
</target>
<!-- -->
<!-- Build-related targets -->
<!-- -->
<target name="init">
<mkdir dir="${dir.build}" />
<copy includeemptydirs="false" todir="${dir.build}">
<fileset dir="${dir.src}">
<exclude name="**/*.launch" />
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="${dir.build}" />
<delete dir="${dir.dist}" />
<delete dir="${dir.lib.dev}/launch4j/launch4j" />
<delete file="buildNo.properties" />
</target>
<target depends="build-subprojects,build-project" name="build" />
<target name="build-subprojects" />
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}" />
<javac debug="true" debuglevel="${debuglevel}" destdir="${dir.build}" source="${source}" target="${target}">
<src path="${dir.src}" />
<classpath refid="RevAger.classpath" />
</javac>
</target>
<target name="unzip-libs">
<echo>Unzip 3rd-party libs from ${lib} directory into ${build}</echo>
<unzip dest="${dir.build}">
<fileset dir="${dir.lib}">
<include name="**/*.jar" />
</fileset>
</unzip>
</target>
<target name="dist" depends="unzip-libs,build" description="Generate the distribution">
<delete dir="${dir.build.test}" />
<delete dir="${dir.build.resources.build}" />
<mkdir dir="${dir.dist}" />
<!-- Build the runnable JAR file -->
<jar jarfile="${dir.dist}/${appFileName}_${appVersion}.jar" basedir="${dir.build}" level="9">
<!-- <fileset dir="${lib.jinput.naive}" /> -->
<manifest>
<attribute name="Main-Class" value="org.revager.Main" />
<attribute name="Class-Path" value="." />
<attribute name="Implementation-Title" value="${appName}" />
<attribute name="Implementation-Version" value="${appVersion} (Build ${appBuild})" />
<attribute name="Implementation-Vendor" value="Team N.E.O.S." />
<attribute name="SplashScreen-Image" value="org/revager/resources/splashScreen.gif" />
</manifest>
</jar>
<!-- Build the ZIP file with the source code inside -->
<zip destfile="${dir.dist}/${appFileName}-src_${appVersion}.zip" basedir="src" level="9" />
</target>
<!-- Platform-dependent targets to perpare Launch4j -->
<target name="prepare-launch4j-unix">
<untar src="${dir.lib.dev}/launch4j/l4j.tar" dest="${dir.lib.dev}/launch4j" />
<delete file="${dir.lib.dev}/launch4j/l4j.tar" />
<chmod perm="a+rwx">
<fileset dir="${dir.lib.dev}/launch4j/launch4j">
<include name="**/*" />
</fileset>
</chmod>
</target>
<target name="prepare-launch4j-linux" if="isLinux">
<gunzip src="${lib.launch4j.linux}" dest="${dir.lib.dev}/launch4j/l4j.tar" />
<antcall target="prepare-launch4j-unix" />
</target>
<target name="prepare-launch4j-solaris" if="isSolaris">
<gunzip src="${lib.launch4j.solaris}" dest="${dir.lib.dev}/launch4j/l4j.tar" />
<antcall target="prepare-launch4j-unix" />
</target>
<target name="prepare-launch4j-macosx" if="isMacOSX">
<gunzip src="${lib.launch4j.macosx}" dest="${dir.lib.dev}/launch4j/l4j.tar" />
<antcall target="prepare-launch4j-unix" />
</target>
<target name="prepare-launch4j-windows" if="isWindows">
<unzip src="${lib.launch4j.windows}" dest="${dir.lib.dev}/launch4j" />
</target>
<target name="prepare-launch4j">
<!-- Remove old Launch4j library if there is one -->
<delete dir="${dir.lib.dev}/launch4j/launch4j" />
<antcall target="prepare-launch4j-linux" />
<antcall target="prepare-launch4j-windows" />
<antcall target="prepare-launch4j-macosx" />
<antcall target="prepare-launch4j-solaris" />
</target>
<target name="build-launch4j" if="isLaunch4jAvailable" description="Generate runnable .exe file for MS Windows">
<property name="dir.launch4j" location="${dir.lib.dev}/launch4j/launch4j" />
<property name="conf.launch4j" location="${dir.src.resources.build}/windows/launch4j-config.xml" />
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="${dir.launch4j}/launch4j.jar
:${dir.launch4j}/lib/xstream.jar" />
<launch4j configFile="${conf.launch4j}" jar="${dir.dist}/${appFileName}_${appVersion}.jar" outfile="${dir.dist}/${appFileName}_${appVersion}.exe" />
</target>
<target name="build-jarbundler" if="isMacOSX" description="Generate runnable app file for Mac OS X">
<taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler" classpath="${dir.lib.dev}/jarbundler-2.1.0.jar" />
<jarbundler dir="${dir.dist}" name="${appName}" mainclass="org.revager.Main" jar="${dir.dist}/${appFileName}_${appVersion}.jar" build="${appBuild}" version="${appVersion}" bundleid="org.revager" icon="${dir.src}/org/revager/resources/build/macosx/appIcon.icns" jvmversion="1.8+" shortname="${appName}" />
</target>
<!-- MacOS X DMG build script adapted from Romain Kuntz (http://www.rkuntz.org/pmwiki.php?n=Code.AntDiskImage) -->
<target name="build-dmg" if="isMacOSX" description="Build DMG image for MacOS X (requires hdiutil, thus only works on MacOS X)">
<!-- Delete previously created DMG -->
<delete file="${dir.dist}/${appFileName}_${appVersion}.dmg" verbose="true" failonerror="false" />
<!-- Create a temporary disk image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="create" />
<arg value="-srcfolder" />
<arg value="${dir.dist}/${appName}.app" />
<arg value="-volname" />
<arg value="${appName}" />
<arg value="-ov" />
<arg value="${dir.dist}/${appFileName}-tmp.dmg" />
<arg value="-format" />
<arg value="UDRW" />
<arg value="-nospotlight" />
</exec>
<!-- Attach the temporary image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="attach" />
<arg value="${dir.dist}/${appFileName}-tmp.dmg" />
<arg value="-mountroot" />
<arg value="${dir.dmg.mount}/" />
</exec>
<!-- Copy the background file -->
<mkdir dir="${dir.dmg.mount}/${appName}/.background" />
<copy file="${dir.src.resources.build}/macosx/dmg_background.png" tofile="${dir.dmg.mount}/${appName}/.background/background.png" overwrite="true" />
<!-- Layout Finder window (Set size, set background, arrange icons etc.) -->
<exec executable="/usr/bin/osascript" os="Mac OS X">
<arg value="${dir.src.resources.build}/macosx/dmg_setlayout.applescript" />
</exec>
<!-- Detach the temporary image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="detach" />
<arg value="${dir.dmg.mount}/${appName}" />
</exec>
<!-- Compress it to a new image -->
<exec executable="/usr/bin/hdiutil" os="Mac OS X" failonerror="true">
<arg value="convert" />
<arg value="${dir.dist}/${appFileName}-tmp.dmg" />
<arg value="-format" />
<arg value="UDZO" />
<arg value="-o" />
<arg value="${dir.dist}/${appFileName}_${appVersion}.dmg" />
</exec>
<!-- Delete the temporary image -->
<delete file="${dir.dist}/${appFileName}-tmp.dmg" verbose="true" failonerror="false" />
</target>
<target name="release" description="Generate a full release">
<!-- Get current date -->
<tstamp>
<format property="currentDate" pattern="yyyy-MM-dd" />
</tstamp>
<!-- Update build date -->
<replaceregexp file="${dir.src}/org/revager/resources/appResources.properties" match="appRelease=(.*)" replace="appRelease=${currentDate}" byline="true" />
<!-- Update language stuff -->
<antcall target="lang-update" />
<!-- Run dist target -->
<antcall target="dist" />
<!-- Mac OS X binary -->
<antcall target="build-jarbundler" />
<antcall target="build-dmg" />
<!-- Windows binary -->
<antcall target="prepare-launch4j" />
<antcall target="build-launch4j" />
</target>
<target name="bzr-release" description="Update build no. before generating the release">
<!-- Get the revision no. of the current bazaar repository -->
<exec executable="bzr" outputproperty="revisionNumber">
<arg value="revno" />
<arg value="${vcsRepositoryURL}" />
</exec>
<!-- Create build no. by incrementing revision no. +1 -->
<propertyfile file="buildNo.properties">
<entry key="buildNumber" type="int" operation="=" value="${revisionNumber}" />
<entry key="buildNumber" type="int" default="${revisionNumber}" operation="+" value="1" />
</propertyfile>
<property file="buildNo.properties" />
<delete file="buildNo.properties" />
<!-- Update build no. -->
<replaceregexp file="${dir.src}/org/revager/resources/appResources.properties" match="appBuild=(.*)" replace="appBuild=${buildNumber}" byline="true" />
<!-- Generate a full release -->
<antcall target="release" />
</target>
</project>