-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathbuild.xml
More file actions
1005 lines (866 loc) · 41.9 KB
/
build.xml
File metadata and controls
1005 lines (866 loc) · 41.9 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
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
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!-- DrJava Build Script -->
<!-- This build script is based on the template located at "trunk/misc/build-template.xml"
in the DrJava Subversion repository. In general, changes made to the script should be
reflected in the template as well. -->
<project name="drjava" default="help">
<property name="readable-project-name" value="DrJava" />
<property name="src-working-dir" value="src/edu/rice/cs/drjava" />
<property name="md5-temp-name" value="classes/md5.properties" />
<property name="md5-properties-path" value="edu/rice/cs/drjava/md5.properties" />
<property name="junit-jar-to-include" value="lib/junit.jar" />
<property name="main-class" value="edu.rice.cs.drjava.DrJava" />
<!-- Properties loaded from a file -->
<property name="props" value="../ant.properties" />
<property file="${props}" />
<!-- Default settings for properties -->
<property name="test-spec" value="*" />
<property name="test-repeat" value="1" />
<property name="test-timeout" value="1440" />
<property name="test-formatter" value="oneline" />
<property name="findbugs-formatter" value="html" />
<property name="test-halt" value="false" />
<property name="force-server" value="no" />
<property name="findbugs-timeout" value="30" />
<property name="debug" value="void" />
<property name="plt.debug.log" value="${debug}" />
<property name="error" value="popup" />
<property name="plt.error.log" value="${error}" />
<property name="clean-can-fail" value="yes" />
<property name="link-source" value="no" />
<property name="drjava.test.config" value="testFiles/drjava.basic.config" />
<property environment="env" />
<property name="java-home" value="${env.JAVA_HOME}" />
<property name="findbugs-home" value="${env.FINDBUGS_HOME}" />
<property name="is-development" value="yes" /> <!-- Development or stable release -->
<property name="tag-append" value="" /> <!-- "stable", "beta", or none -->
<!-- Don't use or inherit the CLASSPATH environment variable for anything -->
<property name="build.sysclasspath" value="ignore" />
<!-- This property was added based on a tip found on the internet in response to many failing unit tests using Java 7 -->
<property name="run.jvmargs.ide" value=""/>
<!-- Extension containing various tools, including "for" and "if" -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="lib/buildlib/ant-contrib.jar"/>
<!-- fornum task, used for test-repeat -->
<taskdef name="fornum" classname="edu.rice.cs.plt.ant.ForNumTask" classpath="lib/buildlib/plt-ant.jar" onerror="report" />
<!-- For code coverage report -->
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="lib/buildlib/jacocoant.jar"/>
</taskdef>
<property name="coverage-report-dir" value="coverage_report"/>
<property name="coverage-exec" value="jacoco.exec"/>
<fileset id="libs" dir="lib" includes="*.jar" /> <!-- Only include jars that are at the top level (not in buildlib) -->
<fileset id="jrelibs" dir="${java.home}/lib" includes="*.jar" />
<echo message="libs = ${toString:libs}" />
<echo message="jrelibs = ${toString:jrelibs}" />
<fileset id="extlibs" dir="extlib" includes="*.jar" /> <!-- Copy of Java 8 ext/lib -->
<echo message="extlibs = ${toString:extlibs}" />
<!-- ************
Help Targets
************ -->
<target name="help" description="Print general build script information">
<echo message="----------------------------------------------------------------------" />
<echo message="${readable-project-name} Build Scripts" />
<echo message="----------------------------------------------------------------------" />
<echo message="Type 'ant -projecthelp' or 'ant -p' to see the list of targets." />
<echo message="Type 'ant options' to see the list of customizable options." />
<echo message="" />
<echo message="For this build file to function properly, the following environment" />
<echo message="variables may need to be defined (depending on the target invoked):" />
<echo message="PATH: The 'javac' command is used for compilation;" />
<echo message=" the 'java' command is used by default in testing/running; " />
<echo message="JAVA_HOME: Home folder of the Java JRE or JDK used for the build." />
<echo message="FINDBUGS_HOME: Location of the FindBugs installation" />
<echo message="" />
<echo message="For control over the version of Java used to run Ant, set JAVA_HOME." />
<echo message="Ant may also require ANT_HOME to be set. Note that the value of " />
<echo message="CLASSPATH will be ignored -- classes on the system class path will " />
<echo message="not be visible during the build process." />
</target>
<target name="options" description="Print the list of customizable options">
<echo message="----------------------------------------------------------------------" />
<echo message="${readable-project-name} Build Script Customizable Options" />
<echo message="----------------------------------------------------------------------" />
<echo message="The following properties control custom behavior. They may be defined " />
<echo message="on the command line ('-Dname=value'), in a properties file (named " />
<echo message="'../ant.properties' by default, and containing 'name=value' pairs on " />
<echo message="each line), or in the ANT_ARGS environment variable (using " />
<echo message="'-Dname=value')." />
<echo message="" />
<echo message="props: An external properties file (default: 'ant.properties')" />
<echo message="test-spec: A matching string for filtering the tests to be run; may be" />
<echo message=" comma-delimited to run multiple test sets" />
<echo message="test-repeat: The number of times the tests should be repeated" />
<echo message="test-timeout: A time limit (in minutes) for running a test set" />
<echo message="test-formatter: The kind of formatter to use for test results: one of" />
<echo message=" 'quiet', 'oneline', 'brief', 'plain', or 'xml'" />
<echo message=" (default: oneline)" />
<echo message="test-halt: Whether unit testing should stop after the *first* failure"/>
<echo message=" (default: no)" />
<echo message="skip-test: Define to indicate that testing should be silently skipped" />
<echo message="skip-clean: Define to indicate that cleaning should be silently skipped" />
<echo message="skip-tag: Define to indicate that tagging should be silently skipped" />
<echo message="skip-javadoc: Define to indicate that Javadocs should not be created" />
<echo message="force-server: Whether the '-server' option should always be used when" />
<echo message=" running or testing (Default: no)" />
<echo message="clean-can-fail: Whether the failure of a 'clean' operation can halt" />
<echo message=" the build (default: yes)" />
<echo message="findbugs-timeout: A time limit (in minutes) for running findbugs " />
<echo message=" (default: 30)" />
<echo message="findbugs-formatter: Generate XML ('xml') or HTML ('html') output?" />
<echo message=" (default: 'xml')" />
<echo message="debug: Type of the debug log when running or testing: one of 'stdout'," />
<echo message=" 'stderr', 'file', 'assert', 'popup', 'tree', or 'void'" />
<echo message=" (equivalent to setting the property 'plt.debug.log'; default: " />
<echo message=" void)" />
<echo message="error: Type of the error log when running or testing: one of 'stdout'," />
<echo message=" 'stderr', 'file', 'assert', 'popup', 'tree', or 'void'" />
<echo message=" (equivalent to setting the property 'plt.error.log'; default: " />
<echo message=" popup)" />
<echo message="drjava.test.config: Location of the DrJava configuration file to use" />
<echo message=" in tests (default: testFiles/drjava.basic.config)" />
</target>
<!-- ************
Build Target
************ -->
<target name="build" depends="clean, test, jar" description="Shortcut for 'clean', 'test', and 'jar'">
</target>
<!-- *************************
Source-generating Targets
************************* -->
<property name="code-status-source" value="${src-working-dir}/CodeStatus.orig" />
<property name="code-status-target" value="${src-working-dir}/CodeStatus.java" />
<property name="version-source" value="${src-working-dir}/Version.orig" />
<property name="version-target" value="${src-working-dir}/Version.java" />
<target name="generate-source" depends="resolve-development-value, resolve-version-tag"
description="Generate the CodeStatus and Version source files">
<filter token="DEVELOPMENT" value="${development-value}" />
<filter token="DATE" value="${DSTAMP}" />
<filter token="TIME" value="${TSTAMP}" />
<echo message="Processing ${code-status-source}" />
<copy file="${code-status-source}" tofile="${code-status-target}" filtering="yes" />
<echo message="Processing ${version-source}" />
<copy file="${version-source}" tofile="${version-target}" filtering="yes" />
<!-- Any additional files to be generated may be processed here -->
</target>
<!-- Matches source files that are generated. Search is relative to the base directory
(NOT "src", since "src-working-dir" is defined relative to the base). This is used
by "clean". -->
<patternset id="generated-sources">
<include name="${code-status-target}" />
<include name="${version-target}" />
<!-- Additional generated sources should be listed here -->
</patternset>
<!-- *******************
Compilation Targets
******************* -->
<!-- The following target assumes that javac resolves to a Java 8 compiler -->
<target name="compile" depends="generate-source, do-compile, copy-resources, unjar-libs"
description="Compile all source files (after generating the source)">
</target>
<target name="do-compile" depends="resolve-java-runtime, resolve-java-tools">
<echo message="Compiling src directory to classes/base and classes/test with command ${java-home}/bin/javac" />
<mkdir dir="classes/base" />
<mkdir dir="classes/test" />
<!-- Move any test classes back to base to prevent recompilation -->
<move todir="classes/base">
<fileset dir="classes/test" includes="**/*" />
</move>
<echo message="jrelibs=${toString:jrelibs}" />
<javac srcdir="src" destdir="classes/base" source="1.8" target="1.8"
bootclasspath="${java-runtime}" sourcepath="" includeAntRuntime="no"
fork="yes" memoryMaximumSize="1024M"
debug="on" optimize="off" deprecation="on" >
<classpath>
<!-- TODO: Remove this dependency on tools.jar by refactoring and moving all the dependent
debugger code into the "platform" module -->
<pathelement location="${java-tools}" />
<fileset refid="libs" />
<fileset refid="jrelibs" />
<fileset refid="extlibs" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
<!-- <pathelement location="classes/base" /> THIS directory is typically empty at the start of this step -->
</classpath>
<compilerarg value="-Xlint" />
<!-- Ignore serial warnings, because they occur for every Throwable definition (among others) -->
<compilerarg value="-Xlint:-serial" />
<!-- Use the next line to compile against other sources, ignoring any unneeded classes.
This can be useful in creating a pruned version of a jar file for the lib directory.
(You must also clear the sourcepath="" option.)
<include name="${src-working-dir}/**/*.java" /> -->
</javac>
<mkdir dir="classes/test" /> <!-- May be deleted by the previous move -->
<move todir="classes/test">
<fileset dir="classes/base">
<include name="**/*Test.class" />
<include name="**/*Test$*.class" />
<include name="**/*TestCase.class" />
<include name="**/*TestCase$*.class" />
<!-- Additional test classes should be listed here -->
</fileset>
</move>
</target>
<target name="copy-resources">
<copy todir="classes/base">
<fileset dir="src">
<include name="**/LICENSE" />
<include name="**/README" />
<include name="**/*.gif" />
<include name="**/*.png" />
<include name="**/*.jpg" />
<include name="**/*.jpeg" />
<include name="**/*.properties" />
<!-- Additional resource files should be listed here -->
</fileset>
</copy>
</target>
<target name="unjar-libs">
<antcall target="do-unjar-libs">
<param name="generate-sourcedir" value="lib" />
<param name="generate-dir" value="classes/lib" />
</antcall>
</target>
<target name="do-unjar-libs" depends="check-generate-dir-from-dir" unless="already-generated">
<echo message="Unjarring jar files in the lib directory" />
<!-- Delete "classes/lib" in case it exists (but is out of date) -->
<delete dir="classes/lib" />
<mkdir dir="classes/lib" />
<echo message="jar files are: ${toString:libs}" />
<unjar dest="classes/lib">
<fileset refid="libs" />
<patternset excludes="META-INF/**" />
</unjar>
</target>
<!-- ***************
Testing Targets
*************** -->
<target name="test" depends="compile, resolve-current-tools" unless="skip-test"
description="Run all tests (after compiling); use -Dtest-spec=... to filter">
<antcall target="iterate-tests">
<param name="test-jvm" value="java" />
<param name="test-tools" value="${current-tools}" />
</antcall>
</target>
<target name="iterate-tests" depends="resolve-test-formatter-class">
<!-- Calls do-test, unless that is overridden by the caller -->
<echo message="Executing iterate-tests" />
<property name="do-test-target" value="do-test" />
<condition property="test-iteration-message">
<not>
<equals arg1="${test-repeat}" arg2="1" />
</not>
</condition>
<condition property="test-output-to-file" value="yes" else="no">
<equals arg1="${test-formatter}" arg2="xml" />
</condition>
<!-- Repeat tests 'test-repeat' times. -->
<fornum count="${test-repeat}" param="iteration">
<sequential>
<trycatch property="test-failure" reference="test-failure-ref">
<try>
<for list="${test-spec}" param="test-filter-string-iter">
<sequential>
<limit minutes="${test-timeout}" failonerror="true">
<antcall target="${do-test-target}">
<param name="test-filter-string" value="@{test-filter-string-iter}" />
</antcall>
</limit>
</sequential>
</for>
<if>
<istrue value="${test-output-to-file}" />
<then>
<mkdir dir="testResults/@{iteration}" />
</then>
</if>
</try>
<catch>
<if>
<istrue value="${test-halt}" />
<then>
<throw refid="test-failure-ref" />
</then>
</if>
</catch>
<finally>
<if>
<istrue value="${test-output-to-file}" />
<then>
<move todir="testResults/@{iteration}">
<fileset dir="${basedir}">
<include name="TEST*" />
</fileset>
</move>
</then>
</if>
</finally>
</trycatch>
<if>
<isset property="test-iteration-message" />
<then>
<math result="iteration1" datatype="int"
operand1="@{iteration}" operation="+" operand2="1" />
<echo message="" />
<echo message="Completed test iteration ${iteration1} of ${test-repeat}" />
</then>
</if>
</sequential>
</fornum>
<!-- Handle errors where test-halt is false -->
<if>
<isset property="test-failure" />
<then>
<!-- Using 'if="test-failure"' here doesn't seem to work -->
<throw refid="test-failure-ref" />
</then>
</if>
</target>
<target name="do-test" depends="resolve-jvm-args">
<echo message="Running all tests matching '${test-filter-string}' with command '${test-jvm}', using '${junit-jar-to-include}' and '${test-tools}'" />
<jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant">
<junit haltonfailure="${test-halt}" failureproperty="test-failed"
fork="yes" forkmode="perTest" maxmemory="2G" jvm="${test-jvm}" dir="${basedir}">
<classpath>
<pathelement location="${test-tools}" />
<pathelement location="${junit-jar-to-include}" />
<pathelement location="lib/buildlib/plt-ant.jar" /> <!-- required for custom formatter -->
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
<pathelement location="classes/test" />
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<assertions>
<enable />
</assertions>
<syspropertyset>
<propertyref prefix="plt." />
<propertyref prefix="drjava." />
<!-- Add any properties that should be passed on -->
</syspropertyset>
<jvmarg line="${jvm-args}" />
<formatter classname="${test-formatter-class}" usefile="${test-output-to-file}" />
<batchtest fork="true">
<fileset dir="classes/test">
<filename name="**/*${test-filter-string}*/**" />
<filename name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<fail if="test-failed" message="One or more unit tests failed."/>
<antcall target="generate-cover" />
</target>
<target name = "generate-cover" xmlns:jacoco="antlib:org.jacoco.ant">
<jacoco:report>
<executiondata>
<file file="${coverage-exec}"/>
</executiondata>
<structure name="drjava">
<classfiles>
<fileset dir="classes/base"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="src"/>
</sourcefiles>
</structure>
<html destdir="${coverage-report-dir}"/>
</jacoco:report>
</target>
<target name="run" depends="compile" description="Run the main class (after compiling)">
<antcall target="do-run">
<param name="run-jvm" value="java" />
</antcall>
</target>
<target name="do-run" depends="resolve-jvm-args">
<echo message="Running ${main-class} with command '${run-jvm}'" />
<java classname="${main-class}" jvm="${run-jvm}" fork="yes" spawn="yes">
<classpath>
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<assertions>
<enable />
</assertions>
<syspropertyset>
<propertyref prefix="plt." />
<propertyref prefix="drjava." />
<!-- Add any properties that should be passed on -->
</syspropertyset>
<jvmarg line="${jvm-args}" />
</java>
</target>
<target name="run-jar" depends="jar" description="Run the jar file (after building it)">
<antcall target="do-run-jar">
<param name="run-jvm" value="java" />
</antcall>
</target>
<target name="do-run-jar" depends="resolve-jvm-args">
<echo message="Running ${ant.project.name}.jar with command '${run-jvm}'" />
<java jar="${ant.project.name}.jar" jvm="${run-jvm}" fork="yes" spawn="yes">
<assertions>
<enable />
</assertions>
<syspropertyset>
<propertyref prefix="plt." />
<propertyref prefix="drjava." />
<!-- Add any properties that should be passed on -->
</syspropertyset>
<jvmarg line="${jvm-args}" />
</java>
</target>
<!-- ***********
Jar Targets
*********** -->
<target name="jar" depends="compile, resolve-version-tag"
description="Create the jar file with all classes and libs (compiling first)">
<available property="junit-jar-to-include-exists" file="${junit-jar-to-include}" />
<fail message="Can't find ${junit-jar-to-include}"
unless="junit-jar-to-include-exists" />
<jar jarfile="${ant.project.name}.jar">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version-tag}" />
<!-- put the right version stamp into the jar file -->
<attribute name="Created-By" value="${java.version}"/>
</manifest>
<fileset dir="classes/lib" excludes="about.html"/>
<fileset dir="classes/base" />
<!-- Include the specified version of JUnit and rename it to junit.jar -->
<!-- <zipfileset dir="." includes="${junit-jar-to-include}" fullpath="junit.jar" /> -->
<zipfileset dir="." includes="${md5-temp-name}"
fullpath="${md5-properties-path}" />
</jar>
</target>
<target name="jar-base" depends="compile, resolve-version-tag"
description="Create the jar file without any support libs (compiling first)">
<jar jarfile="${ant.project.name}-base.jar">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version-tag}" />
<!-- put the right version stamp into the jar file -->
<attribute name="Created-By" value="${java.version}"/>
</manifest>
<fileset dir="classes/base" />
</jar>
</target>
<!-- *********************
Documentation Targets
********************* -->
<target name="javadoc" depends="generate-source, resolve-java-tools, resolve-version-tag"
description="Generate javadocs from the source folder (after generating the source)"
unless="skip-javadoc">
<antcall target="do-javadoc">
<param name="generate-sourcedir" value="src" />
<param name="generate-dir" value="docs/javadoc" />
</antcall>
</target>
<target name="do-javadoc" depends="check-generate-dir-from-dir" unless="already-generated">
<echo message="Generating javadocs" />
<delete dir="docs/javadoc" />
<mkdir dir="docs/javadoc" />
<javadoc sourcepath="src" packagenames="*" destdir="docs/javadoc" maxmemory="512M"
access="private" Use="yes" Version="yes" Author="yes" Windowtitle="${readable-project-name} API (${version-tag})" linksource="${link-source}">
<classpath>
<pathelement location="${java-tools}" />
<fileset refid="libs" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
</classpath>
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
<link href="http://junit.org/junit4/javadoc/4.12/index.html?org/junit/"/>
<link href="http://www.cs.rice.edu/~javaplt/drjava/javadoc/plt/" />
<link href="http://www.cs.rice.edu/~javaplt/drjava/javadoc/javalanglevels/" />
<link href="http://www.cs.rice.edu/~javaplt/drjava/javadoc/dynamicjava/" />
<!-- Additional external library APIs may be listed here -->
</javadoc>
</target>
<target name="findbugs" depends="assert-findbugs-exists, compile, resolve-java-tools"
description="Generate a findbugs report (after compiling)">
<taskdef name="findbugs" classpath="lib/buildlib/findbugs-ant.jar"
classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
<delete file="docs/findbugs.html" />
<mkdir dir="docs" />
<math result="findbugs-timeout-ms" datatype="int"
operand1="${findbugs-timeout}" operation="*" operand2="60000" />
<!-- Add any bug codes to ignore here -->
<property name="findbugs-excludes" value="Nm,Se,Bx,UPM,UrF,UuF,DLS" />
<property name="findbugs-excludes-match"
value="<Match><Bug code='${findbugs-excludes}'/></Match>" />
<echo file="findbugs-excludes.xml"
message="<FindBugsFilter>${findbugs-excludes-match}</FindBugsFilter>" />
<findbugs home="${findbugs-home}" output="${findbugs-formatter}" jvmargs="-Xmx512M" failOnError="true"
outputFile="docs/findbugs.${findbugs-formatter}" timeout="${findbugs-timeout-ms}"
excludeFilter="findbugs-excludes.xml">
<sourcepath path="src" />
<class location="classes/base" />
<class location="classes/test" />
<auxclasspath>
<pathelement location="${java-tools}" />
<pathelement location="classes/lib" />
<pathelement location="lib/buildlib/junit.jar" />
<pathelement location="lib/buildlib/netbeans-memory-leak-utils.jar" />
</auxclasspath>
</findbugs>
<delete file="findbugs-excludes.xml" />
</target>
<!-- *************
Clean Targets
************* -->
<target name="clean" depends="clean-intermediate, clean-coverage-report, clean-products" description="Remove all build products; the result should match the intended Subversion contents">
</target>
<target name="clean-intermediate" unless="skip-clean">
<echo message="Deleting all intermediate build products" />
<delete dir="classes" failonerror="${clean-can-fail}" />
<delete dir="benchmarkSources" failonerror="${clean-can-fail}" />
<delete dir="benchmarkResults" failonerror="${clean-can-fail}" />
<delete includeemptydirs="true" failonerror="${clean-can-fail}">
<fileset dir="testFiles">
<exclude name="**" />
<!-- Additional test output files should be listed here -->
</fileset>
<fileset dir="${basedir}">
<patternset refid="generated-sources" />
</fileset>
<fileset dir="${basedir}" defaultexcludes="no">
<include name="TEST*" />
<include name="src/**/*.class" />
<include name="findbugs-excludes.xml" />
<!-- <include name="**/*~" /> -->
<!-- Get rid of pesky OS helper files (doesn't work if defaultexcludes is "yes") -->
<include name="**/.DS_Store" />
<include name="**/Thumbs.db" />
<!-- Additional files to delete may be listed here -->
</fileset>
</delete>
</target>
<target name="clean-coverage-report" unless="skip-clean">
<echo message="Deleting all coverage report products" />
<delete dir="${coverage-report-dir}" failonerror="${clean-can-fail}" />
<delete file="${coverage-exec}"/>
</target>
<target name="clean-products" unless="skip-clean">
<echo message="Deleting all final build products" />
<delete dir="docs" failonerror="${clean-can-fail}" />
<delete dir="testResults" failonerror="${clean-can-fail}" />
<delete includeemptydirs="true" failonerror="${clean-can-fail}">
<fileset dir="${basedir}" defaultexcludes="no">
<include name="*.jar" />
<include name="*.zip" />
<include name="*.tar.gz" />
<include name="*.exe" />
</fileset>
</delete>
</target>
<!-- ***************
Release Targets
*************** -->
<target name="release-stable" description="Make a 'stable' version release">
<antcall target="release">
<param name="tag-append" value="-stable" />
<param name="is-development" value="no" />
</antcall>
</target>
<target name="release-beta" description="Make a 'beta' version release">
<antcall target="release">
<param name="tag-append" value="-beta" />
<param name="is-development" value="no" />
</antcall>
</target>
<target name="release-local-stable" description="Make a 'stable' version release without touching Subversion">
<antcall target="release">
<param name="tag-append" value="-stable" />
<param name="is-development" value="no" />
<param name="skip-tag" value="yes" />
</antcall>
</target>
<target name="release-local-beta" description="Make a 'beta' version release without touching Subversion">
<antcall target="release">
<param name="tag-append" value="-beta" />
<param name="is-development" value="no" />
<param name="skip-tag" value="yes" />
</antcall>
</target>
<target name="release-local" description="Make a development release without touching Subversion">
<antcall target="release">
<param name="skip-tag" value="yes" />
</antcall>
</target>
<target name="release"
depends="build, jar-app, javadoc-zip"
description="Make a development release">
<delete dir="${version-tag}" />
</target>
<target name="jar-app" depends="jar, assert-jar-exists, resolve-version-tag">
<echo message="Creating ${version-tag}.jar" />
<copy file="${ant.project.name}.jar" tofile="${version-tag}.jar" />
</target>
<target name="javadoc-zip" depends="javadoc, resolve-version-tag" unless="skip-javadoc">
<echo message="Creating ${version-tag}-javadoc.zip" />
<zip destfile="${version-tag}-javadoc.zip">
<zipfileset dir="docs/javadoc" prefix="${version-tag}/javadoc" />
</zip>
</target>
<!-- ********************************
Misc Occasionally-Useful Targets
******************************** -->
<patternset id="exclude-binaries">
<exclude name="**/*.jar" />
<exclude name="**/*.class" />
<exclude name="**/DrJava" />
<exclude name="**/*.png" />
<exclude name="**/*.icns" />
<exclude name="**/*.gif" />
<exclude name="**/*.jpg" />
<exclude name="**/*.jpeg" />
<!-- Additional binary types may be added here -->
</patternset>
<!-- Run a batch find-and-replace on all text files in the project.
Assumes the properties "find" and "replace" have been defined
(e.g. "ant -Dfind=foo -Dreplace=bar find-and-replace"). -->
<target name="find-and-replace" description="Batch find-and-replace (use '-Dfind=foo -Dreplace=bar')">
<replace dir="${basedir}" token="${find}" value="${replace}" summary="yes">
<patternset refid="exclude-binaries" />
</replace>
</target>
<!-- Standardize all newline character sequences.-->
<target name="fix-newlines" description="Standardize newline character sequences in all text files">
<!-- If we're in Windows, use \r\n -->
<condition property="newline-code" value="crlf">
<os family="windows" />
</condition>
<!-- Otherwise, use \n -->
<property name="newline-code" value="lf" />
<fixcrlf srcdir="${basedir}" eol="${newline-code}" fixlast="no">
<patternset refid="exclude-binaries" />
</fixcrlf>
</target>
<!-- Replace the header of each .java source file with the contents of LICENSE, delimited by
BEGIN_COPYRIGHT_BLOCK and END_COPYRIGHT_BLOCK. -->
<target name="relicense" description="Paste the contents of LICENSE in all Java source files">
<loadfile property="license" srcfile="LICENSE" />
<!-- First, add an empty block to files that don't have a license block. -->
<replaceregexp match="^package"
replace="/*BEGIN_COPYRIGHT_BLOCK* *END_COPYRIGHT_BLOCK*/${line.separator}${line.separator}package">
<fileset dir="src">
<include name="**/*.java" />
</fileset>
</replaceregexp>
<replaceregexp flags="s" match="BEGIN_COPYRIGHT_BLOCK.*END_COPYRIGHT_BLOCK"
replace="BEGIN_COPYRIGHT_BLOCK*${line.separator}${line.separator}${license}${line.separator}*END_COPYRIGHT_BLOCK">
<fileset dir="src">
<include name="**/*.java" />
</fileset>
</replaceregexp>
</target>
<!-- This generates a file md5.properties that contains
MD5 checksums for all files contained in the drjava.jar file -->
<target name="generate-md5-properties" depends="compile, resolve-version-tag">
<delete file="${basedir}/${md5-temp-name}"/>
<!-- Generate MD5 checksums for classes/lib -->
<fileset id="classes.lib.fileset" dir="classes/lib" excludes="about.html"/>
<!-- Make file names relative to classes/lib -->
<pathconvert property="classes.lib.relative" refid="classes.lib.fileset"
targetos="unix">
<map from="${basedir}/classes/lib/" to=""/>
</pathconvert>
<!-- Print file names to a text file -->
<tempfile property="classes.lib.tempfile"
suffix=".txt" prefix="classes.lib." deleteonexit="true"/>
<for list="${classes.lib.relative}" delimiter=":" param="file">
<sequential>
<echo file="${classes.lib.tempfile}" append="true"
message="@{file}${line.separator}"/>
</sequential>
</for>
<!-- Run generation program, using text file as input -->
<java classname="edu.rice.cs.util.MD5ChecksumProperties"
dir="classes/lib" fork="true">
<classpath>
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<redirector input="${classes.lib.tempfile}"/>
<arg value="${basedir}/${md5-temp-name}"/>
</java>
<delete file="${classes.lib.tempfile}"/>
<!-- Generate MD5 checksums for classes/base -->
<fileset id="classes.base.fileset" dir="classes/base"/>
<pathconvert property="classes.base.relative" refid="classes.base.fileset"
targetos="unix">
<map from="${basedir}/classes/base/" to=""/>
</pathconvert>
<tempfile property="classes.base.tempfile"
suffix=".txt" prefix="classes.base." deleteonexit="true"/>
<for list="${classes.base.relative}" delimiter=":" param="file">
<sequential>
<echo file="${classes.base.tempfile}" append="true"
message="@{file}${line.separator}"/>
</sequential>
</for>
<java classname="edu.rice.cs.util.MD5ChecksumProperties"
dir="classes/base" fork="true">
<classpath>
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<redirector input="${classes.base.tempfile}"/>
<arg value="${basedir}/${md5-temp-name}"/>
</java>
<delete file="${classes.base.tempfile}"/>
<!-- Generate MD5 checksums for lib/junit.jar -->
<tempfile property="junit.jar.tempfile"
suffix=".txt" prefix="junit.jar." deleteonexit="true"/>
<echo file="${junit.jar.tempfile}"
message="${junit-jar-to-include}"/>
<java classname="edu.rice.cs.util.MD5ChecksumProperties"
dir="${basedir}" fork="true">
<classpath>
<pathelement location="classes/base" />
<pathelement location="classes/lib" />
</classpath>
<redirector input="${junit.jar.tempfile}"/>
<arg value="${basedir}/${md5-temp-name}"/>
</java>
<delete file="${junit.jar.tempfile}"/>
<!-- rename the line in md5.properties to junit.jar=... -->
<replace file="${basedir}/${md5-temp-name}"
token="${junit-jar-to-include}"
value="junit.jar"/>
</target>
<!-- ***************************
Property-resolution Targets
*************************** -->
<target name="resolve-java-runtime">
<!-- We rely on "location" to generate a platform-specific path; note that properties
are immutable and so java-runtime will only be set the *first* time. -->
<property name="java-runtime-1" location="extlib/rt.jar" />
<available property="java-runtime" value="${java-runtime-1}" file="${java-runtime-1}" />
<property name="java-runtime-2" location="${java-home}/jre/lib/rt.jar" />
<available property="java-runtime" value="${java-runtime-2}" file="${java-runtime-2}" />
<echo message="java-runtime = ${java-runtime}" />
<fail message="Can't find rt.jar in the Java 8 home: ${java-home}" unless="java-runtime" />
</target>
<target name="resolve-java-exec">
<!-- We rely on "location" to generate a platform-specific path -->
<property name="java-exec-1" location="${java-home}/bin/java.exe" />
<condition property="java-exec" value="${java-exec-1}">
<and>
<available file="${java-exec-1}" />
<os family="windows" />
</and>
</condition>
<property name="java-exec-2" location="${java-home}/bin/java" />
<available property="java-exec" value="${java-exec-2}" file="${java-exec-2}" />
<fail message="Can't find the java executable in the Java home: ${java-home}" unless="java-exec" />
</target>
<target name="resolve-java-tools">
<property name="java-tools-1" location="extlib/tools.jar" />
<available property="java-tools" value="${java-tools-1}" file="${java-tools-1}" />
<property name="java-tools-2" location="${java-home}/lib/tools.jar" />
<available property="java-tools" value="${java-tools-2}" file="${java-tools-2}" />
<fail message="Can't find tools.jar in extlib or the Java home: ${java-home}" unless="java-tools" />
</target>
<target name="resolve-current-tools">
<property name="current-tools-1" location="extlib/tools.jar" />
<available property="current-tools" value="${current-tools-1}" file="${current-tools-1}" />
<property name="current-tools-2" location="${java.home}/lib/tools.jar" />
<available property="current-tools" value="${current-tools-2}" file="${current-tools-2}" />
<fail message="Can't find tools.jar in extib or the Java home: ${java.home}" unless="current-tools" />
</target>
<target name="assert-jar-exists">
<available property="jar-exists" file="${ant.project.name}.jar" />
<fail message="Can't find ${ant.project.name}.jar" unless="jar-exists" />
</target>
<target name="assert-findbugs-exists">
<available property="findbugs-exists" file="${findbugs-home}/lib/findbugs.jar" />
<fail message="${findbugs-home}/lib/findbugs.jar does not exist" unless="findbugs-exists" />
</target>
<target name="resolve-development-value">
<condition property="development-value" value="true">
<istrue value="${is-development}" />
</condition>
<!-- else... -->
<property name="development-value" value="false" />
</target>
<target name="resolve-jvm-args">
<condition property="jvm-args" value="-server">
<istrue value="${force-server}" />
</condition>
<!-- else... -->
<property name="jvm-args" value="" />
</target>
<target name="resolve-test-formatter-class">
<condition property="test-formatter-class"
value="edu.rice.cs.plt.ant.QuietJUnitResultFormatter">
<equals arg1="quiet" arg2="${test-formatter}" />
</condition>
<condition property="test-formatter-class"
value="edu.rice.cs.plt.ant.OneLineJUnitResultFormatter">
<equals arg1="oneline" arg2="${test-formatter}" />
</condition>
<condition property="test-formatter-class"
value="org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter">
<equals arg1="brief" arg2="${test-formatter}" />
</condition>
<condition property="test-formatter-class"
value="org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter">
<equals arg1="plain" arg2="${test-formatter}" />
</condition>
<condition property="test-formatter-class"
value="org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter">
<equals arg1="xml" arg2="${test-formatter}" />
</condition>
<!-- else... -->
<property name="test-formatter-class"
value="edu.rice.cs.plt.ant.OneLineJUnitResultFormatter" />
</target>
<target name="resolve-version-tag">
<!-- Get a timestamp based on GMT, rather than local time -->
<tstamp>
<format property="DSTAMP" pattern="yyyyMMdd" timezone="GMT" />
<format property="TSTAMP" pattern="HHmmss" timezone="GMT" />
<format property="TODAY" pattern="MMMM dd yyyy" timezone="GMT" />
</tstamp>
<property name="version-tag"
value="${ant.project.name}${tag-append}-${DSTAMP}-${TSTAMP}"/>
</target>
<!-- Sets "already-generated" if "generate-file" is more recent than "generate-sourcefile";
otherwise, the out-of-date target file is deleted (if it exists). Note that, since
properties can only be set once, this should happen underneath an "antcall". -->
<target name="check-generate-file-from-file">
<dependset>
<srcfilelist dir="${basedir}" files="${generate-sourcefile}" />
<targetfilelist dir="${basedir}" files="${generate-file}" />
</dependset>
<available file="${generate-file}" property="already-generated" />
</target>
<!-- Sets "already-generated" if "generate-file" is more recent than everything in
"generate-sourcedir"; otherwise, the out-of-date target file is deleted (if it exists).
Note that, since properties can only be set once, this should happen underneath an "antcall". -->
<target name="check-generate-file-from-dir">
<dependset>
<srcfileset dir="${generate-sourcedir}" />
<targetfilelist dir="${basedir}" files="${generate-file}" />
</dependset>
<available file="${generate-file}" property="already-generated" />
</target>
<!-- Sets "already-generated" if "generate-dir" was created (or modified) more recently
than "generate-sourcefile". Note that, since properties can only be set once, this
should happen underneath an "antcall". -->
<target name="check-generate-dir-from-file">
<uptodate property="already-generated" targetfile="${generate-dir}" srcfile="${generate-sourcefile}" />
</target>
<!-- Sets "already-generated" if "generate-dir" was created (or modified) more recently
than everything in "generate-sourcedir". Note that, since properties can only be
set once, this should happen underneath an "antcall". -->
<target name="check-generate-dir-from-dir">
<!-- Unfortunately, a bug in uptodate prevents this from working properly,
so we just have to equate *existence* with being up to date.
<uptodate property="already-generated" targetfile="${generate-dir}" >
<srcfiles dir="${generate-sourcedir}" />
</uptodate>