forked from facebook/buck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
752 lines (673 loc) · 31 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
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
<project name="buck" default="default">
<property environment="env"/>
<property name="src.dir" value="${basedir}/src" />
<property name="aosp.src.dir" value="third-party/java/aosp/src" />
<property name="test.dir" value="${basedir}/test" />
<property name="third-party.dir" value="${basedir}/third-party" />
<property name="build.dir" value="${basedir}/build" />
<property name="testrunner.classes.dir" value="${build.dir}/testrunner/classes" />
<property name="bootstrapper.src.dir" value="${src.dir}/com/facebook/buck/cli/bootstrapper/" />
<property name="bootstrapper.classes.dir" value="${build.dir}/bootstrapper/classes" />
<property name="buck.path_to_buck_py" value="${basedir}/src/com/facebook/buck/parser/buck.py" />
<property name="buck.path_to_compile_asset_catalogs_py" value="${basedir}/src/com/facebook/buck/apple/compile_asset_catalogs.py" />
<property name="buck.path_to_compile_asset_catalogs_build_phase_sh" value="${basedir}/src/com/facebook/buck/apple/compile_asset_catalogs_build_phase.sh" />
<property name="buck.logging_config_file" value="${basedir}/config/logging.properties" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="testclasses.dir" value="${build.dir}/testclasses" />
<property name="javadoc.dir" value="${build.dir}/javadoc" />
<property name="javadoc-with-android.dir" value="${build.dir}/javadoc-with-android" />
<property name="javadoc-all.dir" value="${build.dir}/javadoc-all" />
<property name="client.dir" value="third-party/nailgun" />
<property name="test.class" value="Test" />
<property name="lint.outputpath" value="${build.dir}/lint.output" />
<property name="dx.base.dir" value="${basedir}/third-party/java/dx-from-kitkat" />
<property name="dx.src.dir" value="${dx.base.dir}/src" />
<property name="dx.test.dir" value="${dx.base.dir}/tests" />
<property name="dx.etc.dir" value="${dx.base.dir}/etc" />
<property name="dx.classes.dir" value="${build.dir}/dx_classes" />
<property name="eclipse.dir" value="${basedir}/third-party/java/eclipse" />
<property name="pathlib.dir" value="${third-party.dir}/py/pathlib" />
<property name="unittest2.dir" value="${third-party.dir}/py/unittest2" />
<property name="immutables-value-standalone.jar" value="${third-party.dir}/java/immutables/value-standalone-1.0.1.jar" />
<property name="immutables.gensrc.dir" value="${build.dir}/immutables" />
<property name="immutables.gensrc.test.dir" value="${build.dir}/immutables-tests" />
<fileset dir="${third-party.dir}/java" id="buck.jars">
<include name="args4j/args4j-2.0.30.jar" />
<include name="ddmlib/ddmlib-22.5.3.jar" />
<include name="guava/guava-18.0.jar" />
<include name="ini4j/ini4j-0.5.2.jar" />
<include name="jackson/jackson-annotations-2.0.5.jar" />
<include name="jackson/jackson-core-2.0.5.jar" />
<include name="jackson/jackson-databind-2.0.5.jar" />
<include name="jsr/jsr305.jar" />
<include name="android/sdklib.jar" />
<include name="nailgun/nailgun-server-0.9.2-SNAPSHOT.jar" />
</fileset>
<fileset dir="${third-party.dir}/java" id="third-party.jars">
<include name="asm/asm-debug-all-5.0.3.jar" />
<include name="auto-service/auto-service-1.0-rc1.jar" />
<include name="aopalliance/aopalliance.jar" />
<include name="astyanax/astyanax-cassandra-1.56.38.jar" />
<include name="astyanax/astyanax-cassandra-1.56.38-javadoc.jar" />
<include name="astyanax/astyanax-cassandra-1.56.38-sources.jar" />
<include name="astyanax/astyanax-core-1.56.38.jar" />
<include name="astyanax/astyanax-thrift-1.56.38.jar" />
<include name="astyanax/cassandra-1.2.3.jar" />
<include name="astyanax/cassandra-thrift-1.2.3.jar" />
<include name="astyanax/commons-cli-1.1.jar" />
<include name="astyanax/commons-codec-1.2.jar" />
<include name="astyanax/commons-lang-2.6.jar" />
<include name="astyanax/high-scale-lib-1.1.2.jar" />
<include name="astyanax/joda-time-2.2.jar" />
<include name="astyanax/libthrift-0.7.0.jar" />
<include name="astyanax/log4j-1.2.16.jar" />
<include name="astyanax/slf4j-api-1.7.2.jar" />
<include name="astyanax/slf4j-log4j12-1.7.2.jar" />
<include name="closure-templates/soy-excluding-deps.jar" />
<include name="commons-compress/commons-compress-1.8.1.jar" />
<include name="dd-plist/dd-plist.jar" />
<include name="eclipse/org.eclipse.core.contenttype_3.4.200.v20130326-1255.jar" />
<include name="eclipse/org.eclipse.core.jobs_3.5.300.v20130429-1813.jar" />
<include name="eclipse/org.eclipse.core.resources_3.8.101.v20130717-0806.jar" />
<include name="eclipse/org.eclipse.core.runtime_3.9.100.v20131218-1515.jar" />
<include name="eclipse/org.eclipse.equinox.common_3.6.200.v20130402-1505.jar" />
<include name="eclipse/org.eclipse.equinox.preferences_3.5.100.v20130422-1538.jar" />
<include name="eclipse/org.eclipse.jdt.core_3.9.2.v20140114-1555.jar" />
<include name="eclipse/org.eclipse.osgi_3.9.1.v20140110-1610.jar" />
<include name="guice/guice-3.0.jar" />
<include name="guice/guice-assistedinject-3.0.jar" />
<include name="guice/guice-multibindings-3.0.jar" />
<include name="gson/gson-2.2.4.jar" />
<include name="icu4j/icu4j-54.1.1.jar" />
<include name="immutables/value-1.0.1.jar" />
<include name="infer-annotations/infer-annotations-1.2.jar" />
<include name="jacoco/org.jacoco.core-0.7.2.201409121644.jar" />
<include name="jacoco/org.jacoco.report-0.7.2.201409121644.jar" />
<include name="jetty/jetty-all-9.0.4.v20130625.jar" />
<include name="jetty/servlet-api.jar" />
<include name="jsr/javax.inject-1.jar" />
<include name="parboiled/parboiled-core-1.1.6.jar" />
<include name="parboiled/parboiled-java-1.1.6.jar" />
<include name="xz-java-1.3/xz-1.3.jar" />
</fileset>
<path id="classpath-no-src">
<fileset refid="buck.jars" />
<fileset refid="third-party.jars" />
<pathelement location="${classes.dir}" />
<pathelement location="${dx.classes.dir}" />
</path>
<path id="classpath">
<path refid="classpath-no-src" />
<pathelement location="${src.dir}" />
<pathelement location="${immutables.gensrc.dir}" />
</path>
<path id="junit">
<pathelement location="${third-party.dir}/java/junit/junit-4.11.jar" />
<pathelement location="${third-party.dir}/java/hamcrest/hamcrest-core-1.3.jar" />
<pathelement location="${third-party.dir}/java/hamcrest/hamcrest-library-1.3.jar" />
<pathelement location="${third-party.dir}/java/testng/testng-6.8.jar" />
</path>
<target name="clean" description="remove all generated files">
<delete dir="${build.dir}" />
</target>
<!-- Default target so that a command line build can
do more than one thing. -->
<target name="default" depends="compile, dx, client, report-generator-jar" />
<target name="checkversion">
<!-- The nio Files class was only introduced in Java 7. -->
<available property="jdk7" classname="java.nio.file.Files"/>
<fail message="Require JDK 7 or higher" unless="jdk7"/>
</target>
<target name="compile-testrunner" depends="checkversion">
<mkdir dir="${testrunner.classes.dir}" />
<javac srcdir="${src.dir}"
includes="com/facebook/buck/junit/**,src/com/facebook/buck/util/concurrent/MoreExecutors.java"
destdir="${testrunner.classes.dir}"
classpathref="junit"
debug="on"
includeAntRuntime="no"
>
<compilerarg value="-Xlint:rawtypes" />
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:serial" />
</javac>
</target>
<target name="compile-bootstrapper" depends="checkversion">
<mkdir dir="${bootstrapper.classes.dir}" />
<ecj srcdir="${bootstrapper.src.dir}"
destdir="${bootstrapper.classes.dir}"
>
<javac-params>
<include name="**/*.java"/>
</javac-params>
</ecj>
</target>
<path id="immutables-classpath">
<path refid="classpath" />
<pathelement location="${immutables-value-standalone.jar}" />
<pathelement location="${src.dir}" />
</path>
<target name="generate-immutables">
<mkdir dir="${immutables.gensrc.dir}" />
<javac srcdir="${src.dir}"
classpathref="classpath"
includeAntRuntime="no">
<src path="${aosp.src.dir}" />
<exclude name="com/facebook/buck/android/support/**" />
<exclude name="com/facebook/buck/cli/quickstart/**" />
<exclude name="com/facebook/buck/junit/**" />
<compilerarg value="-processorpath" />
<compilerarg value="${immutables-value-standalone.jar}" />
<compilerarg value="-processor" />
<compilerarg value="org.immutables.value.internal.processor.Processor" />
<compilerarg value="-proc:only" />
<compilerarg value="-s" />
<compilerarg value="${immutables.gensrc.dir}" />
</javac>
</target>
<macrodef name="ecj" description="Compile Java using the ecj compiler with strict checks.">
<attribute name="srcdir" default="${src.dir}" />
<attribute name="classpathref" default="classpath-no-src" />
<attribute name="destdir" default="${classes.dir}" />
<!--
javac-params can contain any extra parameters to the javac ant command.
include and exclude elements are automatically relative to ${src.dir}.
According to http://ant.apache.org/manual/Tasks/javac.html, the only way
to enumerate the .java inputs to javac in Ant is to set the sourcepath
to the empty string, set the srcdir to something, and use include/exclude
elements to filter things under the srcdir.
-->
<element name="javac-params" />
<sequential>
<javac srcdir="@{srcdir}"
sourcepath=""
destdir="@{destdir}"
classpathref="@{classpathref}"
debug="on"
deprecation="on"
includeAntRuntime="no"
compiler="org.eclipse.jdt.core.JDTCompilerAdapter"
>
<javac-params />
<!--
ecj does not appear to support -Werror. As suggested by
http://stackoverflow.com/a/14927725/396304, we specify an Eclipse preferences
file to ECJ with the rules we want to enforce set to error.
To see the full list of compiler options available, read the Javadoc for JavaCore at:
http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2FJavaCore.html
Apparently Eclipse refuses to publish traditional Javadoc with manageable URLs.
-->
<compilerarg line="-properties ${eclipse.dir}/org.eclipse.jdt.core.prefs" />
<compilerarg value="-Xlint:rawtypes" />
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:serial" />
<compilerarg value="-time" />
<compilerclasspath>
<pathelement location="${eclipse.dir}/org.eclipse.jdt.core_3.9.2.v20140114-1555.jar" />
<pathelement location="${eclipse.dir}/jdtCompilerAdapter.jar" />
</compilerclasspath>
</javac>
</sequential>
</macrodef>
<target name="compile"
depends="compile-testrunner, compile-bootstrapper, dx, generate-immutables"
description="compile Java source code">
<mkdir dir="${classes.dir}" />
<ecj>
<javac-params>
<!-- //src/com/facebook/buck/io:io -->
<include name="com/facebook/buck/io/PathListing.java" />
<!-- //src/com/facebook/buck/log:log -->
<include name="com/facebook/buck/log/CommandThreadAssociation.java" />
<include name="com/facebook/buck/log/CommandThreadFactory.java" />
<include name="com/facebook/buck/log/ConsoleHandler.java" />
<include name="com/facebook/buck/log/GlobalState.java" />
<include name="com/facebook/buck/log/LogConfig.java" />
<include name="com/facebook/buck/log/LogConfigPaths.java" />
<include name="com/facebook/buck/log/LogFormatter.java" />
<include name="com/facebook/buck/log/Logger.java" />
<!-- //src/com/facebook/buck/util:concurrent -->
<include name="com/facebook/buck/util/concurrent/MoreExecutors.java" />
<include name="com/facebook/buck/util/concurrent/MoreFutures.java" />
<include name="com/facebook/buck/util/concurrent/TimeSpan.java" />
<!-- //src/com/facebook/buck/util:exceptions -->
<include name="com/facebook/buck/util/ExceptionWithHumanReadableMessage.java" />
<include name="com/facebook/buck/util/HumanReadableException.java" />
<include name="com/facebook/buck/util/WatchmanWatcherException.java" />
<!-- //src/com/facebook/buck/util:io -->
<include name="com/facebook/buck/util/Ansi.java" />
<include name="com/facebook/buck/util/Console.java" />
<include name="com/facebook/buck/util/CapturingPrintStream.java" />
<include name="com/facebook/buck/util/DefaultDirectoryTraverser.java" />
<include name="com/facebook/buck/util/DirectoryTraverser.java" />
<include name="com/facebook/buck/util/DirectoryTraversal.java" />
<include name="com/facebook/buck/util/DirtyPrintStreamDecorator.java" />
<include name="com/facebook/buck/util/InputStreamConsumer.java" />
<include name="com/facebook/buck/util/MoreFiles.java" />
<include name="com/facebook/buck/util/MorePaths.java" />
<include name="com/facebook/buck/util/MorePosixFilePermissions.java" />
<include name="com/facebook/buck/util/PkillProcessManager.java" />
<include name="com/facebook/buck/util/ProcessExecutor.java" />
<include name="com/facebook/buck/util/ProcessExecutorParams.java" />
<include name="com/facebook/buck/util/ProcessManager.java" />
<include name="com/facebook/buck/util/ProjectFilesystem.java" />
<include name="com/facebook/buck/util/Threads.java" />
<include name="com/facebook/buck/util/Verbosity.java" />
<!-- //src/com/facebook/buck/util:constants -->
<include name="com/facebook/buck/util/BuckConstant.java" />
<!-- //src/com/facebook/buck/util/environment:platform -->
<include name="com/facebook/buck/util/environment/Platform.java" />
<!-- //src/com/facebook/buck/zip:stream -->
<include name="com/facebook/buck/zip/AppendingZipOutputStream.java" />
<include name="com/facebook/buck/zip/ByteIo.java" />
<include name="com/facebook/buck/zip/CentralDirectory.java" />
<include name="com/facebook/buck/zip/CustomZipOutputStream.java" />
<include name="com/facebook/buck/zip/CustomZipEntry.java" />
<include name="com/facebook/buck/zip/EntryAccounting.java" />
<include name="com/facebook/buck/zip/OverwritingZipOutputStream.java" />
<include name="com/facebook/buck/zip/ZipOutputStreams.java" />
<!-- //src/com/facebook/buck/timing:timing -->
<include name="com/facebook/buck/timing/*.java" />
</javac-params>
</ecj>
<!--
Compile code from AOSP using the default compiler.
Using ecj spits out too many warnings that are not our responsibility to fix.
-->
<javac destdir="${classes.dir}"
classpathref="classpath"
debug="on"
deprecation="on"
includeAntRuntime="no"
>
<src path="${aosp.src.dir}" />
<compilerarg value="-Xlint:rawtypes" />
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:serial" />
</javac>
<!--
Note that the inputs to this <ecj> task overlap with those from the previous
<ecj> task. It's too much work to exclude them here.
-->
<ecj>
<javac-params>
<!--
These patterns are excluded because they are compiled elsewhere
and are deliberately isolated from Buck's core.
-->
<exclude name="com/facebook/buck/android/support/**" />
<exclude name="com/facebook/buck/cli/bootstrapper/**" />
<exclude name="com/facebook/buck/cli/quickstart/**" />
<exclude name="com/facebook/buck/junit/**" />
<src path="${immutables.gensrc.dir}" />
</javac-params>
</ecj>
</target>
<fileset dir="${third-party.dir}/java" id="dx.jars">
<include name="guava/guava-18.0.jar" />
</fileset>
<path id="dx.classpath">
<fileset refid="dx.jars" />
</path>
<target name="dx">
<mkdir dir="${dx.classes.dir}" />
<javac destdir="${dx.classes.dir}"
classpathref="dx.classpath"
debug="on"
deprecation="on"
includeAntRuntime="no"
>
<src path="${dx.src.dir}" />
</javac>
<jar destfile="${build.dir}/dx.jar">
<zipfileset includes="**/*.class" src="${third-party.dir}/java/guava/guava-18.0.jar"/>
<zipfileset includes="**/*.class" src="${third-party.dir}/java/junit/junit-4.11.jar" />
<fileset dir="${dx.classes.dir}" />
<manifest>
<attribute name="Main-Class" value="com.android.dx.command.Main" />
</manifest>
</jar>
</target>
<!--
Note: two of the dx tests (the two tests for the merger) run the command
"dalvik" and expect it to be a working dalvik virtual machine.
Fulfilling this expectation is no easy task. Here's how I did it.
- Be on Linux (Dalvik doesn't build for Mac).
- Check out Android (I used ICS because I had it lying around).
- make -kj25 dalvik-host
- If you built on a remote machine, rsync "out" to where you are
developing Buck, inside of a dedicated directory called "android"
or something.
- Edit android/out/host/linux-x86/dalvik to change the log tags to
"*:w", because a spurious info message was messing up the test.
- Delete android/out/host/linux-x86/dx so the tests will use our dx.
- Run this rule as
ANDROID_BUILD_TOP=/path/to/android PATH=$PATH:$ANDROID_BUILD_TOP/out/host/linux-x86/bin ant dx-tests
-->
<target name="dx-tests" depends="dx">
<exec
failonerror="true"
dir="${dx.test.dir}"
executable="./run-all-tests">
<env key="PATH" path="${env.PATH}:${dx.etc.dir}"/>
</exec>
</target>
<target name="jar" depends="buck-jar, report-generator-jar"/>
<target name="buck-jar"
depends="compile"
description="build buck.jar"
>
<jar destfile="${build.dir}/buck.jar" update="true">
<zipfileset refid="buck.jars" />
<zipfileset refid="third-party.jars" />
<fileset dir="${src.dir}"
excludes="**/*.java, **/BUCK"
/>
<fileset dir="${classes.dir}" />
<manifest>
<attribute name="Main-Class" value="com.facebook.buck.cli.Main" />
</manifest>
</jar>
</target>
<target name="report-generator-jar" depends="compile">
<jar destfile="${build.dir}/report-generator.jar">
<zipfileset excludes="**/*SF **/*RSA" src="${third-party.dir}/java/jacoco/org.jacoco.core-0.7.2.201409121644.jar"/>
<zipfileset excludes="**/*SF **/*RSA" src="${third-party.dir}/java/jacoco/org.jacoco.report-0.7.2.201409121644.jar"/>
<zipfileset excludes="**/*SF **/*RSA" src="${third-party.dir}/java/asm/asm-debug-all-5.0.3.jar"/>
<fileset dir="${classes.dir}">
<include name="com/facebook/buck/java/ReportGenerator.class"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="com.facebook.buck.java.ReportGenerator" />
</manifest>
</jar>
</target>
<path id="tests.classpath">
<path refid="classpath" />
<fileset dir="${third-party.dir}/java">
<include name="cglib/cglib-nodep-2.2.jar" />
<include name="easymock/easymock-3.0.jar" />
<include name="hamcrest/hamcrest-core-1.3.jar" />
<include name="hamcrest/hamcrest-library-1.3.jar" />
<include name="junit/junit-4.11.jar" />
<include name="objenesis/objenesis-1.2.jar" />
</fileset>
<pathelement location="${testclasses.dir}" />
<pathelement location="${test.dir}" />
<pathelement location="${testrunner.classes.dir}" />
<pathelement location="${immutables.gensrc.dir}" />
<pathelement location="${immutables.gensrc.test.dir}" />
</path>
<target name="generate-test-immutables" depends="compile">
<mkdir dir="${immutables.gensrc.test.dir}" />
<javac srcdir="${test.dir}"
classpathref="tests.classpath"
includeAntRuntime="no">
<exclude name="**/testdata/**" />
<compilerarg value="-processorpath" />
<compilerarg value="${immutables-value-standalone.jar}" />
<compilerarg value="-processor" />
<compilerarg value="org.immutables.value.internal.processor.Processor" />
<compilerarg value="-proc:only" />
<compilerarg value="-s" />
<compilerarg value="${immutables.gensrc.test.dir}" />
</javac>
</target>
<target name="compile-tests"
depends="compile, generate-test-immutables"
>
<mkdir dir="${testclasses.dir}" />
<mkdir dir="${immutables.gensrc.dir}" />
<ecj srcdir="${test.dir}"
destdir="${testclasses.dir}"
classpathref="tests.classpath"
>
<javac-params>
<exclude name="**/testdata/**" />
</javac-params>
</ecj>
</target>
<target name="java-test"
depends="compile-tests"
description="runs the Java tests"
>
<junit failureproperty="hasFailingTests"
showoutput="true"
forkmode="perBatch"
haltonerror="on">
<sysproperty key="buck.path_to_buck_py" value="${buck.path_to_buck_py}" />
<sysproperty key="buck.path_to_compile_asset_catalogs_py" value="${buck.path_to_compile_asset_catalogs_py}" />
<sysproperty key="buck.path_to_compile_asset_catalogs_build_phase_sh" value="${buck.path_to_compile_asset_catalogs_build_phase_sh}" />
<sysproperty key="buck.logging_config_file" value="${buck.logging_config_file}" />
<sysproperty key="java.util.logging.config.class" value="com.facebook.buck.log.LogConfig" />
<!-- See DEFS for details on why this property is needed. -->
<sysproperty key="sun.zip.disableMemoryMapping" value="true" />
<formatter type="plain" usefile="false" />
<batchtest fork="yes">
<fileset dir="${test.dir}">
<!--
Do not exclude tests that start with "Abstract", as there are some tests for abstract
classes.
-->
<include name="**/*${test.class}.java" />
<exclude name="**/testdata/**" />
</fileset>
</batchtest>
<classpath refid="tests.classpath" />
</junit>
<fail if="hasFailingTests" />
</target>
<target name="py-test" description="runs the Python tests" depends="buck-py-test, class-loader-py-test, asset-catalogs-py-test, pathlib-py-test" />
<target name="buck-py-test" description="tests the BUCK parser">
<exec executable="python" failonerror="true">
<env key="PYTHONPATH" path="${pathlib.dir}" />
<arg value="src/com/facebook/buck/parser/buck_test.py" />
</exec>
</target>
<target name="class-loader-py-test" description="tests BUCK's class loader setup">
<exec executable="python" failonerror="true">
<env key="PYTHONPATH" path="${pathlib.dir}" />
<arg value="test/com/facebook/buck/cli/bootstrapper/class_loader_test.py" />
</exec>
</target>
<target name="asset-catalogs-py-test" description="tests the asset catalogs compiler">
<exec executable="python" failonerror="true">
<arg value="src/com/facebook/buck/apple/compile_asset_catalogs_test.py" />
</exec>
</target>
<target name="pathlib-py-test" description="tests pathlib.py">
<exec executable="python" failonerror="true" dir="${pathlib.dir}">
<!-- Needed on Python 2.6. -->
<env key="PYTHONPATH" path="${unittest2.dir}" />
<arg value="test_pathlib.py" />
</exec>
</target>
<path id="pmd-classpath">
<fileset dir="${basedir}/pmd" includes="*.jar" />
</path>
<!--
Runs pmd on the file(s) specified in the property "lint.files",
separated by commas. Writes output to ${lint.outputpath}.
-->
<target name="pmd-files-xml" if="lint.files">
<taskdef name="pmd"
classpathref="pmd-classpath"
classname="net.sourceforge.pmd.ant.PMDTask"
/>
<pmd failOnRuleViolation="true" rulesetfiles="pmd/rules.xml">
<ruleset>buck</ruleset>
<formatter type="xml" toFile="${lint.outputpath}" />
<fileset dir="${basedir}" includes="${lint.files}" />
</pmd>
</target>
<!--
Runs pmd on all source and test files.
-->
<target name="pmd">
<taskdef name="pmd"
classpathref="pmd-classpath"
classname="net.sourceforge.pmd.ant.PMDTask"
/>
<pmd failOnRuleViolation="true" rulesetfiles="pmd/rules.xml">
<ruleset>buck</ruleset>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${test.dir}">
<include name="**/*.java"/>
<exclude name="**/testdata/**"/>
</fileset>
</pmd>
</target>
<path id="checkstyle-classpath">
<fileset dir="${basedir}/third-party/java/checkstyle" includes="*.jar" />
</path>
<!--
Runs checkstyle on the file(s) specified in the property "lint.files",
separated by commas.
-->
<target name="checkstyle-files-xml" if="lint.files">
<taskdef resource="checkstyletask.properties"
classpathref="checkstyle-classpath"/>
<checkstyle config="checkstyle.xml">
<formatter type="xml" toFile="${lint.outputpath}" />
<fileset dir="${basedir}" includes="${lint.files}" />
</checkstyle>
</target>
<!--
Runs checkstyle on the file(s) specified in the property "lint.files",
separated by commas.
-->
<target name="checkstyle-xml">
<taskdef resource="checkstyletask.properties"
classpathref="checkstyle-classpath"/>
<checkstyle config="checkstyle.xml">
<formatter type="xml" toFile="${lint.outputpath}" />
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${test.dir}">
<include name="**/*.java"/>
<exclude name="**/testdata/**"/>
</fileset>
</checkstyle>
</target>
<!--
Runs checkstyle on all source and test files.
-->
<target name="checkstyle">
<taskdef resource="checkstyletask.properties"
classpathref="checkstyle-classpath"/>
<checkstyle config="checkstyle.xml">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
<fileset dir="${test.dir}">
<include name="**/*.java"/>
<exclude name="**/testdata/**"/>
</fileset>
<formatter type="plain"/>
</checkstyle>
</target>
<target name="lint" depends="pmd, checkstyle" />
<target name="test" depends="java-test, py-test" description="runs the unit tests" />
<macrodef name="buck-javadoc" description="generates HTML documentation for Java code">
<attribute name="destdir" />
<attribute name="classpathref" />
<attribute name="access" default="protected" />
<element name="additional-links" optional="true" />
<sequential>
<delete dir="@{destdir}" />
<mkdir dir="@{destdir}" />
<record name="@{destdir}/javadoc.log" action="start" />
<javadoc destdir="@{destdir}"
access="@{access}"
classpathref="@{classpathref}"
windowtitle="Buck"
failonerror="true"
>
<fileset dir="${src.dir}">
<include name="**/*.java" />
<exclude name="com/facebook/buck/cli/quickstart/**" />
</fileset>
<fileset dir="${immutables.gensrc.dir}" />
<link href="http://docs.oracle.com/javase/7/docs/api/" />
<link href="http://docs.guava-libraries.googlecode.com/git-history/v18.0/javadoc/"
offline="true"
packagelistloc="third-party/java/guava"/>
<!-- The latest version of the javadocs is only for 4.10 -->
<link href="https://junit-team.github.io/junit/javadoc/latest/" />
<additional-links />
</javadoc>
<record name="@{destdir}/javadoc.log" action="stop" />
</sequential>
</macrodef>
<target name="-javadoc-deps" depends="compile" />
<path id="javadoc.classpath">
<path refid="classpath" />
<!-- Buck test runner has references to JUnit and TestNG. -->
<pathelement location="${third-party.dir}/java/junit/junit-4.11.jar" />
<pathelement location="${third-party.dir}/java/testng/testng-6.8.jar" />
</path>
<target name="javadoc"
description="generates HTML documentation for Java code"
depends="-javadoc-deps">
<buck-javadoc destdir="${javadoc.dir}"
classpathref="javadoc.classpath"
>
</buck-javadoc>
</target>
<path id="javadoc-with-android.classpath">
<path refid="javadoc.classpath" />
<!-- Buck's Android support library has references to Android. -->
<pathelement location="${env.ANDROID_HOME}/platforms/android-16/android.jar" />
</path>
<macrodef name="javadoc-with-android">
<attribute name="destdir" />
<attribute name="access" />
<sequential>
<fail unless="env.ANDROID_HOME" message="ANDROID_HOME not set." />
<buck-javadoc destdir="@{destdir}"
classpathref="javadoc-with-android.classpath"
access="@{access}"
>
<additional-links>
<!--
This is the recommended way to link to Android's Javadoc.
This problem derives from Android's refusal to publish the package-list file
with their Javadoc: http://stackoverflow.com/a/2823592/396304.
Surprisingly, the generated Javadoc does link to http://d.android.com/
rather than a local file:/// URI that points to the local $ANDROID_HOME.
-->
<link offline="true" href="http://d.android.com/reference" packagelistLoc="${env.ANDROID_HOME}/docs/reference"/>
</additional-links>
</buck-javadoc>
</sequential>
</macrodef>
<target name="javadoc-with-android"
description="generates HTML documentation for Java code with links to Android"
depends="-javadoc-deps">
<javadoc-with-android destdir="${javadoc-with-android.dir}" access="protected" />
</target>
<target name="verify-javadoc"
description="verify that full Javadoc ran without errors"
depends="-javadoc-deps">
<!-- Runs javadoc with -private to catch errors in all possible docblocks. -->
<javadoc-with-android destdir="${javadoc-all.dir}" access="private" />
<exec executable="${basedir}/scripts/verify-javadoc.py" failonerror="true">
<arg value="${javadoc-all.dir}/javadoc.log" />
</exec>
</target>
<target name="travis" depends="test, verify-javadoc" />
<target name="client" description="install nailgun buckd c client (non Windows only)">
<mkdir dir="${build.dir}" />
<exec dir="${basedir}"
executable="gcc"
failonerror="true"
osfamily="unix">
<arg line="-Wall -pedantic -O3 -o ${build.dir}/ng ${client.dir}/nailgun-client/ng.c" />
</exec>
</target>
<target name="pre-checkin" depends="clean, default, compile-tests, lint"/>
<target name="all" depends="jar, test, javadoc, client" />
</project>