-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild_plugin.xml
More file actions
484 lines (422 loc) · 21.5 KB
/
Copy pathbuild_plugin.xml
File metadata and controls
484 lines (422 loc) · 21.5 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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<project name="build_plugin" default="test">
<!--abstract tasks for plugin, to be imported in plugin build.xml-->
<property name="funz.properties" location="../funz-profile/funz.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>
<property name="funz.release" value="v${core.version}" />
<echo message="********************************" />
<echo message=" Funz ${funz.release} ${code.name} plugin" />
<echo message="********************************" />
<property name="plugin.properties" location="../funz-profile/plugin.properties" />
<property file="${plugin.properties}" />
<!-- verify that the ${plugin.properties} file has been set -->
<fail message="Set the plugin properties file ${plugin.properties} from funz-profile">
<condition>
<not>
<and>
<available file="${plugin.properties}" type="file" />
</and>
</not>
</condition>
</fail>
<path id="antcontrib.classpath">
<pathelement location="../funz-profile/lib/ant-contrib-0.6.jar" />
</path>
<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" />
<!-- get empty Funz (given version) -->
<import file="../funz-profile/proxy_conf.xml"/> <!-- fill with your conf if needed -->
<property name="funz-calculator.install.src" value="https://github.com/Funz/funz-calculator/releases/download/${funz.release}"/>
<property name="funz-client.install.src" value="https://github.com/Funz/funz-client/releases/download/${funz.release}"/>
<target name="get-funz" depends="proxy">
<if><available file="${funz.dir}" type="dir" />
<then>
<echo message="Funz dir already exists. Skipping download..."/>
</then>
<else>
<if><available file="funz-calculator.zip" type="file" />
<then></then>
<else>
<get src="${funz-calculator.install.src}/funz-calculator.zip" dest="funz-calculator.zip"/>
</else>
</if>
<unzip src="funz-calculator.zip" dest="${funz.dir}" overwrite="true"/>
<if><available file="funz-client.zip" type="file" />
<then></then>
<else>
<get src="${funz-client.install.src}/funz-client.zip" dest="funz-client.zip"/>
</else>
</if>
<unzip src="funz-client.zip" dest="${funz.dir}" overwrite="true"/>
</else>
</if>
</target>
<!-- pathes and classpathes -->
<path id="funz.classpath" >
<fileset dir="${funz.lib.dir}" includes="**/*.jar" />
</path>
<path id="plugin.classpath" >
<path refid="funz.classpath" />
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
<path id="test.classpath" >
<path refid="plugin.classpath" />
<pathelement location="${build.dir}" />
</path>
<!-- clean: remove all generated files -->
<target name="clean" description="clean up">
<delete dir="${dist.dir}" failonerror="false" />
<delete dir="${pack.dir}" failonerror="false" />
<delete dir="${build.dir}" failonerror="false" />
<delete dir="${funz.dir}" failonerror="false" />
<delete dir="${install.dir}" />
</target>
<!-- copy resources in dist dir -->
<target name="samples">
<mkdir dir="${dist.samples.dir}" />
<copy todir="${dist.samples.dir}" failonerror="false">
<fileset dir="${samples.dir}">
<include name="*" />
</fileset>
</copy>
</target>
<target name="scripts">
<mkdir dir="${dist.scripts.dir}" />
<copy todir="${dist.scripts.dir}" failonerror="false">
<fileset dir="${scripts.dir}">
<include name="*" />
</fileset>
</copy>
<chmod dir="${dist.scripts.dir}" perm="ugo+rx" includes="**/*.sh"/>
<chmod dir="${dist.scripts.dir}" perm="ugo+rx" includes="**/*.bat"/>
</target>
<target name="libs">
<mkdir dir="${dist.lib.dir}" />
<copy todir="${dist.lib.dir}" failonerror="false">
<fileset dir="${lib.dir}">
<include name="*" />
<exclude name="Funz-*" />
</fileset>
</copy>
</target>
<!-- dist: compile the plugin classes and create 2 jars -->
<target name="dist-iopluginjar" depends="samples, scripts, libs, get-funz">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.scripts.dir}" />
<mkdir dir="${dist.samples.dir}" />
<mkdir dir="${dist.plugin.dir}" />
<mkdir dir="${dist.plugin.io.dir}" />
<mkdir dir="${dist.plugin.calc.dir}" />
<javac classpathref="plugin.classpath"
deprecation="true"
source="${java.compiler.version}"
target="${java.compiler.version}"
excludes="**/*CPlugin*"
srcdir="${src.dir}"
destdir="${build.dir}"
encoding="ISO-8859-1"
debug="true" />
<jar destfile="${dist.plugin.io.dir}/${code.name}.ioplugin.jar">
<fileset dir="${build.dir}">
<include name="org/funz/**/${code.name}IOPlugin*.class" />
<include name="org/funz/**/*Helper*.class" />
</fileset>
</jar>
<javac classpathref="plugin.classpath"
deprecation="true"
source="${java.compiler.version}"
target="${java.compiler.version}"
excludes="**/*IOPlugin*"
srcdir="${src.dir}"
destdir="${build.dir}"
encoding="ISO-8859-1"
debug="true" />
<jar destfile="${dist.plugin.calc.dir}/${code.name}.cplugin.jar">
<fileset dir="${build.dir}">
<include name="org/funz/**/${code.name}CPlugin*.class" />
<include name="org/funz/**/*Helper*.class" />
</fileset>
</jar>
</target>
<!-- dist: copy the plugin ascii files -->
<target name="dist-ioplugin" depends="samples, scripts, libs, get-funz">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.scripts.dir}" />
<mkdir dir="${dist.samples.dir}" />
<mkdir dir="${dist.plugin.dir}" />
<mkdir dir="${dist.plugin.io.dir}" />
<copy todir="${dist.plugin.io.dir}">
<fileset file="${ioplugin.dir}/*" />
</copy>
</target>
<!-- install a copy of funz and a copy of the plugin. Needed for test or (full) pack-->
<target name="install-plugin" depends="get-funz, dist">
<copy todir="${install.dir}" includeemptydirs="yes">
<fileset dir="${funz.dir}" />
</copy>
<copy todir="${install.dir}" includeemptydirs="yes" overwrite="true">
<fileset dir="${dist.dir}" />
</copy>
<!-- detects the command script -->
<condition property="command" value=".\scripts\${code.name}.bat" >
<os family="windows"/>
</condition>
<condition property="command" value="./scripts/${code.name}.sh" >
<os family="unix"/>
</condition>
<!-- append code command in calculator.xml -->
<if>
<available file="${install.dir}/plugins/calc/${code.name}.cplugin.jar" />
<then>
<replace file="${install.dir}/calculator.xml" token="/CALCULATOR" value="CODE name='${code.name}' cplugin='file:plugins/calc/${code.name}.cplugin.jar' command='./scripts/${code.name}.sh' /> </CALCULATOR" />
</then>
<else>
<replace file="${install.dir}/calculator.xml" token="/CALCULATOR" value="CODE name='${code.name}' command='${command}' /> </CALCULATOR" />
</else>
</if>
<chmod dir="${install.dir}" perm="ugo+rx" includes="**/*.sh"/>
<chmod dir="${install.dir}" perm="ugo+rx" includes="**/*.bat"/>
</target>
<!-- run reference cases. Just put input files inside src/test/cases/testname/* (usually, testname is the first input file name) -->
<target name="run-reference-cases" depends="install-plugin">
<if><os family="unix"/><then>
<exec dir="${install.dir}" executable="/bin/bash" spawn="true" failonerror="false">
<arg value="${install.dir}/FunzDaemon.sh"/>
</exec>
</then><else>
<exec dir="${install.dir}" executable="cmd.exe" spawn="true" failonerror="false">
<arg value="${install.dir}/FunzDaemon.bat"/>
</exec>
</else></if>
<dirset id="tests" dir="${test.cases.dir}" includes="*"/>
<pathconvert pathsep="${line.separator}" property="tests.list" refid="tests">
<map from="${test.cases.dir}/" to=""/>
</pathconvert>
<for list="${tests.list}" param="test.name" delimiter="${line.separator}">
<sequential>
<echo message="========================================="/>
<echo message="============= @{test.name} ============="/>
<local name="current.time"/>
<tstamp>
<format property="current.time" pattern="hh:mm:ss" />
</tstamp>
<echo message="============ ${current.time} ============"/>
<echo message="========================================="/>
<!-- create input files list, without test name (will be added in 1st position later) -->
<fileset id="input.list" dir="${test.cases.dir}/@{test.name}" casesensitive="yes">
<filename name="*"/>
<filename name="**"/>
<exclude name="@{test.name}"/>
<exclude name="Run.*"/>
<exclude name="cases.xml"/>
<exclude name="report.md"/>
<exclude name="input"/>
<exclude name="output"/>
<exclude name="info.txt"/>
</fileset>
<pathconvert pathsep=" " property="input.list.@{test.name}" refid="input.list">
<map from="${test.cases.dir}/@{test.name}/" to=""/>
</pathconvert>
<script language="javascript">
project.setProperty('startTime', new Date().getTime());
project.setProperty('startDate', new Date());
</script>
<echo level="error">Start: ${startDate}</echo>
<record name="@{test.name}.log" action="start" />
<if><os family="unix"/><then>
<exec dir="${test.cases.dir}/@{test.name}" executable="/bin/bash" failonerror="false"> <!-- timeout="60000" -->
<arg value="${install.dir}/Funz.sh"/>
<arg value="Run"/>
<arg value="-m ${code.name}"/>
<arg value="-if @{test.name} ${input.list.@{test.name}}"/>
<arg value="-v 11"/>
<arg value="-ad ${test.cases.dir}/@{test.name}" /> <!-- add other files given there -->
</exec>
</then><else>
<exec dir="${test.cases.dir}/@{test.name}" executable="cmd.exe" failonerror="false"> <!-- timeout="60000" -->
<arg value="${install.dir}/Funz.bat"/>
<arg value="Run"/>
<arg value="-m ${code.name}"/>
<arg value="-if @{test.name} ${input.list.@{test.name}}"/>
<arg value="-v 11"/>
<arg value="-ad ${test.cases.dir}/@{test.name}" /> <!-- add other files given there -->
</exec>
</else></if>
<record name="@{test.name}.log" action="stop"/>
<script language="javascript">
project.setProperty('elapsedTime', new Date().getTime() - startTime)
</script>
<echo message=" Time: ${elapsedTime} ms"/>
</sequential>
</for>
<if><os family="unix"/><then>
<exec dir="${install.dir}" executable="/bin/bash" spawn="true" failonerror="false">
<arg value="${install.dir}/FunzDaemon_stop.sh"/>
</exec>
</then><else>
<exec dir="${install.dir}" executable="cmd.exe" spawn="true" failonerror="false">
<arg value="${install.dir}/FunzDaemon_stop.bat"/>
</exec>
</else></if>
</target>
<!-- launch tests for ascii plugin -->
<target name="test-ioplugin" depends="dist-ioplugin" >
<dirset id="tests" dir="${test.cases.dir}" includes="*"/>
<pathconvert pathsep=" " property="tests.list" refid="tests">
<map from="${test.cases.dir}/" to=""/>
</pathconvert>
<java dir="${test.cases.dir}" classpathref="test.classpath"
classname="org.funz.ioplugin.BasicIOPlugin" fork="true" failonerror="true" >
<assertions>
<enable/>
</assertions>
<arg value="file:${ioplugin.dir}/${code.name}.ioplugin" />
<arg line="${tests.list}" />
</java>
</target>
<!-- launch tests for jar plugin -->
<target name="test-iopluginjar" depends="dist-iopluginjar" >
<dirset id="tests" dir="${test.cases.dir}" includes="*"/>
<pathconvert pathsep=" " property="tests.list" refid="tests">
<map from="${test.cases.dir}/" to=""/>
</pathconvert>
<java dir="${test.cases.dir}" classpathref="test.classpath"
classname="org.funz.ioplugin.ExtendedIOPlugin" fork="true" failonerror="true" >
<sysproperty key="app.home" value="${dist.dir}"/> <!-- setup root dir for static dependencies (eg. jar) -->
<assertions>
<enable/>
</assertions>
<sysproperty key="app.home" value="${dist.dir}"/> <!-- setup root dir for static dependencies (eg. jar) -->
<arg value="org.funz.${code.name}.${code.name}IOPlugin" />
<arg line="${tests.list}" />
</java>
</target>
<target name="read-output-tests" depends="install">
<dirset id="tests" dir="${test.cases.dir}" includes="*"/>
<pathconvert pathsep="${line.separator}" property="tests.list" refid="tests">
<map from="${test.cases.dir}/" to=""/>
</pathconvert>
<for list="${tests.list}" param="test.name" delimiter="${line.separator}">
<sequential>
<echo message="========================================="/>
<echo message="============= @{test.name} ============="/>
<local name="current.time"/>
<tstamp>
<format property="current.time" pattern="hh:mm:ss" />
</tstamp>
<echo message="============ ${current.time} ============"/>
<echo message="========================================="/>
<!-- create input files list -->
<fileset id="input.list" dir="${test.cases.dir}/@{test.name}/input" casesensitive="yes">
<filename name="*"/>
<filename name="**"/>
</fileset>
<pathconvert pathsep=" " property="input.list.@{test.name}" refid="input.list">
<map from="${test.cases.dir}/@{test.name}/" to=""/>
</pathconvert>
<script language="javascript">
project.setProperty('startTime', new Date().getTime());
project.setProperty('startDate', new Date());
</script>
<echo level="error">Start: ${startDate}</echo>
<record name="@{test.name}.log" action="start" />
<if><os family="unix"/><then>
<exec dir="${test.cases.dir}/@{test.name}" executable="/bin/bash" failonerror="false" timeout="60000">
<arg value="${install.dir}/Funz.sh"/>
<arg value="ReadOutput"/>
<arg value="-m ${code.name}"/>
<arg value="-if ${input.list.@{test.name}} -od output" />
</exec>
</then><else>
<exec dir="${test.cases.dir}/@{test.name}" executable="cmd.exe" failonerror="false" timeout="60000">
<arg value="${install.dir}/Funz.bat"/>
<arg value="ReadOutput"/>
<arg value="-m ${code.name}"/>
<arg value="-if ${input.list.@{test.name}} -od output" />
</exec>
</else></if>
<record name="@{test.name}.log" action="stop"/>
<script language="javascript">
project.setProperty('elapsedTime', new Date().getTime() - startTime)
</script>
<echo message=" Time: ${elapsedTime} ms"/>
</sequential>
</for>
</target>
<target name="parse-input-tests" depends="install">
<dirset id="tests" dir="${test.cases.dir}" includes="*"/>
<pathconvert pathsep="${line.separator}" property="tests.list" refid="tests">
<map from="${test.cases.dir}/" to=""/>
</pathconvert>
<for list="${tests.list}" param="test.name" delimiter="${line.separator}">
<sequential>
<echo message="========================================="/>
<echo message="============= @{test.name} ============="/>
<local name="current.time"/>
<tstamp>
<format property="current.time" pattern="hh:mm:ss" />
</tstamp>
<echo message="============ ${current.time} ============"/>
<echo message="========================================="/>
<!-- create input files list -->
<fileset id="input.list" dir="${test.cases.dir}/@{test.name}/input" casesensitive="yes">
<filename name="*"/>
<filename name="**"/>
</fileset>
<pathconvert pathsep=" " property="input.list.@{test.name}" refid="input.list">
<map from="${test.cases.dir}/@{test.name}/" to=""/>
</pathconvert>
<script language="javascript">
project.setProperty('startTime', new Date().getTime());
project.setProperty('startDate', new Date());
</script>
<echo level="error">Start: ${startDate}</echo>
<record name="@{test.name}.log" action="start" />
<if><os family="unix"/><then>
<exec dir="${test.cases.dir}/@{test.name}" executable="/bin/bash" failonerror="false" timeout="10000">
<arg value="${install.dir}/Funz.sh"/>
<arg value="ParseInput"/>
<arg value="-m ${code.name}"/>
<arg value="-if ${input.list.@{test.name}}" />
</exec>
</then><else>
<exec dir="${test.cases.dir}/@{test.name}" executable="cmd.exe" failonerror="false" timeout="10000">
<arg value="${install.dir}/Funz.bat"/>
<arg value="ParseInput"/>
<arg value="-m ${code.name}"/>
<arg value="-if ${input.list.@{test.name}}" />
</exec>
</else></if>
<record name="@{test.name}.log" action="stop"/>
<script language="javascript">
project.setProperty('elapsedTime', new Date().getTime() - startTime)
</script>
<echo message=" Time: ${elapsedTime} ms"/>
</sequential>
</for>
</target>
<!-- help -->
<target name="help" description="display the help on standard output">
<echo message="help : display this help" />
<echo message="clean : clean build, dist and temp directories" />
<echo message="dist : generate the plugin distribution" />
<echo message="install : generate the Funz+plugin distribution" />
<echo message="run-reference-cases : launch cases to build reference (check carefuly the results !)" />
<echo message="parse-input-test : try to parse input for all test cases" />
<echo message="read-output-test : try to read output for all test cases" />
<echo message="test : launch the plugin's tests" />
</target>
</project>