-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
290 lines (224 loc) · 9.35 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
<project name="jav" default="jar" basedir=".">
<description>
JAV - Java wrapper for FFMPEG.
</description>
<!-- Version control system. Options: "git", "svn", or "unversioned". -->
<target name="vcs" depends="git" />
<!-- Source code packaging. Options:
"no-source" Do not package source
"source-in-jar" Include source in same jar as class files.
"source-own-jar" Package source into separate jar file. -->
<target name="include-source" depends="source-own-jar" />
<property name="domain.name" value="bits" />
<property name="jvm.source" value="1.6" />
<property name="jvm.target" value="1.6" />
<property name="dst.dir" value="target" />
<property name="dst.name" value="${domain.name}_${ant.project.name}" />
<property name="src.dir" value="src/main/java" />
<property name="resources.dir" value="src/main/resources" />
<property name="build.dir" value="scratch/main/java" />
<property name="test.src.dir" value="src/test/java" />
<property name="test.build.dir" value="scratch/test/java" />
<property name="lib.dir" value="lib" />
<property name="buildtools.dir" value="buildtools" />
<property name="meta.build.dir" value="scratch/ant" />
<property name="app.name" value="" />
<property name="app.main" value="" />
<property name="app.icon" value="" />
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!--============================
Project Specific Targets
============================-->
<!--============================
Building
============================-->
<target name="init">
<tstamp>
<format property="timestamp" pattern="yyyy-MM-dd HH:mm" />
<format property="timestamp.nospace" pattern="yyyy-MM-dd_HHmm" />
</tstamp>
</target>
<target name="clean" description="Delete scratch directories" >
<delete dir="${build.dir}" />
<delete dir="${test.build.dir}" />
<delete dir="${meta.build.dir}" />
</target>
<target name="compile" depends="init" description="Compile source" >
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="yes" fork="yes" source="${jvm.source}" target="${jvm.target}" includeantruntime="false">
<classpath>
<path refid="classpath"/>
</classpath>
</javac>
</target>
<target name="compile-test" depends="compile" description="Compile test source" >
<mkdir dir="${test.build.dir}" />
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" debug="yes" nowarn="true" source="${jvm.source}" target="${jvm.target}" includeantruntime="false">
<classpath>
<path refid="classpath" />
<pathelement location="${build.dir}" />
</classpath>
</javac>
</target>
<target name="jar" depends="include-source" description="Generate target jars" >
<!-- Cleanup. See jar-begin. -->
<delete>
<fileset refid="jar.meta.gen" />
</delete>
<delete file="${manifest.path}" />
</target>
<target name="jar-begin" depends="compile,vcs" >
<property name="jar.file" value="${dst.dir}/${dst.name}.jar" />
<mkdir dir="${dst.dir}" />
<mkdir dir="${meta.build.dir}" />
<property name="manifest.path" value="${meta.build.dir}/MANIFEST.MF" />
<property name="version.file" value="VERSION_${version}" />
<property name="timestamp.file" value="TIMESTAMP_${timestamp.nospace}" />
<manifest file="${manifest.path}" >
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Version" value="${version}" />
<attribute name="Build-Timestamp" value="${timestamp}" />
</manifest>
<!-- Add empty file with the version number in it. -->
<touch file="${meta.build.dir}/${version.file}" />
<touch file="${meta.build.dir}/${timestamp.file}" />
<fileset id="jar.meta.gen" dir="${meta.build.dir}" >
<include name="${version.file}" />
<include name="${timestamp.file}" />
</fileset>
<fileset id="jar.meta.root" dir=".">
<include name="README.TXT" />
<include name="LICENSE.TXT" />
</fileset>
<jar jarfile="${jar.file}" basedir="${build.dir}" manifest="${manifest.path}" >
<metainf refid="jar.meta.root" />
<metainf refid="jar.meta.gen" />
</jar>
</target>
<target name="no-source" depends="jar-begin" >
<echo message="Source code will not be packaged." />
</target>
<target name="source-in-jar" depends="jar-begin" >
<echo message="Source code will be merged with target jar." />
<jar jarfile="${jar.file}" update="true" basedir="${src.dir}" />
</target>
<target name="source-own-jar" depends="jar-begin" >
<jar jarfile="${dst.dir}/${dst.name}-source.jar" manifest="${manifest.path}" >
<fileset dir="${src.dir}" />
<metainf refid="jar.meta.gen" />
<metainf refid="jar.meta.root" />
</jar>
</target>
<!--============================
Packaging
======================= -->
<target name="app" depends="jar" description="Create the ${app.name} application bundle.">
<property name="bundle.name" value="${app.name}.app" />
<exec executable="python">
<arg value="${buildtools.dir}/bundle_app" />
<arg value="${app.main}" />
<arg value="${dst.dir}/${bundle.name}" />
<arg value="-w" />
<arg value="-s" /><arg value="${buildtools.dir}/JavaApplicationStub" />
<arg value="-n" /><arg value="${app.name}" />
<arg value="-r" /><arg value="${dst.dir}/${dst.name}.jar" />
<arg value="-r" /><arg value="${lib.dir}" />
<arg value="-r" /><arg value="${resources.dir}" />
<arg value="-i" /><arg value="${app.icon}" />
<arg value="-J" /><arg value="-Xmx1024M" />
</exec>
</target>
<!--============================
Testing
============================ -->
<target name="test" depends="compile-test">
<junit haltonfailure="true">
<formatter type="plain" usefile="false"/>
<classpath>
<path refid="classpath" />
<pathelement location="${build.dir}" />
<pathelement location="${test.build.dir}" />
</classpath>
<batchtest fork="yes">
<fileset dir="${test.src.dir}">
<include name="**/*Test*.java"/>
<include name="**/*Unit*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!--============================
Version Control Systems
============================ -->
<target name="unversioned" >
<property name="version" value="unversioned" />
</target>
<!-- SVN Targets -->
<target name="svn" depends="svn-check" unless="version.clean" >
<echo message="WARNING: Project contains unversioned modifications." />
</target>
<target name="svn-check" description="Sets version based on svn.">
<exec executable="svnversion" dir="." outputproperty="version" >
<arg line="."/>
</exec>
<condition property="version.clean">
<not>
<or>
<contains string="${version}" substring=":"/>
<contains string="${version}" substring="M"/>
<contains string="${version}" substring="S"/>
</or>
</not>
</condition>
<echo message="version = ${version}"/>
</target>
<!-- GIT Targets -->
<target name="git" depends="git-check-ok,git-check-warning,git-check-fatal" />
<target name="git-fetch-version" >
<!-- Fetch version hash. -->
<exec executable="git" dir="." outputproperty="version.raw" failonerror="false">
<arg line='log -1 --format="%H"' />
</exec>
<condition property="version.fatal" >
<contains string="${version.raw}" substring="fatal:" />
</condition>
</target>
<target name="git-status" depends="git-fetch-version" unless="version.fatal" >
<!-- Update the index. -->
<exec executable="git" dir="." failonerror="false">
<arg line='update-index -q --ignore-submodules --refresh'/>
</exec>
<!-- Check for unstaged changes. -->
<exec executable="git" dir="." failonerror="false" resultproperty="version.changesnotstaged" >
<arg line='diff-files --quiet --ignore-submodules --'/>
</exec>
<!-- Check for uncommited changes. -->
<exec executable="git" dir="." failonerror="false" resultproperty="version.changesnotcommitted" >
<arg line='diff-index --cached --quiet HEAD --ignore-submodules --'/>
</exec>
<condition property="version.ok">
<and>
<equals arg1="${version.changesnotstaged}" arg2="0" />
<equals arg1="${version.changesnotcommitted}" arg2="0" />
</and>
</condition>
<condition property="version.warning" >
<isfalse value="${version.ok}" />
</condition>
</target>
<target name="git-check-ok" depends="git-status" if="version.ok" >
<property name="version" value="${version.raw}" />
</target>
<target name="git-check-warning" depends="git-status" if="version.warning" >
<property name="version" value="${version.raw}_modified" />
<echo message="WARNING: Project contains unversioned modifications." />
</target>
<target name="git-check-fatal" depends="git-status" if="version.fatal" >
<property name="version" value="unversioned" />
<echo message="WARNING: Not a valid git repository." />
</target>
</project>