-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
373 lines (312 loc) · 15.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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2008, xBlackCat.
-->
<project name="rojac-application" default="rebuild">
<description>
This build file is used for compiling and preparing Rojac distributive.
</description>
<property environment="env"/>
<property name="rojac.filename" value="rojac"/>
<property name="rojac.launcher.class" value="org.xblackcat.rojac.RojacLauncher"/>
<dirname property="rojac-application.basedir" file="${ant.file.rojac-application}"/>
<property file="build.properties"/>
<property name="rojac-application.lib.dir" value="${rojac-application.basedir}/libs"/>
<property name="rojac-application.output.dir" value="${rojac-application.basedir}/classes/bin"/>
<property name="rojac-application.testoutput.dir" value="${rojac-application.basedir}/classes/test"/>
<property name="rojac-application.dist.dir" value="${rojac-application.basedir}/dist"/>
<property name="rojac-application.dist.dir-unpacked" value="${rojac-application.dist.dir}/Rojac"/>
<!-- Revision number file is used to determine current build -->
<property name="revision.number.file" value="${rojac-application.output.dir}/config/rojac.revision"/>
<!-- Compiler options -->
<property name="compiler.generate.no.warnings" value="off"/>
<!--<property name="compiler.args" value="-target jsr14"/>-->
<patternset id="compiler.resources">
<include name="**/?*.properties"/>
<include name="**/?*.xml"/>
<include name="**/?*.gif"/>
<include name="**/?*.png"/>
<include name="**/?*.jpeg"/>
<include name="**/?*.jpg"/>
<include name="**/?*.html"/>
<include name="**/?*.dtd"/>
<include name="**/?*.tld"/>
<include name="**/?*.wsdd"/>
<include name="**/?*.txt"/>
<include name="**/?*.config"/>
<include name="**/?*.words"/>
<include name="**/?*.css"/>
</patternset>
<!-- JDK definitions -->
<path id="jdk.classpath">
<fileset dir="${jdk.home}">
<include name="jre/lib/charsets.jar"/>
<include name="jre/lib/deploy.jar"/>
<include name="jre/lib/javaws.jar"/>
<include name="jre/lib/jce.jar"/>
<include name="jre/lib/jsse.jar"/>
<include name="jre/lib/plugin.jar"/>
<include name="jre/lib/rt.jar"/>
<include name="jre/lib/ext/dnsns.jar"/>
<include name="jre/lib/ext/localedata.jar"/>
<include name="jre/lib/ext/sunjce_provider.jar"/>
<include name="jre/lib/ext/sunpkcs11.jar"/>
</fileset>
</path>
<path id="rojac-application.module.bootclasspath">
<!-- Paths to be included in compilation bootclasspath -->
</path>
<path id="rojac-application.module.classpath">
<path refid="jdk.classpath"/>
<fileset dir="${rojac-application.lib.dir}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
</fileset>
</path>
<path id="rojac-application.module.classpath.compile">
<path refid="jdk.classpath"/>
<fileset dir="${rojac-application.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<property name="project.jdk.home" value="${jdk.home}"/>
<property name="project.jdk.classpath" value="jdk.classpath"/>
<path id="rojac-application.module.sourcepath">
<dirset dir="${rojac-application.basedir}">
<include name="src/java"/>
<include name="src/wsdl"/>
</dirset>
</path>
<path id="rojac-application.module.test.sourcepath">
<dirset dir="${rojac-application.basedir}">
<include name="test/java"/>
</dirset>
</path>
<target name="clean" description="cleanup all">
<delete dir="${rojac-application.dist.dir}"/>
<delete dir="${rojac-application.basedir}/classes"/>
<delete dir="${rojac-application.basedir}/report"/>
</target>
<target name="prepare">
<mkdir dir="${rojac-application.output.dir}"/>
<mkdir dir="${rojac-application.testoutput.dir}"/>
<mkdir dir="${rojac-application.dist.dir}"/>
<mkdir dir="${rojac-application.dist.dir-unpacked}"/>
</target>
<target name="get.revision" depends="prepare" if="get.source.revision">
<!-- Paste resource file with revision information -->
<exec executable="svn" output="${rojac-application.output.dir}/svninfo.xml" failifexecutionfails="false">
<arg line="info"/>
<arg line="-r BASE"/>
<arg line="--xml"/>
<!-- any filename can be here, because we need only Revision property, which is general for all filenames -->
<arg value="${rojac-application.basedir}"/>
</exec>
<xmlproperty file="${rojac-application.output.dir}/svninfo.xml" prefix="svn" keepRoot="no"/>
<delete file="${rojac-application.output.dir}/svninfo.xml" failonerror="false"/>
<echo>Revision: ${svn.entry(revision)}</echo>
</target>
<target name="compile" description="Compile application" depends="prepare, get.revision">
<!--Compile application classes-->
<javac destdir="${rojac-application.output.dir}"
debug="${compiler.debug}"
nowarn="${compiler.generate.no.warnings}"
memorymaximumsize="${compiler.max.memory}"
fork="true"
includeantruntime="false">
<compilerarg line="${compiler.args.rojac}"/>
<bootclasspath refid="rojac-application.module.bootclasspath"/>
<classpath refid="rojac-application.module.classpath"/>
<src refid="rojac-application.module.sourcepath"/>
</javac>
<copy todir="${rojac-application.output.dir}">
<fileset dir="${rojac-application.basedir}/src/java">
<patternset refid="compiler.resources"/>
<type type="file"/>
</fileset>
<fileset dir="${rojac-application.basedir}/src/res">
<patternset refid="compiler.resources"/>
<type type="file"/>
</fileset>
</copy>
<!--Compile test classes-->
<javac destdir="${rojac-application.testoutput.dir}"
debug="${compiler.debug}"
nowarn="${compiler.generate.no.warnings}"
memorymaximumsize="${compiler.max.memory}"
includeantruntime="false"
fork="true">
<compilerarg line="${compiler.args.rojac}"/>
<classpath refid="rojac-application.module.classpath.compile"/>
<classpath location="${rojac-application.output.dir}"/>
<src refid="rojac-application.module.test.sourcepath"/>
</javac>
<copy todir="${rojac-application.testoutput.dir}">
<fileset dir="${rojac-application.basedir}/test/java">
<patternset refid="compiler.resources"/>
<type type="file"/>
</fileset>
<fileset dir="${rojac-application.basedir}/test/res">
<patternset refid="compiler.resources"/>
<type type="file"/>
</fileset>
</copy>
<antcall target="add.svn.info" inheritall="on"/>
</target>
<!-- Run the task only if svn info is success fully obtained. -->
<target name="add.svn.info" if="svn.entry(revision)">
<dirname property="revision.number.dir" file="${revision.number.file}"/>
<mkdir dir="${revision.number.dir}"/>
<echo file="${revision.number.file}"># Application revision information
relative.path=${svn.entry.url}
revision=${svn.entry(revision)}
</echo>
<replace file="${revision.number.file}" token="${svn.entry.repository.root}" value=""/>
</target>
<target name="test" description="Make tests before packaging application" depends="compile" if="perform.tests">
<mkdir dir="${rojac-application.basedir}/report"/>
<junit haltonerror="yes" haltonfailure="yes" fork="true">
<classpath>
<path refid="rojac-application.module.classpath.compile"/>
<pathelement location="${rojac-application.output.dir}"/>
<pathelement location="${rojac-application.testoutput.dir}"/>
<pathelement location="${rojac-application.basedir}/test/res"/>
<!-- External resources are not included into compile output folder -->
<pathelement location="${rojac-application.basedir}/src/res.ext"/>
</classpath>
<batchtest todir="${rojac-application.basedir}/report">
<formatter type="xml"/>
<fileset dir="${rojac-application.testoutput.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="build" description="Make distributive of the application. Generate scripts to run application"
depends="compile, test">
<mkdir dir="${rojac-application.dist.dir-unpacked}/bin"/>
<mkdir dir="${rojac-application.dist.dir-unpacked}/conf"/>
<mkdir dir="${rojac-application.dist.dir-unpacked}/lib"/>
<fileset id="rojac.runtime.libs" dir="${rojac-application.lib.dir}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
</fileset>
<copy todir="${rojac-application.dist.dir-unpacked}/conf">
<fileset dir="${rojac-application.basedir}/src/res.ext">
<patternset refid="compiler.resources"/>
</fileset>
</copy>
<copy todir="${rojac-application.dist.dir-unpacked}/lib">
<fileset refid="rojac.runtime.libs"/>
</copy>
<jar jarfile="${rojac-application.dist.dir-unpacked}/lib/${rojac.filename}.jar">
<fileset dir="${rojac-application.output.dir}"/>
</jar>
<echo file="${rojac-application.dist.dir-unpacked}/bin/setclasspath.bat"><![CDATA[
@SET CLASSPATH=%CLASSPATH%;%1
]]>
</echo>
<echo file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.cmd"><![CDATA[@echo off
SET CLASSPATH=%CLASSPATH%;..\conf
FOR /F %%j IN ('DIR /S /B ..\lib\*.jar') DO CALL setclasspath.bat "%%j"
javaw.exe -cp "%CLASSPATH%" ${rojac.launcher.class}
]]>
</echo>
<echo file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.sh"><![CDATA[#
#!/bin/sh
BASEDIR=`dirname $0`
cd "$BASEDIR"
export CLASSPATH=$BASEDIR/../conf:`ls -1 $BASEDIR/../lib/*.jar $BASEDIR/../lib/*/*.jar | tr "\r\n" ":"`
java -cp "$CLASSPATH" ${rojac.launcher.class}
]]>
</echo>
<echo file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.bat"><![CDATA[@echo off
SET CLASSPATH=%CLASSPATH%;..\conf
FOR /F %%j IN ('DIR /S /B ..\lib\*.jar') DO CALL setclasspath.bat "%%j"
java.exe -cp "%CLASSPATH%" ${rojac.launcher.class}
]]>
</echo>
<echo file="${rojac-application.dist.dir-unpacked}/build.txt">${svn.entry(revision)}</echo>
<fixcrlf file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.cmd" eol="dos"/>
<fixcrlf file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.bat" eol="dos"/>
<fixcrlf file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.sh" eol="unix"/>
<chmod file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.sh" perm="755" failonerror="false"/>
</target>
<target name="build.exe" if="launch4j.dir">
<!-- Generate launch4j config file -->
<echo file="${rojac-application.basedir}/classes/sender.launch4j.xml"><![CDATA[
<launch4jConfig>
<headerType>gui</headerType>
<outfile>${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.exe</outfile>
<errTitle>Rojac</errTitle>
<dontWrapJar>true</dontWrapJar>
<customProcName>true</customProcName>
<icon>${rojac-application.basedir}/extras/design/rojac.ico</icon>
<classPath>
<mainClass>${rojac.launcher.class}</mainClass>
<cp>../lib/lnf/*.jar</cp>
<cp>../lib/db/*.jar</cp>
<cp>../conf</cp>
<cp>../lib/*.jar</cp>
</classPath>
<jre>
<minVersion>1.7.0</minVersion>
</jre>
</launch4jConfig>]]>
</echo>
<!-- Perform -->
<taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask">
<classpath>
<fileset file="${launch4j.dir}/launch4j.jar"/>
<fileset file="${launch4j.dir}/lib/xstream.jar"/>
</classpath>
</taskdef>
<launch4j configFile="${rojac-application.basedir}/classes/sender.launch4j.xml"/>
<echo file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.l4j.ini"><![CDATA[# Rojac JVM options
-Xms32M
-Xmx80M
]]>
</echo>
<fixcrlf file="${rojac-application.dist.dir-unpacked}/bin/${rojac.filename}.l4j.ini" eol="dos"/>
</target>
<target name="make.name" unless="svn.entry(revision)">
<property name="rojac.pack.filename" value="${rojac.filename}"/>
</target>
<target name="make.name.revision" if="svn.entry(revision)">
<property name="rojac.pack.filename" value="${rojac.filename}-r${svn.entry(revision)}"/>
</target>
<target name="pack" description="Make archive of the project" depends="rebuild, make.name, make.name.revision">
<mkdir dir="${rojac-application.archive.dir}"/>
<zip destfile="${rojac-application.archive.dir}/${rojac.pack.filename}.zip" level="9"
compress="yes">
<fileset dir="${rojac-application.dist.dir-unpacked}">
<include name="build.txt"/>
<include name="bin/${rojac.filename}*"/>
<include name="bin/setclasspath.bat"/>
<include name="lib/**/*.jar"/>
<exclude name="lib/${rojac.filename}-tests.jar"/>
<include name="conf/**/*"/>
</fileset>
</zip>
<zip destfile="${rojac-application.archive.dir}/${rojac.pack.filename}-src.zip" level="9"
compress="yes">
<fileset dir="${rojac-application.basedir}">
<include name="docs/**/*"/>
<include name="extras/**/*"/>
<include name="libs/**/*"/>
<include name="src/**/*"/>
<include name="test/**/*"/>
<include name="build.*"/>
<exclude name="**/.svn"/>
</fileset>
</zip>
<echo file="${rojac-application.archive.dir}/last-revision.txt">${svn.entry(revision)}</echo>
</target>
<target name="rebuild" description="Rebuild application" depends="clean, compile, build, build.exe"/>
<target name="make-product"
description="Force run all additional tasks to make production distributive.">
<property name="perform.tests" value="on"/>
<property name="get.source.revision" value="on"/>
<antcall target="pack" inheritall="on"/>
</target>
</project>