-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
319 lines (275 loc) · 12.4 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
<project name="funz-calculator" default="help" basedir="." xmlns:jacoco="antlib:org.jacoco.ant">
<property name="funz-root.dir" value="${basedir}/.." />
<property name="funz.properties" location="../funz-profile/funz.properties" />
<!-- funz dependent properties -->
<property file="${funz.properties}" />
<!-- verify that the ${funz.properties} file has been set -->
<fail message="Set the funz properties file ${funz.properties} from funz-profile">
<condition>
<not>
<and>
<available file="${funz.properties}" type="file" />
</and>
</not>
</condition>
</fail>
<!-- funz calculator dependent properties -->
<property file="funz-calculator.properties"/>
<path id="antcontrib.classpath">
<pathelement location="../funz-profile/lib/ant-contrib-0.6.jar" />
</path>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="../funz-profile/lib/jacocoant.jar"/>
</taskdef>
<property name="unit.test.jar" value="../funz-profile/lib/concutest-junit-4.7-withrt.jar" />
<!--property name="unit.test.jar" value="../funz-profile/lib/junit-4.3.jar" /-->
<taskdef name="for" taskname="for" classname="net.sf.antcontrib.logic.For" classpathref="antcontrib.classpath" />
<taskdef name="if" taskname="if" classname="net.sf.antcontrib.logic.IfTask" classpathref="antcontrib.classpath" />
<taskdef name="propertycopy" taskname="propertycopy" classname="net.sf.antcontrib.property.PropertyCopy" classpathref="antcontrib.classpath" />
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="antcontrib.classpath" />
<property name="Calculator.tmpl" location="${src.dir}/org/funz/calculator/Calculator.tmpl" />
<property name="Calculator.java" location="${src.dir}/org/funz/calculator/Calculator.java" />
<!-- classpathes -->
<path id="core.classpath">
<fileset dir="${core.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="client.classpath">
<fileset dir="${client.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="lib.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="compile.path" >
<path refid="core.classpath" />
<path refid="lib.classpath" />
</path>
<!-- clean targets -->
<target name="clean-build" description="clean up">
<delete dir="${build.dir}" failonerror="false" />
<delete dir="${build.ide.dir}" failonerror="false" />
</target>
<target name="clean-dist" description="clean up">
<delete dir="${dist.dir}" failonerror="false"/>
</target>
<target name="clean-doc" description="">
<delete dir="${doc.dir}" failonerror="false" />
</target>
<target name="clean" depends="clean-build, clean-dist, clean-doc" />
<!-- compilation and installation -->
<target name="compile" description="compile the source">
<if>
<equals arg1="$${monitor}" arg2="${monitor}" />
<then>
<echo message="No monitor"/>
<copy file="${Calculator.tmpl}" tofile="${Calculator.java}" overwrite="true" />
<replace file="${Calculator.java}" token="__MONITOR__" value='""' />
</then>
<else>
<echo message="Monitor: ${monitor}"/>
<copy file="${Calculator.tmpl}" tofile="${Calculator.java}" overwrite="true" />
<replace file="${Calculator.java}" token="__MONITOR__" value="${monitor}" />
</else>
</if>
<mkdir dir="${build.dir}" />
<javac srcdir="${src.dir}"
destdir="${build.dir}"
debug="true"
encoding="ISO-8859-1"
source="${java.compiler.version}"
target="${java.compiler.version}" >
<classpath refid="compile.path" />
</javac>
</target>
<target name="dist" depends="compile" description="generate the distribution">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.lib.dir}" />
<mkdir dir="${dist.plugins.calculator.dir}" />
<jar destfile="${dist.lib.dir}/${calculator.jar}">
<fileset dir="${build.dir}">
<include name="org/funz/calculator/**" />
</fileset>
<fileset dir="${src.dir}">
<include name="org/funz/calculator/**" />
</fileset>
<manifest>
<attribute name="Main-Class" value="org.funz.calculator.Calculator" />
</manifest>
</jar>
<copy todir="${dist.dir}" overwrite="true">
<fileset file="${config.dir}/${calculator.xml}"/>
</copy>
<copy todir="${dist.dir}" overwrite="true">
<fileset file="${scripts.dir}/Funz*"/>
</copy>
<chmod perm="a+x">
<fileset dir="${dist.dir}">
<include name="Funz*.*" />
</fileset>
</chmod>
<mkdir dir="${dist.scripts.dir}" />
<copy todir="${dist.scripts.dir}" overwrite="true">
<fileset dir="${scripts.dir}">
<include name="*"/>
<exclude name="*Funz*"/>
</fileset>
</copy>
<chmod perm="a+x">
<fileset dir="${dist.scripts.dir}">
<include name="*.sh" />
<include name="*.bat" />
</fileset>
</chmod>
<copy todir="${dist.lib.dir}">
<fileset dir="${lib.dir}">
<include name="*" />
</fileset>
</copy>
<copy todir="${dist.lib.dir}">
<fileset dir="${core.lib.dir}">
<include name="*" />
</fileset>
</copy>
</target>
<target name="compile-test" depends="compile" description="compile the test">
<javac srcdir="${test.dir}"
destdir="${build.dir}"
debug="true"
encoding="ISO-8859-1"
source="${java.compiler.version}"
target="${java.compiler.version}" >
<classpath refid="compile.path" />
<classpath path="${build.dir}" />
<classpath path="${unit.test.jar}" />
<classpath path="../funz-client/build" />
</javac>
</target>
<target name="dist-test" depends="dist, compile-test" description="add the test resources to dist">
<copy todir="." >
<fileset file="${test.resources.dir}/*"/>
</copy>
<chmod perm="a+x">
<fileset dir=".">
<include name="*.sh" />
<include name="*.bat" />
</fileset>
</chmod>
<copy todir="." >
<fileset file="${test.resources.dir}/*"/>
</copy>
<copy todir="${dist.dir}" overwrite="true">
<fileset file="${test.config.dir}/*"/>
</copy>
<!--java classname="org.funz.conf.Configuration" fork="true" >
<classpath refid="client.classpath" />
<jvmarg value="-Dcharset=ISO-8859-1" />
<arg value="${test.config.dir}/${quotas.xml}" />
<redirector output="${dist.dir}/${quotas.hex}" />
</java-->
<jar destfile="${dist.dir}/plugins/calc/CatnCount.cplugin.jar">
<fileset dir="${build.dir}">
<include name="org/funz/**/CatnCount_CPlugin*.class" />
</fileset>
</jar>
</target>
<target name="test" depends="dist-test, compile-test">
<fileset id="tests" dir="${build.dir}" includes="**/*Test.class" />
<!--property name="tests.p" refid="tests"/>
<echo message="${tests.p}"/-->
<pathconvert pathsep="${line.separator}" property="tests.list" refid="tests">
<map from="${build.dir}/" to=""/>
</pathconvert>
<!--echo message="${tests.list}"/>
<echo message="================"/-->
<for list="${tests.list}" param="test.class" delimiter="${line.separator}">
<sequential>
<echo message="======================================="/>
<echo message="============= @{test.class} ============="/>
<echo message="========================================="/>
<propertyregex property="test.class" input="@{test.class}" regexp="\.class" replace="" global="true" override="true"/>
<!--echo message="${test.class}"/-->
<propertyregex property="test.class.id" input="${test.class}" regexp="[/\\]" replace="\." global="true" override="true"/>
<!--echo message="${test.class.id}"/-->
<record name="${test.class.id}.txt" action="start"/>
<jacoco:coverage>
<java classname="${test.class.id}" fork="true" timeout="360000" failonerror="false" resultproperty="@{test.class}.failed">
<!-- jvmarg value='-Dnashorn.args="-.-no-deprecation-warning"'/ -->
<classpath refid="lib.classpath" />
<classpath refid="core.classpath" />
<classpath refid="client.classpath" />
<classpath path="${build.dir}" />
<classpath path="${unit.test.jar}" />
<assertions>
<enable/>
</assertions>
</java>
</jacoco:coverage>
<record name="${test.class.id}.txt" action="stop"/>
<if>
<equals arg1="${@{test.class}.failed}" arg2="0" />
<then>
</then>
<else>
<property name="failed" value="1" />
<echo message="Failures: @{test.class}" />
</else>
</if>
</sequential>
</for>
<fail message="Test failure detected, check test results." if="failed" />
</target>
<target name="coverage" >
<jacoco:report>
<executiondata>
<file file="jacoco.exec"/>
</executiondata>
<structure name="funz-calculator">
<classfiles>
<fileset dir="build"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src/main/java"/>
</sourcefiles>
</structure>
<html destdir="coverage"/>
<xml destfile="jacoco.xml"/>
</jacoco:report>
</target>
<target name="doc" >
<mkdir dir="${doc.dir}" />
<javadoc sourcepath="${src.dir}" packagenames="org.funz.*" classpathref="compile.path" destdir="${doc.dir}" access="public"/>
</target>
<target name="doc-CPlugin" >
<mkdir dir="${doc.dir}" />
<mkdir dir="${doc.dir}/cplugin" />
<javadoc sourcepath="${src.dir}" packagenames="org.funz.calculator.plugin.*" classpathref="compile.path" destdir="${doc.dir}/cplugin" access="protected"/>
</target>
<!-- run application -->
<target name="run-calculator">
<java classname="org.funz.calculator.Calculator" fork="true">
<!--jvmarg value='-Dnashorn.args="-.-no-deprecation-warning"'/-->
<classpath refid="compile.path" />
<classpath path="${build.dir}" />
<jvmarg value="-Dapp.home=." />
<arg value="file:${dist.dir}/${calculator.xml}" />
</java>
</target>
<!-- help -->
<target name="help" description="display the help on standard output">
<echo message="********************************" />
<echo message=" Funz calculator" />
<echo message="********************************" />
<echo />
<echo message="help : display this help" />
<echo message="clean : clean everything that can be generated by ant targets" />
<echo message="dist : generate a distribution" />
<echo message="test : run tests" />
<echo message="run-calculator : run the application" />
<echo message="doc : generate the code documentation" />
</target>
</project>