-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
834 lines (735 loc) · 32.8 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
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
<!--
Copyright 2009 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Author: Kai Huang
Author: Robert Bowdidge
Author: Neil Sanchala
-->
<project name="Soy" basedir="." default="jar">
<property name="java.src.dir" value="${basedir}/java/src" />
<property name="java.tests.dir" value="${basedir}/java/tests" />
<property name="java.lib.dir" value="${basedir}/java/lib" />
<property name="build.dir" value="${basedir}/build" />
<property name="soy.jar.file" value="${build.dir}/soy.jar" />
<property name="build.classes.dir" value="${build.dir}/classes" />
<property name="build.testclasses.dir" value="${build.dir}/tests" />
<property name="build.genfiles.dir" value="${build.dir}/genfiles" />
<property name="includeDebugInfo" value="true" />
<property name="javadoc.lite.dir" value="${basedir}/javadoc-lite" />
<property name="javadoc.complete.dir" value="${basedir}/javadoc-complete" />
<!-- To release a new stable version of soy, update release.stamp to 'latest' or pass
-Drelease.stamp=latest when running ant. -->
<property name="release.dir" value="${basedir}/release" />
<property name="release.stamp" value="unstable" />
<path id="classpath.path">
<fileset dir="${java.lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- Target to delete the generated files. -->
<target name="clean"
description="Deletes generated files.">
<delete dir="${build.dir}" />
</target>
<!-- Target to compile the Java source. -->
<target name="compile"
description="Compiles the Java source.">
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${build.genfiles.dir}" />
<mkdir dir="${build.genfiles.dir}/com/google/template/soy/exprparse" />
<mkdir dir="${build.genfiles.dir}/com/google/template/soy/soyparse" />
<!-- JavaCC compilation. Generated files go into the 'genfiles' directory. -->
<javacc target="${java.src.dir}/com/google/template/soy/exprparse/ExpressionParser.jj"
outputdirectory="${build.genfiles.dir}/com/google/template/soy/exprparse"
javacchome="buildtools/javacc" />
<javacc target = "${java.src.dir}/com/google/template/soy/soyparse/SoyFileParser.jj"
outputdirectory = "${build.genfiles.dir}/com/google/template/soy/soyparse"
javacchome = "buildtools/javacc" />
<javacc target = "${java.src.dir}/com/google/template/soy/soyparse/TemplateParser.jj"
outputdirectory = "${build.genfiles.dir}/com/google/template/soy/soyparse"
javacchome = "buildtools/javacc" />
<!-- Java compilation. -->
<javac srcdir="${java.src.dir}:${build.genfiles.dir}"
destdir="${build.classes.dir}"
source="1.6"
target="1.6"
includeAntRuntime="true"
debug="${includeDebugInfo}">
<classpath refid="classpath.path" />
<compilerarg value="-Werror"/> <!-- warnings become errors -->
<compilerarg value="-Xlint:deprecation"/>
</javac>
</target>
<target name="generated-soyutils"
depends="compile"
description="generates soyutils.js and soyutils_usegoog.js.">
<!-- Load a custom ANT task. -->
<taskdef name="gen.escape.directives"
classname="com.google.template.soy.jssrc.internal.GenerateSoyUtilsEscapingDirectiveCode">
<classpath>
<fileset dir="${java.lib.dir}">
<include name="*.jar" />
</fileset>
<pathelement path="${build.classes.dir}" />
</classpath>
</taskdef>
<mkdir dir="${build.dir}/javascript"/>
<gen.escape.directives>
<input path="${basedir}/javascript/soyutils.js"/>
<output path="${build.dir}/javascript/soyutils.js"/>
</gen.escape.directives>
<gen.escape.directives>
<input path="${basedir}/javascript/soyutils_usegoog.js"/>
<output path="${build.dir}/javascript/soyutils_usegoog.js"/>
<jsdefined pattern="goog.string.*"/>
<jsdefined pattern="goog.asserts.*"/>
</gen.escape.directives>
</target>
<!-- Target to create a standalone jar of all Java class files and dependencies. -->
<target name="jar"
depends="compile"
description="Creates a standalone jar of all Java class files and dependencies.">
<jar destfile="${soy.jar.file}" update="true">
<fileset dir="${build.classes.dir}" />
<zipfileset src="${java.lib.dir}/jsr305.jar" />
<zipfileset src="${java.lib.dir}/guava-10.0.1.jar" />
<zipfileset src="${java.lib.dir}/javax.inject.jar" />
<zipfileset src="${java.lib.dir}/aopalliance.jar" />
<zipfileset src="${java.lib.dir}/guice-3.0.jar" />
<zipfileset src="${java.lib.dir}/guice-multibindings-3.0.jar"
excludes="LICENSE,NOTICE" />
<zipfileset src="${java.lib.dir}/guice-assistedinject-3.0.jar"
excludes="LICENSE,NOTICE" />
<zipfileset src="${java.lib.dir}/args4j-2.0.17.jar" />
<zipfileset src="${java.lib.dir}/icu4j-4_8_1_1.jar" />
</jar>
</target>
<!-- Target to create a non-standalone jar of all Java class files, excluding dependencies. -->
<target name="jar-excluding-deps"
depends="compile"
description="Creates a non-standalone jar of all Java class files, excluding dependencies.">
<jar destfile="${build.dir}/soy-excluding-deps.jar" update="true">
<fileset dir="${build.classes.dir}" />
</jar>
</target>
<!-- Target to create a standalone executable SoyToJsSrcCompiler.jar. -->
<target name="SoyToJsSrcCompiler"
depends="jar"
description="Creates a standalone executable SoyToJsSrcCompiler.jar.">
<jar destfile="${build.dir}/SoyToJsSrcCompiler.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.SoyToJsSrcCompiler" />
</manifest>
<zipfileset src="${soy.jar.file}" />
</jar>
</target>
<!-- Target to create a standalone executable SoyParseInfoGenerator.jar. -->
<target name="SoyParseInfoGenerator"
depends="jar"
description="Creates a standalone executable SoyParseInfoGenerator.jar.">
<jar destfile="${build.dir}/SoyParseInfoGenerator.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.SoyParseInfoGenerator" />
</manifest>
<zipfileset src="${soy.jar.file}" />
</jar>
</target>
<!-- Target to create a standalone executable SoyMsgExtractor.jar. -->
<target name="SoyMsgExtractor"
depends="jar"
description="Creates a standalone executable SoyMsgExtractor.jar.">
<jar destfile="${build.dir}/SoyMsgExtractor.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.SoyMsgExtractor" />
</manifest>
<zipfileset src="${soy.jar.file}" />
</jar>
</target>
<!-- Target to create a standalone executable SoyToJavaSrcCompilerExperimental.jar. -->
<target name="SoyToJavaSrcCompilerExperimental"
depends="jar"
description="Creates a standalone executable SoyToJavaSrcCompilerExperimental.jar.">
<jar destfile="${build.dir}/SoyToJavaSrcCompilerExperimental.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.SoyToJavaSrcCompilerExperimental" />
</manifest>
<zipfileset src="${soy.jar.file}" />
</jar>
</target>
<!-- Target to create a standalone executable SoyToGoSrcCompilerExperimental.jar. -->
<target name="SoyToGoSrcCompilerExperimental"
depends="jar"
description="Creates a standalone executable SoyToGoSrcCompilerExperimental.jar.">
<jar destfile="${build.dir}/SoyToGoSrcCompilerExperimental.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.SoyToGoSrcCompilerExperimental" />
</manifest>
<zipfileset src="${soy.jar.file}" />
</jar>
</target>
<!-- Target to generate lite javadoc (for API users). -->
<target name="javadoc-lite"
depends="compile"
description="Generates lite javadoc (for API users).">
<mkdir dir="${javadoc.lite.dir}" />
<javadoc destdir="${javadoc.lite.dir}"
additionalparam="-notimestamp"
author="false"
windowtitle="Soy Lite"
link="http://java.sun.com/javase/6/docs/api/">
<packageset dir="${java.src.dir}">
<include name="com/google/template/soy" />
<include name="com/google/template/soy/data" />
<include name="com/google/template/soy/javasrc" />
<include name="com/google/template/soy/jssrc" />
<include name="com/google/template/soy/gosrc" />
<include name="com/google/template/soy/msgs" />
<include name="com/google/template/soy/parseinfo" />
<include name="com/google/template/soy/shared" />
<include name="com/google/template/soy/tofu" />
<include name="com/google/template/soy/xliffmsgplugin" />
</packageset>
<fileset dir="${java.src.dir}">
<include name="com/google/template/soy/base/SoySyntaxException.java" />
</fileset>
<classpath>
<pathelement path="${java.src.dir}" />
<pathelement path="${build.genfiles.dir}" />
<fileset dir="${java.lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
<doctitle>
<![CDATA[
<h1>Closure Templates (a.k.a. Soy)</h1>
<h4>Lite javadoc for API users.</h4>
<h5><a href="../javadoc-complete/index.html" target="_blank">(Go to complete javadoc.)</a></h5>
]]>
</doctitle>
<bottom>
<![CDATA[
<div id="footer">
<div id="footerlogo" style="float:left">
<img src="http://www.google.com/images/art.gif"
alt="Google colored balls">
</div>
<div id="copyright" style="float:left">
<p>
© 2009 Google -
<a href="http://www.google.com/privacy.html">Privacy Policy</a> -
<a href="http://www.google.com/terms_of_service.html">Terms and Conditions</a> -
<a href="http://www.google.com/about.html">About Google</a>
</p>
</div>
</div>
]]>
</bottom>
</javadoc>
</target>
<!-- Target to generate complete javadoc (for developers and plugin writers). -->
<target name="javadoc-complete"
depends="compile"
description="Generates complete javadoc (for developers and plugin writers).">
<mkdir dir="${javadoc.complete.dir}" />
<javadoc sourcepath="${java.src.dir}:${build.genfiles.dir}"
additionalparam="-notimestamp"
destdir="${javadoc.complete.dir}"
author="false"
windowtitle="Soy Complete"
link="http://java.sun.com/javase/6/docs/api/">
<classpath>
<fileset dir="${java.lib.dir}">
<include name="*.jar" />
</fileset>
</classpath>
<doctitle>
<![CDATA[
<h1>Closure Templates (a.k.a. Soy)</h1>
<h4>Complete javadoc for developers and plugin writers.</h4>
<h5><a href="../javadoc-lite/index.html" target="_blank">(Go to lite javadoc.)</a></h5>
]]>
</doctitle>
<bottom>
<![CDATA[
<div id="footer">
<div id="footerlogo" style="float:left">
<img src="http://www.google.com/images/art.gif"
alt="Google colored balls">
</div>
<div id="copyright" style="float:left">
<p>
© 2009 Google -
<a href="http://www.google.com/privacy.html">Privacy Policy</a> -
<a href="http://www.google.com/terms_of_service.html">Terms and Conditions</a> -
<a href="http://www.google.com/about.html">About Google</a>
</p>
</div>
</div>
]]>
</bottom>
</javadoc>
</target>
<!--*******************************************************************************************-->
<!-- Below are targets for the examples. -->
<property name="examples.dir" value="${basedir}/examples" />
<property name="javascript.examples.dir" value="${basedir}/javascript/examples" />
<property name="java.examples.dir" value="${basedir}/java/src/com/google/template/soy/examples" />
<property name="go.examples.dir" value="${basedir}/go/examples" />
<property name="build.examples.dir" value="${build.dir}/examples" />
<!-- Utility macro. Fails if the specified file is not available. -->
<macrodef name="AssertFileExists">
<attribute name="filename" description="Filename to look for." />
<sequential>
<fail>
<condition>
<not>
<available file="@{filename}" />
</not>
</condition>
</fail>
</sequential>
</macrodef>
<!--
Uses SoyToJsSrcCompiler to compile simple.soy.
In 'build/examples', generates the following file:
simple_generated.js
Should be same as the file in 'javascript/examples'.
-->
<target name="js-simple-example"
depends="SoyToJsSrcCompiler"
description="Uses SoyToJsSrcCompiler to compile simple.soy.">
<mkdir dir="${build.examples.dir}" />
<java jar="${build.dir}/SoyToJsSrcCompiler.jar"
fork="true" failonerror="true">
<arg value="--outputPathFormat" />
<arg value="${build.examples.dir}/{INPUT_FILE_NAME_NO_EXT}_generated.js" />
<arg value="${examples.dir}/simple.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/simple_generated.js" />
</target>
<!--
Uses SoyToJsSrcCompiler to compile simple.soy and features.soy for locales en and x-zz.
In 'build/examples', generates the following files:
simple_generated_en.js
features_generated_en.js
simple_generated_x-zz.js
features_generated_x-zz.js
Should be same as the files in 'javascript/examples'.
-->
<target name="js-features-example"
depends="SoyToJsSrcCompiler"
description="Uses SoyToJsSrcCompiler to compile simple.soy and features.soy for locales en and x-zz.">
<mkdir dir="${build.examples.dir}" />
<java jar="${build.dir}/SoyToJsSrcCompiler.jar"
fork="true" failonerror="true">
<arg value="--outputPathFormat" />
<arg value="${build.examples.dir}/{INPUT_FILE_NAME_NO_EXT}_generated_{LOCALE}.js" />
<arg value="--locales" />
<arg value="en,x-zz" />
<arg value="--messageFilePathFormat" />
<arg value="${examples.dir}/examples_translated_{LOCALE}.xlf" />
<arg value="--compileTimeGlobalsFile" />
<arg value="${javascript.examples.dir}/features-usage_globals.txt" />
<arg value="--inputPrefix" />
<arg value="${examples.dir}/" /> <!-- note the trailing slash -->
<arg value="simple.soy" />
<arg value="features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/simple_generated_en.js" />
<AssertFileExists filename="${build.examples.dir}/features_generated_en.js" />
<AssertFileExists filename="${build.examples.dir}/simple_generated_x-zz.js" />
<AssertFileExists filename="${build.examples.dir}/features_generated_x-zz.js" />
</target>
<!--
Creates an executable jar for rendering the simple examples from Java.
In 'build/examples', generates the following file:
SimpleUsage.jar
This can be executed to render the simple examples from Java:
java -jar SimpleUsage.jar
-->
<target name="java-simple-example"
depends="jar"
description="Creates an executable jar for rendering the simple examples from Java.">
<mkdir dir="${build.examples.dir}" />
<jar destfile="${build.examples.dir}/SimpleUsage.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.examples.SimpleUsage" />
</manifest>
<zipfileset src="${soy.jar.file}" />
<!-- Resources. -->
<fileset file="${examples.dir}/simple.soy" />
</jar>
<AssertFileExists filename="${build.examples.dir}/SimpleUsage.jar" />
</target>
<!--
Uses SoyParseInfoGenerator to generate parse info for features.soy.
In 'build/examples', generates the following file:
FeaturesSoyInfo.java
Should be same as the file in 'java/src/com/google/template/soy/examples'.
-->
<target name="parse-info-generation-example"
depends="SoyParseInfoGenerator"
description="Uses SoyParseInfoGenerator to generate parse info for features.soy.">
<mkdir dir="${build.examples.dir}" />
<java jar="${build.dir}/SoyParseInfoGenerator.jar"
fork="true" failonerror="true">
<arg value="--outputDirectory" />
<arg value="${build.examples.dir}" />
<arg value="--javaPackage" />
<arg value="com.google.template.soy.examples" />
<arg value="--javaClassNameSource" />
<arg value="filename" />
<arg value="${examples.dir}/features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/FeaturesSoyInfo.java" />
</target>
<!--
Creates an executable jar for rendering the features examples from Java.
In 'build/examples', generates the following file:
FeaturesUsage.jar
This can be executed to render the features examples from Java:
java -jar FeaturesUsage.jar
java -jar FeaturesUsage.jar -locale x-zz
-->
<target name="java-features-example"
depends="jar"
description="Creates an executable jar for rendering the features examples from Java.">
<mkdir dir="${build.examples.dir}" />
<jar destfile="${build.examples.dir}/FeaturesUsage.jar" update="true">
<manifest>
<attribute name="Main-Class" value="com.google.template.soy.examples.FeaturesUsage" />
</manifest>
<zipfileset src="${soy.jar.file}" />
<!-- Resources. -->
<fileset file="${examples.dir}/simple.soy" />
<fileset file="${examples.dir}/features.soy" />
<fileset file="${examples.dir}/examples_translated_en.xlf" />
<fileset file="${examples.dir}/examples_translated_x-zz.xlf" />
<fileset file="${java.examples.dir}/FeaturesUsage_globals.txt" />
</jar>
<AssertFileExists filename="${build.examples.dir}/FeaturesUsage.jar" />
</target>
<!--
Uses SoyToJsSrcCompiler to compile simple.soy.
In 'build/examples', generates the following file:
simple_generated.js
Should be same as the file in 'javascript/examples'.
-->
<target name="go-simple-example"
depends="SoyToGoSrcCompilerExperimental"
description="Uses SoyToGoSrcCompilerExperimental to compile simple.soy.">
<mkdir dir="${build.examples.dir}" />
<java jar="${build.dir}/SoyToGoSrcCompilerExperimental.jar"
fork="true" failonerror="true">
<arg value="--outputPath" />
<arg value="${build.examples.dir}/simple_generated" />
<arg value="${examples.dir}/simple.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/simple_generated/soy/examples/simple/simple.go" />
</target>
<!--
Uses SoyToGoSrcCompiler to compile simple.soy and features.soy for locales en and x-zz.
In 'build/examples', generates the following files:
simple_generated_en.js
features_generated_en.js
simple_generated_x-zz.js
features_generated_x-zz.js
Should be same as the files in 'javascript/examples'.
-->
<target name="go-features-example"
depends="SoyToGoSrcCompilerExperimental"
description="Uses SoyToGoSrcCompilerExperimental to compile simple.soy and features.soy for locales en and x-zz.">
<mkdir dir="${build.examples.dir}" />
<java jar="${build.dir}/SoyToGoSrcCompilerExperimental.jar"
fork="true" failonerror="true">
<arg value="--outputPath" />
<arg value="${build.examples.dir}/go_generated_en" />
<arg value="--messageFilePath" />
<arg value="${examples.dir}/examples_translated_en.xlf" />
<arg value="--compileTimeGlobalsFile" />
<arg value="${go.examples.dir}/features-usage_globals.txt" />
<arg value="--inputPrefix" />
<arg value="${examples.dir}/" /> <!-- note the trailing slash -->
<arg value="simple.soy" />
<arg value="features.soy" />
</java>
<java jar="${build.dir}/SoyToGoSrcCompilerExperimental.jar"
fork="true" failonerror="true">
<arg value="--outputPath" />
<arg value="${build.examples.dir}/go_generated_x-zz" />
<arg value="--messageFilePath" />
<arg value="${examples.dir}/examples_translated_x-zz.xlf" />
<arg value="--compileTimeGlobalsFile" />
<arg value="${go.examples.dir}/features-usage_globals.txt" />
<arg value="--inputPrefix" />
<arg value="${examples.dir}/" /> <!-- note the trailing slash -->
<arg value="simple.soy" />
<arg value="features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/go_generated_en/soy/examples/simple/simple.go" />
<AssertFileExists filename="${build.examples.dir}/go_generated_en/soy/examples/features/features.go" />
<AssertFileExists filename="${build.examples.dir}/go_generated_x-zz/soy/examples/simple/simple.go" />
<AssertFileExists filename="${build.examples.dir}/go_generated_x-zz/soy/examples/features/features.go" />
</target>
<!--
********************************************************************************************
Below are targets to generate release zip files, and to test that the generated binaries are
sane.
-->
<!--
Uses SoyMsgExtractor to extract messages from simple.soy and features.soy.
In 'build/examples', generates the following file:
examples_extracted.xlf
Should be same as the file in 'examples'.
-->
<target name="msg-extraction-example"
depends="SoyMsgExtractor"
description="Uses SoyMsgExtractor to extract messages from simple.soy and features.soy.">
<mkdir dir="${build.examples.dir}" />
<java jar="${build.dir}/SoyMsgExtractor.jar"
fork="true" failonerror="true">
<arg value="--outputFile" />
<arg value="${build.examples.dir}/examples_extracted.xlf" />
<arg value="--inputPrefix" />
<arg value="${examples.dir}/" /> <!-- note the trailing slash -->
<arg value="simple.soy" />
<arg value="features.soy" />
</java>
<AssertFileExists filename="${build.examples.dir}/examples_extracted.xlf" />
</target>
<!--
Runs the specified jar with no arguments, and asserts that the specified usage message was
printed.
-->
<macrodef name="RunBuiltJarAndLookForExpectedError">
<attribute name="jar" description="The jar to run and test"/>
<attribute name="expectederror" description="The error message to expect"/>
<sequential>
<!-- Run the jar and dump its output to ${@{jar}_output}. -->
<java jar="${build.dir}/@{jar}.jar"
fork="true"
failonerror="false"
errorproperty="@{jar}_output">
</java>
<!-- Look in the output for the error message we expect to see. -->
<fail message="The output of the specified jar does not include the expected error message.
${line.separator}Expected Error Substring : @{expectederror}
${line.separator}Actual Output : ${@{jar}_output}">
<condition>
<not>
<contains string="${@{jar}_output}" substring="@{expectederror}" />
</not>
</condition>
</fail>
</sequential>
</macrodef>
<target name="test-built-jars" depends="SoyToJsSrcCompiler,
SoyParseInfoGenerator,
SoyMsgExtractor,
SoyToGoSrcCompilerExperimental">
<RunBuiltJarAndLookForExpectedError
jar="SoyToJsSrcCompiler"
expectederror="Error: Option "--outputPathFormat" is required" />
<RunBuiltJarAndLookForExpectedError
jar="SoyParseInfoGenerator"
expectederror="Error: Option "--javaClassNameSource" is required" />
<RunBuiltJarAndLookForExpectedError
jar="SoyMsgExtractor"
expectederror="Error: Must provide list of Soy files." />
<RunBuiltJarAndLookForExpectedError
jar="SoyToGoSrcCompilerExperimental"
expectederror="Error: Option "--outputPath" is required" />
</target>
<!-- Runs a full build, the examples, and test-built-jars to ensure that the build is sane. -->
<target name="verification-tests"
depends="compile,
jar,
jar-excluding-deps,
SoyToJsSrcCompiler,
SoyParseInfoGenerator,
SoyMsgExtractor,
test-built-jars,
js-simple-example,
js-features-example,
java-simple-example,
parse-info-generation-example,
java-features-example,
msg-extraction-example,
test-forkless" />
<!--
Builds a set of zip files containing releaseable bundles of code. These zip files may be uploaded
to the project's Downloads area at Google Code.
-->
<target name="zips-for-release" depends="jar,
jar-excluding-deps,
generated-soyutils,
SoyMsgExtractor,
SoyParseInfoGenerator,
SoyToJsSrcCompiler,
javadoc-lite">
<mkdir dir="${release.dir}" />
<!--
Rename our three README files to README in appropriately-named directories so they can be
pulled in as just "README" in the zip files below.
-->
<copy file="for-java_jar_README.txt" tofile="${build.dir}/java/README" />
<copy file="for-javascript_jar_README.txt" tofile="${build.dir}/javascript/README" />
<copy file="for-go_jar_README.txt" tofile="${build.dir}/go/README" />
<copy file="msg-extractor_jar_README.txt" tofile="${build.dir}/msg_extractor/README" />
<!--
Zip file 1: Create a "msg-extractor" zip files.
Mapping:
COPYING ==> ./COPYING
README.msg_extractor ==> ./README
build/SoyMsgExtractor.jar ==> ./SoyMsgExtractor.jar
-->
<zip destfile="${release.dir}/closure-templates-msg-extractor-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/msg_extractor/README" />
<fileset file="${build.dir}/SoyMsgExtractor.jar" />
</zip>
<!-- Rename soy.jar and soy-excluding-deps.jar to to include a ${release.stamp} suffix. -->
<copy file="${build.dir}/soy-excluding-deps.jar"
tofile="${build.dir}/soy-excluding-deps-${release.stamp}.jar" />
<copy file="${build.dir}/soy.jar"
tofile="${build.dir}/soy-${release.stamp}.jar" />
<!--
Zip file 2.1: Make soy-src-${release.stamp}.zip containing all soy src. Note that this gets
stored in the build directory, not the release directory, because this is only released as part
of the for-java zip.
Mapping:
java/src/** ==> ./**
-->
<zip destfile="${build.dir}/soy-src-${release.stamp}.zip"
basedir="java/src" />
<!--
Zip file 2.2: Create "for-java" zip file.
Mapping:
COPYING ==> ./COPYING
README.java ==> ./README
build/soy.jar ==> ./soy-${release.stamp}.jar
build/SoyParseInfoGenerator.jar ==> ./SoyParseInfoGenerator.jar
java/lib/** ==> ./separate-jars/lib/**
javadoc-lite/** ==> ./separate-jars/javadoc/**
build/soy-excluding-deps.jar ==> ./separate-jars/soy-excluding-deps-${release.stamp}.jar
build/soy-src-${release.stamp}.zip ==> ./separate-jars/soy-src-${release.stamp}.zip
-->
<zip destfile="${release.dir}/closure-templates-for-java-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/java/README" />
<fileset file="${build.dir}/SoyParseInfoGenerator.jar" />
<fileset file="${build.dir}/soy-${release.stamp}.jar" />
<zipfileset dir="${build.dir}"
includes="soy-src-${release.stamp}.zip"
prefix="separate-jars" />
<zipfileset dir="${build.dir}"
includes="soy-excluding-deps-${release.stamp}.jar"
prefix="separate-jars" />
<zipfileset dir="java/lib" prefix="separate-jars/lib" />
<zipfileset dir="javadoc-lite" prefix="separate-jars/javadoc" />
</zip>
<!--
Zip file 3: Create "for-javascript" zip file.
Mapping:
COPYING ==> ./COPYING
README.javascript ==> ./README
build/SoyToJsSrcCompiler.jar ==> ./SoyToJsSrcCompiler.jar
build/javascript/*.js ==> ./soyutils{,_usegoog}.js
-->
<zip destfile="${release.dir}/closure-templates-for-javascript-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/javascript/README" />
<fileset file="${build.dir}/SoyToJsSrcCompiler.jar" />
<fileset dir="${build.dir}/javascript" includes="soyutils.js,soyutils_usegoog.js" />
</zip>
<!--
Zip file 4: Create "for-go" zip file.
Mapping:
COPYING ==> ./COPYING
README.java ==> ./README
build/soy.jar ==> ./soy-${release.stamp}.jar
build/SoyParseInfoGenerator.jar ==> ./SoyParseInfoGenerator.jar
java/lib/** ==> ./separate-jars/lib/**
javadoc-lite/** ==> ./separate-jars/javadoc/**
build/soy-excluding-deps.jar ==> ./separate-jars/soy-excluding-deps-${release.stamp}.jar
build/soy-src-${release.stamp}.zip ==> ./separate-jars/soy-src-${release.stamp}.zip
-->
<zip destfile="${release.dir}/closure-templates-for-go-${release.stamp}.zip">
<fileset file="COPYING" />
<fileset file="${build.dir}/go/README" />
<fileset file="${build.dir}/SoyParseInfoGenerator.jar" />
<fileset file="${build.dir}/soy-${release.stamp}.jar" />
<zipfileset dir="${build.dir}"
includes="soy-src-${release.stamp}.zip"
prefix="separate-jars" />
<zipfileset dir="${build.dir}"
includes="soy-excluding-deps-${release.stamp}.jar"
prefix="separate-jars" />
<zipfileset dir="java/lib" prefix="separate-jars/lib" />
<zipfileset dir="javadoc-lite" prefix="separate-jars/javadoc" />
</zip>
</target>
<target name="compile-tests"
depends="compile"
description="Compiles the tests.">
<mkdir dir="${build.testclasses.dir}" />
<javac srcdir="${java.tests.dir}"
destdir="${build.testclasses.dir}"
source="1.6"
target="1.6"
includeAntRuntime="false"
debug="${includeDebugInfo}">
<classpath refid="classpath.path" />
<classpath>
<pathelement location="${build.classes.dir}" />
</classpath>
</javac>
</target>
<macrodef name="testing">
<attribute name="printsummary" default="off" />
<attribute name="fork" default="off" />
<attribute name="forkmode" default="perTest" />
<sequential>
<antcall target="compile-tests" />
<junit printsummary="@{printsummary}"
fork="@{fork}"
forkmode="@{forkmode}"
showoutput="true">
<classpath refid="classpath.path" />
<classpath>
<pathelement location="${build.classes.dir}" />
<pathelement location="${build.testclasses.dir}" />
<!--
Include the test directory on the classpath so that static resources loaded via
Resources.getResource() do not need to be copied to ${build.testclasses.dir}.
-->
<pathelement location="${java.tests.dir}" />
</classpath>
<formatter type="plain" usefile="false" />
<batchtest haltonfailure="true">
<fileset dir="${build.testclasses.dir}">
<include name="**/*Test.class" />
</fileset>
</batchtest>
</junit>
</sequential>
</macrodef>
<target name="test"
description="Runs all of the tests.">
<testing printsummary="on" fork="on" forkmode="once" />
</target>
<target name="test-forkless"
description="Runs all of the tests without forking the process.">
<testing />
</target>
</project>