-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild-commons.xml
More file actions
383 lines (327 loc) · 11.4 KB
/
build-commons.xml
File metadata and controls
383 lines (327 loc) · 11.4 KB
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
374
375
376
377
378
379
380
381
382
383
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Copyright 2010 Spolecne s.r.o. (www.spoledge.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-->
<project name="commons" basedir="." default="...">
<!-- SECTION PROPERTIES -->
<dirname property="root.dir" file="${ant.file.commons}"/>
<property name="app-name" value="audao"/>
<property name="pkg-prefix" value="com.spoledge"/>
<!-- The global .ant.properties -->
<property file="${root.dir}/VERSION"/>
<property file="${root.dir}/.ant.properties"/>
<!-- The local .ant.properties -->
<property file=".ant.properties"/>
<condition property="pkg-name" value="${pkg-prefix}.${app-name}">
<not>
<isset property="pkg-name"/>
</not>
</condition>
<property name="module-name" value="${app-name}-${ant.project.name}"/>
<property name="conf.global" location="${root.dir}/conf"/>
<property name="conf.local" location="conf"/>
<property name="lib.global" location="${root.dir}/lib"/>
<property name="lib.local" location="lib"/>
<property name="src.dir" location="src"/>
<property name="src.java" location="${src.dir}/java"/>
<property name="src-test.dir" location="${src.dir}/test"/>
<property name="build.dir" location="build"/>
<property name="build.src-gen.dir" location="${build.dir}/src-gen"/>
<property name="build.classes.dir" location="${build.dir}/classes"/>
<property name="build.classes-test.dir" location="${build.dir}/classes-test"/>
<property name="dist.dir" location="dist"/>
<property name="module.jar" location="${dist.dir}/${module-name}.jar"/>
<condition property="log4j.conf" value="${log4j.config}" else="conf/log4j.xml">
<isset property="log4j.config"/>
</condition>
<whichresource property="log4j.config.url" resource="${log4j.conf}" classpath="."/>
<condition property="logging.properties" value="${logging.properties}" else="conf/logging.properties">
<isset property="logging.properties"/>
</condition>
<!-- SECTION FILESET AND CLASSPATH -->
<fileset id="lib.global.fileset" dir="${lib.global}">
<include name="**/*.jar"/>
</fileset>
<fileset id="lib.local.fileset" dir="${lib.local}">
<include name="**/*.jar"/>
</fileset>
<path id="sql.classpath">
<fileset refid="lib.global.fileset"/>
</path>
<path id="junit.path">
<fileset dir="${lib.global}/junit" includes="*.jar"/>
</path>
<!-- SECTION TARGETS -->
<target name="clean" description="Clears output directories">
<delete dir="${dist.dir}"/>
<delete dir="${build.dir}"/>
</target>
<target name="clear" description="Clears output directories">
<antcall target="clean"/>
</target>
<target name="mr-proper" description="Clears output and lib directories">
<antcall target="clean"/>
<delete>
<fileset dir="${lib.local}" includes="${app-name}-*.jar"/>
</delete>
</target>
<target name="db-info">
<property file="${conf.global}/${db.config}"/>
<echo level="info" message="*** INFO ************************************************************"/>
<echo level="info" message="* The '${db.type}' DB type is configured as follows:"/>
<echo level="info" message="* driver: ${jdbc.driver}"/>
<echo level="info" message="* url: ${jdbc.url}"/>
<echo level="info" message="* login: ${jdbc.username}"/>
<echo level="info" message="*********************************************************************"/>
</target>
<target name="sql-execute">
<sql driver="${jdbc.driver}"
url="${jdbc.url}"
userid="${jdbc.username}"
password="${jdbc.password}"
onerror="continue"
src="${sql-execute.src}"
classpathref="sql.classpath"
encoding="UTF-8"
/>
</target>
<target name="confirm">
<input
message="${confirm.message}"
validargs="y,n"
addproperty="confirm"
/>
<condition property="continue">
<equals arg1="y" arg2="${confirm}"/>
</condition>
<fail unless="continue">Confirmation failed:
The process was aborted because confirmation failed.
</fail>
</target>
<target name="depends-on-jar">
<condition property="jar.present">
<or>
<resourcecount when="ge" count="1">
<fileset dir="${lib.global}" includes="**/${name}"/>
</resourcecount>
<resourcecount when="ge" count="1">
<fileset dir="${lib.local}" includes="**/${name}"/>
</resourcecount>
</or>
</condition>
<antcall target="depends-on-jar.impl"/>
</target>
<target name="depends-on-jar.impl" unless="jar.present">
<echo level="error" message="*** ERROR ***********************************************************"/>
<echo level="error" message="* The library ${name} is missing."/>
<echo level="error" message="* Please read the README file and install it as recommended."/>
<echo level="error" message="*********************************************************************"/>
<fail>Module dependency failed</fail>
</target>
<target name="depends-on-module">
<condition property="full-name" value="${app-name}-${name}-${suffix}.jar">
<isset property="suffix"/>
</condition>
<condition property="full-name" value="${app-name}-${name}.jar">
<not>
<isset property="suffix"/>
</not>
</condition>
<property name="jar.name" location="${lib.local}/${full-name}"/>
<available property="jar.present" file="${jar.name}"/>
<antcall target="depends-on-module.impl"/>
</target>
<target name="depends-on-module.impl" unless="jar.present">
<echo level="error" message="*** ERROR ***********************************************************"/>
<echo level="error" message="* The file ${jar.name} is missing."/>
<echo level="error" message="* Please run the global build first."/>
<echo level="error" message="*********************************************************************"/>
<fail>Module dependency failed</fail>
</target>
<target name="check">
<fail unless="pkg-prefix">
The property "pkg-prefix" is not set.
Please add it to your global .ant.properties file.
</fail>
<fail unless="app-name">
The property "app-name" is not set.
Please add it to your global .ant.properties file.
</fail>
<fail unless="java-version">
The property "java-version" is not set (1.5 or 1.6).
Please add it to your global .ant.properties file.
</fail>
</target>
<target name="compile">
<antcall target="compile-src-path">
<param name="src-path" value="${src.java}"/>
</antcall>
</target>
<target name="compile-src-path">
<antcall target="compile-src-dest">
<param name="dest-dir" value="${build.classes.dir}"/>
</antcall>
</target>
<target name="compile-src-dest" depends="check">
<mkdir dir="${dest-dir}"/>
<condition property="jdk-5">
<equals arg1="${java-version}" arg2="1.5"/>
</condition>
<antcall target="compile-src-dest-5"/>
<antcall target="compile-src-dest-6"/>
</target>
<target name="compile-src-dest-5" if="jdk-5">
<condition property="includeantruntime" value="false">
<not>
<isset property="includeantruntime"/>
</not>
</condition>
<javac
destdir="${dest-dir}"
classpathref="compile.path"
source="${java-version}"
target="${java-version}"
debug="true"
deprecation="true"
optimize="false"
includeantruntime="${includeantruntime}"
>
<src path="${src-path}"/>
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
<target name="compile-src-dest-6" unless="jdk-5">
<mkdir dir="${build.src-gen.dir}"/>
<condition property="includeantruntime" value="false">
<not>
<isset property="includeantruntime"/>
</not>
</condition>
<javac
destdir="${dest-dir}"
classpathref="compile.path"
source="${java-version}"
target="${java-version}"
debug="true"
deprecation="true"
optimize="false"
includeantruntime="${includeantruntime}"
>
<src path="${src-path}"/>
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-s"/>
<compilerarg path="${build.src-gen.dir}"/>
</javac>
</target>
<target name="compile-test">
<mkdir dir="${build.classes-test.dir}"/>
<javac
srcdir="${src-test.dir}"
destdir="${build.classes-test.dir}"
classpathref="compile-test.path"
source="${java-version}"
target="${java-version}"
debug="true"
deprecation="true"
optimize="false"
includeantruntime="false"
>
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
<target name="make-jar">
<antcall target="make-jar-src">
<param name="src-dir" value="${build.classes.dir}"/>
</antcall>
</target>
<fileset id="empty-fs" dir="${dist.dir}" includes="n/a"/>
<target name="make-jar-src">
<mkdir dir="${dist.dir}"/>
<condition property="metainf-fs" value="empty-fs">
<not>
<isset property="metainf-fs"/>
</not>
</condition>
<condition property="jar" value="${module.jar}">
<not>
<isset property="jar"/>
</not>
</condition>
<jar destfile="${jar}">
<fileset dir="${src-dir}">
<include name="**" />
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Jdk" value="${java.version}"/>
<attribute name="Build-Platform" value="${os.name} ${os.arch} ${os.version}"/>
</manifest>
<metainf refid="${metainf-fs}"/>
</jar>
</target>
<fileset id="junit-default.fs" dir="${build.classes-test.dir}">
<include name="**/*Test.class"/>
<include name="**/*Tests.class"/>
<exclude name="**/*Abstract*Test.class"/>
<exclude name="**/*Abstract*Tests.class"/>
</fileset>
<fileset id="junit-custom.fs" dir="${build.classes-test.dir}">
<include name="${junit-custom-pattern}"/>
<include name="${junit-custom-pattern-include}"/>
<exclude name="${junit-custom-pattern-exclude}"/>
<exclude name="**/*Abstract*Test.class"/>
<exclude name="**/*Abstract*Tests.class"/>
</fileset>
<target name="junit">
<condition property="junit-fs" value="junit-default.fs">
<not>
<isset property="junit-fs"/>
</not>
</condition>
<condition property="junit-path" value="run-test.path">
<not>
<isset property="junit-path"/>
</not>
</condition>
<echo message="log4j.conf=${log4j.conf}"/>
<echo message="log4j.configuration=${log4j.config.url}"/>
<echo message="logging.properties=${logging.properties}"/>
<junit
printsummary="on" fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="false"
>
<classpath refid="${junit-path}"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset refid="${junit-fs}"/>
</batchtest>
<sysproperty key="log4j.configuration" value="${log4j.config.url}"/>
<sysproperty key="java.util.logging.config.file" value="${logging.properties}"/>
<sysproperty key="jdbc.driver" value="${jdbc.driver}"/>
<sysproperty key="jdbc.url" value="${jdbc.url}"/>
<sysproperty key="jdbc.username" value="${jdbc.username}"/>
<sysproperty key="jdbc.password" value="${jdbc.password}"/>
</junit>
<fail if="tests.failed">
***********************************************************
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
***********************************************************
</fail>
</target>
</project>