forked from dpalic/one-jar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
734 lines (671 loc) · 29.6 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
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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
<project name="one-jar" default="dist" basedir=".">
<!-- version number -->
<property name="one-jar.version" value="0.97" />
<!--
Additional version information inside .version file, but not encoded into file names
The final release should use -release-${time.DSTAMP}-${time.TSTAMP} as the info stamp.
-->
<tstamp prefix="time"/>
<property name="one-jar.info" value="-rc12-${time.DSTAMP}-${time.TSTAMP}" />
<property name="one-jar.dir" value="${basedir}"/>
<property name="build.dir" location="${basedir}/build" />
<property name="classes.dir" location="${build.dir}/ant" />
<import file="${one-jar.dir}/build.onejar.xml"/>
<property name="src.dir" location="${basedir}/src" />
<property name="ant.dir" location="${basedir}/ant" />
<property name="example.dir" location="${basedir}/example" />
<property name="test.dir" location="${basedir}/test" />
<property name="services.dir" location="${basedir}/services" />
<property name="sdk.dir" location="${basedir}/sdk" />
<property name="dist.dir" location="${basedir}/dist" />
<property name="jar.dir" location="${build.dir}/jars" />
<property name="test.results" value="test-results"/>
<property name="test.reports" value="test-reports"/>
<property name="test.reports.dir" value="${basedir.unix}/${test.reports}"/>
<property name="test.results.dir" value="${basedir.unix}/${test.results}"/>
<property name="one-jar-dll.dir" location="../one-jar-dll"/>
<available property="one-jar-dll.exists" file="${one-jar-dll.dir}/build.xml"/>
<property name="one-jar-guice.dir" location="../one-jar-guice"/>
<available property="one-jar-guice.exists" file="${one-jar-guice.dir}/build.xml"/>
<property name="one-jar-spring.dir" location="../one-jar-spring"/>
<available property="one-jar-spring.exists" file="${one-jar-spring.dir}/build.xml"/>
<property name="one-jar-log4j.dir" location="../one-jar-log4j"/>
<available property="one-jar-log4j.exists" file="${one-jar-log4j.dir}/build.xml"/>
<property name="one-jar-inversion.dir" location="../one-jar-inversion"/>
<available property="one-jar-inversion.exists" file="${one-jar-inversion.dir}/build.xml"/>
<property name="one-jar-args.dir" location="../one-jar-args"/>
<available property="one-jar-args.exists" file="${one-jar-args.dir}/build.xml"/>
<!-- jar files -->
<property name="boot.jar" value="${dist.dir}/one-jar-boot-${one-jar.version}.jar" />
<property name="example.jar" value="${dist.dir}/one-jar-example-${one-jar.version}.jar" />
<property name="example-ext.jar" value="${dist.dir}/one-jar-example-ext-${one-jar.version}.jar" />
<property name="main.jar" value="${jar.dir}/main/main.jar" />
<property name="util.jar" value="${jar.dir}/lib/util.jar" />
<property name="external.jar" value="${jar.dir}/expand/external.jar" />
<property name="wraploader.jar" value="${jar.dir}/detect/wrap/wraploader.jar" />
<!-- Build Control -->
<property name="optimize" value="off" />
<property name="debug" value="on" />
<property name="ant.build.javac.source" value="1.3"/>
<property name="ant.build.javac.target" value="1.2"/>
<target name="init">
<tstamp />
</target>
<!-- Make the build directories -->
<target name="mkdirs" depends="init">
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${classes.dir}/src" />
<mkdir dir="${classes.dir}/example" />
<mkdir dir="${classes.dir}/ant" />
<mkdir dir="${classes.dir}/services" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${jar.dir}" />
<mkdir dir="${jar.dir}/main" />
<mkdir dir="${jar.dir}/lib" />
<mkdir dir="${jar.dir}/expand" />
<mkdir dir="${jar.dir}/detect/wrap" />
<mkdir dir="${jar.dir}/external/wrap" />
</target>
<available file="${one-jar.ant.jar}" property="one-jar.ant.jar.available" value="true"/>
<echo>one-jar.ant.jar.available=${one-jar.ant.jar.available}</echo>
<!-- compile the source -->
<target name="compile" depends="mkdirs">
<javac destdir="${classes.dir}/ant" deprecation="off" optimize="${optimize}" debug="${debug}" includeantruntime="false">
<src path="${test.dir}" />
<include name="**/Testable.java"/>
<include name="**/Invoker.java"/>
<classpath>
<path location="${classes.dir}/src" />
</classpath>
</javac>
<javac destdir="${classes.dir}/src" deprecation="off" optimize="${optimize}" debug="${debug}" includeantruntime="false">
<src path="${src.dir}" />
</javac>
<echo file="${classes.dir}/src/.version">${one-jar.version}${one-jar.info}</echo>
<javac destdir="${classes.dir}/example" deprecation="off" optimize="${optimize}" debug="${debug}" includeantruntime="false">
<src path="${example.dir}" />
<classpath>
<path location="${classes.dir}/src" />
<path location="${classes.dir}/ant" />
</classpath>
</javac>
<javac destdir="${classes.dir}/ant" deprecation="off" optimize="${optimize}" debug="${debug}" includeantruntime="false">
<src path="${ant.dir}" />
<classpath>
<path location="${classes.dir}/src" />
</classpath>
</javac>
<javac destdir="${classes.dir}/services" deprecation="off" optimize="${optimize}" debug="${debug}" includeantruntime="false">
<src path="${services.dir}" />
<classpath>
<path location="${classes.dir}/example" />
</classpath>
</javac>
</target>
<!-- Make the jar files -->
<target name="build.main.jar" depends="init,compile,compile.tests">
<delete file="${main.jar}"/>
<jar destfile="${main.jar}" manifest="${example.dir}/main/main-manifest.mf">
<fileset dir="${classes.dir}/example">
<include name="**/example/main/**" />
<include name="**/example/util/Duplicate*" />
</fileset>
<fileset dir="${classes.dir}/test">
<include name="**/Testable*" />
</fileset>
<fileset dir="${example.dir}">
<include name="**/example/main/**" />
<include name="**/example/util/Duplicate*.java" />
</fileset>
<fileset dir="${example.dir}/main">
<include name="main-manifest.mf" />
<include name="duplicate.txt" />
<include name="index.html" />
<include name="one-jar.policy"/>
<include name="images/*" />
</fileset>
</jar>
</target>
<target name="build.util.jar" depends="init,compile">
<delete file="${util.jar}"/>
<jar destfile="${util.jar}" manifest="${example.dir}/util/util-manifest.mf">
<fileset dir="${classes.dir}/example">
<include name="**/example/util/**" />
<include name="**/example/unique/**" />
</fileset>
<fileset dir="${example.dir}">
<include name="**/example/util/**" />
<include name="**/example/unique/**" />
</fileset>
<fileset dir="${example.dir}/util">
<include name="util-manifest.mf" />
<include name="duplicate.txt" />
</fileset>
</jar>
</target>
<target name="build.external.jar">
<delete file="${external.jar}"/>
<jar destfile="${external.jar}">
<fileset dir="${classes.dir}/example">
<include name="**/example/external/**" />
</fileset>
<fileset dir="${example.dir}">
<include name="**/example/external/**" />
</fileset>
</jar>
</target>
<target name="build.wraploader.jar">
<delete file="${wraploader.jar}"/>
<jar destfile="${wraploader.jar}" manifest="${src.dir}/detectloader.mf">
<fileset dir="${classes.dir}/src">
<include name="**/Detect*" />
</fileset>
<fileset dir="${src.dir}">
<include name="**/Detect*" />
</fileset>
</jar>
</target>
<target name="build.boot.jar" depends="compile">
<delete file="${boot.jar}" />
<jar destfile="${boot.jar}" manifest="${src.dir}/boot-manifest.mf">
<fileset dir="${classes.dir}/src">
<include name=".version"/>
<include name="com/**" />
<include name="OneJar.*" />
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${src.dir}">
<include name="boot-manifest.mf" />
</fileset>
<fileset dir="${src.dir}/..">
<include name="src/OneJar.*" />
<include name="src/com/**" />
<exclude name="src/**/example/**" />
<exclude name="src/**/Detect*" />
</fileset>
<fileset dir="${basedir}">
<include name="doc/*license.txt" />
</fileset>
</jar>
</target>
<target name="build.ant.jar" depends="compile,build.boot.jar" description="Build Ant one-jar-task separately">
<copy file="${boot.jar}" tofile="${classes.dir}/ant/com/simontuffs/onejar/ant/one-jar-boot.jar" />
<delete failonerror="false" file="${dist.dir}/one-jar-ant-task-${one-jar.version}.jar"/>
<jar destfile="${dist.dir}/one-jar-ant-task-${one-jar.version}.jar">
<fileset dir="${classes.dir}/ant">
<include name="**" />
</fileset>
<fileset dir="${ant.dir}">
<exclude name="**/*.java" />
</fileset>
<fileset dir="${ant.dir}/..">
<include name="ant/**/*.java"/>
</fileset>
<fileset dir="${test.dir}/..">
<include name="test/**/Invoker.java"/>
<include name="test/**/Testable.java"/>
</fileset>
</jar>
<copy todir="${dist.dir}">
<fileset dir="${ant.dir}">
<include name="one-jar-*.xml" />
</fileset>
</copy>
</target>
<target name="build.example.jar" depends="build.boot.jar,build.main.jar,build.util.jar,build.services">
<delete file="${example.jar}" />
<jar destfile="${example.jar}" manifest="${src.dir}/example-manifest.mf">
<fileset dir="${basedir}">
<include name="doc/*license.txt" />
</fileset>
<fileset dir="${classes.dir}/src">
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${src.dir}">
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${example.dir}">
<include name="expand/**" />
<include name="file.txt" />
</fileset>
<fileset dir="${jar.dir}">
<include name="main/main.jar" />
<include name="lib/*.jar" />
</fileset>
<fileset dir="${jar.dir}/detect">
<include name="wrap/wraploader.jar" />
</fileset>
</jar>
</target>
<target name="build.example-ext.jar" depends="build.boot.jar,build.main.jar,build.util.jar,build.services,build.external.jar">
<delete file="${example-ext.jar}" />
<jar destfile="${example-ext.jar}" manifest="${src.dir}/example-manifest-external.mf">
<fileset dir="${basedir}">
<include name="doc/*license.txt" />
</fileset>
<fileset dir="${classes.dir}/src">
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${src.dir}">
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${example.dir}">
<include name="expand/**" />
<include name="file.txt" />
</fileset>
<fileset dir="${jar.dir}">
<include name="main/main.jar" />
<include name="lib/*.jar" />
<include name="expand/*.jar" />
</fileset>
<fileset dir="${jar.dir}/detect">
<include name="wrap/wraploader.jar" />
</fileset>
</jar>
</target>
<target name="build.services" depends="mkdirs">
<jar destfile="${jar.dir}/lib/english.jar">
<fileset dir="${classes.dir}">
<include name="**/services/english/**" />
</fileset>
<fileset dir="${services.dir}/english">
<include name="META-INF/**" />
</fileset>
</jar>
<jar destfile="${jar.dir}/lib/french.jar">
<fileset dir="${classes.dir}">
<include name="**/services/french/**" />
</fileset>
<fileset dir="${services.dir}/french">
<include name="META-INF/**" />
</fileset>
</jar>
<jar destfile="${jar.dir}/lib/german.jar">
<fileset dir="${classes.dir}">
<include name="**/services/german/**" />
</fileset>
<fileset dir="${services.dir}/german">
<include name="META-INF/**" />
</fileset>
</jar>
</target>
<target name="jar" depends="build.main.jar,build.util.jar,build.boot.jar,build.external.jar,build.wraploader.jar,build.example.jar,build.example-ext.jar,build.services,build.source.jar">
</target>
<!-- Build the example jar using the one-jar-macro -->
<import file="${ant.dir}/one-jar-macro.xml" optional="true" />
<target name="build.one-jar-example-macro" depends="jar">
<delete file="${dist.dir}/one-jar-example-macro-${one-jar.version}.jar" />
<one-jar-macro destfile="${dist.dir}/one-jar-example-macro-${one-jar.version}.jar" manifest="${src.dir}/example-manifest.mf" mainmanifest="${example.dir}/main/main-manifest.mf" onejarboot="${boot.jar}">
<top>
<fileset dir="${src.dir}">
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${example.dir}">
<include name="expand/**" />
<include name="file.txt" />
</fileset>
</top>
<main>
<fileset dir="${classes.dir}/example">
<include name="**/example/main/**" />
<include name="**/example/util/Duplicate*" />
</fileset>
<fileset dir="${classes.dir}/test">
<include name="**/Testable*" />
</fileset>
<fileset dir="${example.dir}">
<include name="**/example/main/**" />
<include name="**/example/util/Duplicate*" />
</fileset>
<fileset dir="${example.dir}/main">
<include name="main-manifest.mf" />
<include name="duplicate.txt" />
<include name="index.html" />
<include name="one-jar.policy"/>
<include name="images/*" />
</fileset>
</main>
<lib>
<fileset file="${jar.dir}/lib/**" />
</lib>
<wrap>
<fileset file="${jar.dir}/detect/wrap/**" />
</wrap>
</one-jar-macro>
</target>
<!-- Build the example jar using the one-jar task. Identical syntax to the
one-jar-macro, but creates the target jar without using the filesystem
for intermediates.
-->
<import file="${dist.dir}/one-jar-ant-task.xml" optional="true" />
<target name="build.one-jar-example-task" depends="build.boot.jar,build.example.jar">
<delete file="dist/one-jar-example-task-${one-jar.version}.jar" />
<echo>
If this task fails, it is probably because the OneJarTask class has changed underneath us.
Re-execute the Ant command.
</echo>
<!-- Pick libraries out of configured path -->
<path id="libs">
<fileset file="${jar.dir}/lib/**" />
</path>
<one-jar destfile="dist/one-jar-example-task-${one-jar.version}.jar" manifest="${src.dir}/example-manifest.mf">
<fileset dir="${src.dir}">
<exclude name="**/Detect*" />
</fileset>
<fileset dir="${basedir}">
<include name="doc/*license.txt" />
</fileset>
<fileset dir="${example.dir}">
<include name="expand/**" />
<include name="file.txt" />
</fileset>
<main manifest="${example.dir}/main/main-manifest.mf">
<!-- Construct main.jar from classes and source code -->
<fileset dir="${classes.dir}/example">
<include name="**/example/main/**" />
<include name="**/example/util/Duplicate*" />
</fileset>
<fileset dir="${example.dir}">
<include name="**/example/main/**" />
<include name="**/example/util/Duplicate*" />
</fileset>
<fileset dir="${classes.dir}/test">
<include name="**/Testable*" />
</fileset>
<fileset dir="${example.dir}/main">
<include name="main-manifest.mf" />
<include name="duplicate.txt" />
<include name="index.html" />
<include name="one-jar.policy"/>
<include name="images/*" />
</fileset>
</main>
<lib>
<!-- Pre-built library jars -->
<!-- <fileset file="${jar.dir}/lib/**" /> -->
<!-- Use classpath -->
<classpath refid="libs"/>
</lib>
<wrap>
<!-- Class-loader wrapper -->
<fileset file="${jar.dir}/detect/wrap/**" />
</wrap>
</one-jar>
</target>
<!-- Make the distribution -->
<target name="dist" depends="compile,jar,build.one-jar-example-macro,build.one-jar-example-task,build.sdk,build.one-jar-dll">
<copy file="${ant.dir}/one-jar-macro.xml" todir="${dist.dir}" />
<copy file="${ant.dir}/one-jar-ant-task.xml" todir="${dist.dir}" />
</target>
<!--
A one-jar file which contains the boot sources, expands itself after confirmation.
Uses expansion confirmation.
-->
<target name="build.source.jar">
<one-jar destfile="dist/one-jar-source-${one-jar.version}.jar">
<manifest>
<attribute name="Main-Class" value="com.simontuffs.onejar.Boot"/>
<attribute name="One-Jar-Expand" value="src"/>
<attribute name="One-Jar-Expand-Dir" value="./one-jar-src-${one-jar.version}"/>
<attribute name="One-Jar-Show-Expand" value="true"/>
<attribute name="One-Jar-Confirm-Expand" value="true"/>
</manifest>
<main/>
<fileset dir="${basedir}">
<include name="src/**"/>
</fileset>
</one-jar>
</target>
<target name="build.sdk">
<copy file="${ant.dir}/one-jar-ant-task.xml" todir="${sdk.dir}" />
<copy file="${dist.dir}/one-jar-ant-task-${one-jar.version}.jar" todir="${sdk.dir}" />
<ant antfile="sdk/build.xml" inheritall="false">
<property name="one-jar.version" value="${one-jar.version}"/>
</ant>
<copy file="${sdk.dir}/one-jar-sdk-${one-jar.version}.jar" todir="${dist.dir}"/>
</target>
<!-- Two part build of one-jar -->
<target name="build.source.jar.filesetmanifest">
<one-jar destfile="dist/one-jar-source-fsm-${one-jar.version}.jar">
<manifest>
<attribute name="Main-Class" value="com.simontuffs.onejar.Boot"/>
</manifest>
<main/>
</one-jar>
<one-jar destfile="dist/one-jar-source-fsm-${one-jar.version}.jar" update="true" filesetmanifest="mergewithoutmain">
<main/>
<manifest>
<attribute name="One-Jar-Expand" value="src"/>
<attribute name="One-Jar-Expand-Dir" value="./one-jar-src-${one-jar.version}"/>
<attribute name="One-Jar-Show-Expand" value="true"/>
<attribute name="One-Jar-Confirm-Expand" value="true"/>
</manifest>
<fileset dir="${basedir}">
<include name="src/**"/>
</fileset>
</one-jar>
</target>
<target name="build.one-jar-dll" if="one-jar-dll.exists">
<ant antfile="${one-jar-dll.dir}/build.xml" inheritall="false">
</ant>
<echo>copy to ${dist.dir}</echo>
<copy file="${one-jar-dll.dir}/dist/one-jar-dll-${one-jar.version}.jar" todir="${dist.dir}"/>
</target>
<property name="formatter" value="xml" />
<target name="compile.tests">
<fail unless="one-jar.ant.jar.available" message="Run the build.ant.jar task first"/>
<mkdir dir="${classes.dir}/test" />
<mkdir dir="${test.results.dir}" />
<javac destdir="${classes.dir}/test" debug="on" deprecation="off" optimize="off" includeantruntime="false">
<src path="${test.dir}" />
<classpath>
<fileset file="${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<path refid="one-jar.libraries"/>
<path refid="one-jar.test.libraries"/>
</classpath>
</javac>
</target>
<!-- Test the distribution -->
<target name="test" depends="dist,compile.tests" description="Run all regression tests">
<delete dir="${test.results.dir}"/>
<antcall target="test.one-jar-example" />
<antcall target="test.one-jar-example-task" />
<antcall target="test.one-jar-example-macro" />
<antcall target="test.one-jar-example-ext" />
<antcall target="test.one-jar-example-secure" />
<antcall target="test.one-jar-dll" />
<antcall target="test.one-jar-guice" />
<antcall target="test.one-jar-spring" />
<antcall target="test.one-jar-log4j" />
<antcall target="test.one-jar-inversion" />
<antcall target="test.one-jar-args" />
<antcall target="test.command-line" />
<antcall target="test.ant.taskdefs" />
<antcall target="junit.report" />
</target>
<target name="test.one-jar-example" depends="dist,compile.tests">
<echo>********** one-jar-example-${one-jar.version}.jar</echo>
<junit fork="yes" showoutput="no" printsummary="yes">
<jvmarg value="-Done-jar.verbose=true" />
<jvmarg value="-Done-jar.jarname=${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<sysproperty key="one-jar.test.external" value="true"/>
<sysproperty key="one-jar.class.path" value="${external.jar}|external/subdir"/>
<classpath>
<fileset file="${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<path refid="one-jar.test.libraries"/>
</classpath>
<test name="com.simontuffs.onejar.test.SelfTest" todir="${test.results.dir}" outfile="one-jar-SelfTest" />
<formatter type="${formatter}" usefile="yes" />
</junit>
</target>
<target name="test.one-jar-example-task" depends="dist,compile.tests">
<echo>********** one-jar-example-task-${one-jar.version}.jar</echo>
<junit fork="yes" showoutput="no" printsummary="yes">
<jvmarg value="-Done-jar.verbose=true" />
<jvmarg value="-Done-jar.jarname=${basedir}/dist/one-jar-example-task-${one-jar.version}.jar" />
<classpath>
<fileset file="${basedir}/dist/one-jar-example-task-${one-jar.version}.jar" />
<path refid="one-jar.test.libraries"/>
</classpath>
<test name="com.simontuffs.onejar.test.SelfTest$Task" todir="${test.results.dir}" outfile="one-jar-SelfTest-task" />
<formatter type="${formatter}" usefile="yes" />
</junit>
</target>
<target name="test.one-jar-example-macro" depends="dist,compile.tests">
<echo>********** one-jar-example-macro-${one-jar.version}.jar</echo>
<junit fork="yes" showoutput="no" printsummary="yes">
<jvmarg value="-Done-jar.verbose=true" />
<jvmarg value="-Done-jar.jarname=${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<classpath>
<fileset file="${basedir}/dist/one-jar-example-macro-${one-jar.version}.jar" />
<path refid="one-jar.test.libraries"/>
</classpath>
<test name="com.simontuffs.onejar.test.SelfTest$Macro" todir="${test.results.dir}" outfile="one-jar-SelfTest-macro" />
<formatter type="${formatter}" usefile="yes" />
</junit>
</target>
<target name="test.one-jar-example-ext" depends="dist,compile.tests">
<echo>********** one-jar-example-ext-${one-jar.version}.jar</echo>
<junit dir="dist" fork="yes" showoutput="no" printsummary="yes">
<jvmarg value="-Done-jar.verbose=true" />
<jvmarg value="-Done-jar.jarname=${basedir}/dist/one-jar-example-ext-${one-jar.version}.jar" />
<jvmarg value="-Done-jar.class.path=expand/subdir"/>
<classpath>
<fileset file="${basedir}/dist/one-jar-example-ext-${one-jar.version}.jar" />
<path refid="one-jar.test.libraries"/>
</classpath>
<test name="com.simontuffs.onejar.test.SelfTestExternal" todir="${test.results.dir}" outfile="one-jar-SelfTestExt" />
<formatter type="${formatter}" usefile="yes" />
</junit>
</target>
<target name="test.one-jar-example-secure" depends="dist,compile.tests">
<echo>********** one-jar-example-secure-${one-jar.version}.jar</echo>
<junit dir="dist" fork="yes" showoutput="no" printsummary="yes">
<jvmarg value="-Done-jar.verbose=true" />
<jvmarg value="-Done-jar.jarname=${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<classpath>
<fileset file="${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<path refid="one-jar.test.libraries"/>
</classpath>
<test name="com.simontuffs.onejar.test.SelfTestSecure" todir="${test.results.dir}" outfile="one-jar-SelfTestSecure" />
<formatter type="${formatter}" usefile="yes" />
</junit>
</target>
<target name="test.command-line" depends="dist,compile.tests">
<echo>********** command-line tests</echo>
<junit fork="yes" showoutput="no" printsummary="yes">
<jvmarg value="-Done-jar.verbose=true" />
<jvmarg value="-Done-jar.jarname=${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<classpath>
<fileset file="${basedir}/dist/one-jar-example-${one-jar.version}.jar" />
<path refid="one-jar.test.libraries"/>
</classpath>
<test name="com.simontuffs.onejar.test.CommandLine" todir="${test.results.dir}" outfile="one-jar-SelfTest-commandline" />
<formatter type="${formatter}" usefile="yes" />
</junit>
</target>
<target name="test.one-jar-dll" if="one-jar-dll.exists">
<ant antfile="${one-jar-dll.dir}/build.xml" target="test" inheritall="false">
<property name="test.results.dir" location="${test.results.dir}"/>
</ant>
</target>
<target name="test.one-jar-guice" if="one-jar-guice.exists">
<ant antfile="${one-jar-guice.dir}/build.xml" target="test" inheritall="false">
<property name="test.results.dir" location="${test.results.dir}"/>
</ant>
</target>
<target name="test.one-jar-spring" if="one-jar-spring.exists">
<ant antfile="${one-jar-spring.dir}/build.xml" target="test" inheritall="false">
<property name="test.results.dir" location="${test.results.dir}"/>
</ant>
</target>
<target name="test.one-jar-log4j" if="one-jar-log4j.exists">
<ant antfile="${one-jar-log4j.dir}/build.xml" target="test" inheritall="false">
<property name="test.results.dir" location="${test.results.dir}"/>
</ant>
</target>
<target name="test.one-jar-inversion" if="one-jar-inversion.exists">
<ant antfile="${one-jar-inversion.dir}/build.xml" target="test" inheritall="false">
<property name="test.results.dir" location="${test.results.dir}"/>
</ant>
</target>
<target name="test.one-jar-args" if="one-jar-args.exists">
<ant antfile="${one-jar-args.dir}/build.xml" target="test" inheritall="false">
<property name="test.results.dir" location="${test.results.dir}"/>
</ant>
</target>
<target name="test.ant.taskdefs" depends="test.ant.taskdef.1,test.ant.taskdef.2,test.ant.taskdef.3">
</target>
<!-- Test the Ant one-jar taskdef -->
<target name="test.ant.taskdef.1">
<mkdir dir="${test.results.dir}"/>
<!-- Degenerate One-JAR -->
<one-jar destfile="${test.results.dir}/ant-taskdef-1.jar">
<main/>
</one-jar>
<delete dir="tmp/ant-taskdef-1"/>
<mkdir dir="tmp/ant-taskdef-1"/>
<java fork="true" dir="tmp/ant-taskdef-1" jar="${test.results.dir}/ant-taskdef-1.jar" failonerror="true">
<arg line="--one-jar-help"/>
</java>
</target>
<target name="test.ant.taskdef.2">
<one-jar destfile="${test.results.dir}/ant-taskdef-2.jar">
<manifest>
<!-- Remember, One-Jar-Expand is a comma-separated prefix list for path filtering -->
<attribute name="One-Jar-Expand" value=""/>
<attribute name="One-Jar-Expand-Dir" value="tmp"/>
<attribute name="One-Jar-Show-Expand" value="true"/>
<attribute name="One-Jar-Confirm-Expand" value="true"/>
</manifest>
<main/>
</one-jar>
<delete dir="tmp/ant-taskdef-2"/>
<mkdir dir="tmp/ant-taskdef-2"/>
<!-- <chmod dir="tmp" perm="444"/> -->
<!-- Override the manifest setting for One-Jar-Expand-Dir" -->
<java fork="true" dir="tmp/ant-taskdef-2" jar="${test.results.dir}/ant-taskdef-2.jar" failonerror="true" inputstring="y">
<sysproperty key="one-jar.expand.dir" value="."/>
</java>
<available property="test.ant.taskdef.2" file="tmp/ant-taskdef-2/OneJar.class"/>
<fail unless="test.ant.taskdef.2"/>
</target>
<target name="test.ant.taskdef.3">
<!-- Create and use a manifest file -->
<manifest file="${test.results.dir}/manifest.mf">
<!-- Remember, One-Jar-Expand is a comma-separated prefix list for path filtering -->
<attribute name="One-Jar-Expand" value=""/>
<attribute name="One-Jar-Expand-Dir" value="tmp"/>
<attribute name="One-Jar-Show-Expand" value="true"/>
<attribute name="One-Jar-Confirm-Expand" value="true"/>
</manifest>
<one-jar destfile="${test.results.dir}/ant-taskdef-3.jar" manifest="${test.results.dir}/manifest.mf">
<main/>
</one-jar>
<delete dir="tmp/ant-taskdef-3"/>
<mkdir dir="tmp/ant-taskdef-3"/>
<java fork="true" dir="tmp/ant-taskdef-3" jar="${test.results.dir}/ant-taskdef-3.jar" failonerror="true" inputstring="y"/>
<available property="test.ant.taskdef.3" file="tmp/ant-taskdef-3/tmp/OneJar.class"/>
<fail unless="test.ant.taskdef.3"/>
</target>
<target name="clean" depends="init" description="clean tree (including dist)">
<!-- delete everything in the classes and jars dir -->
<delete dir="${classes.dir}" />
<delete dir="${jar.dir}" />
<delete dir="expand" />
<delete deleteonexit="true">
<fileset dir="${dist.dir}">
<exclude name="CVS/**"/>
<exclude name=".cvsignore"/>
<exclude name="*.xml"/>
</fileset>
</delete>
</target>
<target name="clean.compile" depends="init">
<!-- delete everything in the classes dir -->
<delete dir="${classes.dir}" />
<antcall target="mkdirs"/>
<antcall target="compile"/>
</target>
</project>