forked from google/closure-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
402 lines (361 loc) · 14.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
<!--
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.
-->
<project name="compiler" basedir="." default="jar">
<!--
Use -Dtest.class to change what tests are run on the command-line.
i.e., -Dtest.class=CommandLineRunnerTest will run just that test class.
-->
<property name="test.class" value="*Test"/>
<!-- Use -Dtest.method in conjunction with the one-test rule. -->
<property name="test.method" value=""/>
<!--
Use -Dtest.fork to specify whether or not to fork the process.
Some machines run better with forking turned off.
-->
<property name="test.fork" value="true"/>
<!-- Force java 7 -->
<property name="ant.build.javac.source" value="1.7" />
<property name="ant.build.javac.target" value="1.7" />
<!-- define other variables -->
<property name="javac.debug" value="on" />
<property name="src.dir" value="${basedir}/src" />
<property name="gen.dir" value="${basedir}/gen" />
<property name="test.dir" value="${basedir}/test" />
<property name="externs.dir" value="${basedir}/externs" />
<!-- To workaround Ant limitation on overriding properties set on the
command-line, define a unique property to allow "build.dir" to
be change without forcing the build of Rhino to the same directory.
-->
<property name="closure.build.dir" value="${basedir}/build" />
<property name="build.dir" value="${closure.build.dir}" />
<property name="buildlib.dir" value="${build.dir}/lib" />
<property name="classes.dir" value="${build.dir}/classes" />
<property name="testClasses.dir" value="${build.dir}/test" />
<property name="javadoc.dir" value="${build.dir}/javadoc" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="tools.dir" value="${basedir}/tools" />
<property name="compiler-jarfile"
value="${build.dir}/${ant.project.name}.jar" />
<property name="num-fuzz-tests" value="10000"/>
<property name="webservice.dir" value="${basedir}/src/com/google/javascript/jscomp/webservice" />
<property name="webservice-classes.dir" value = "${build.dir}/webservice-classes" />
<property name="webservice-jarfile" value="${build.dir}/webservice.jar" />
<property name="refasterjs.dir" value="${basedir}/src/com/google/javascript/refactoring" />
<property name="refasterjs-classes.dir" value = "${build.dir}/refasterjs-classes" />
<property name="refasterjs-jarfile" value="${build.dir}/refasterjs.jar" />
<!-- The following server is used to deploy releases to maven central via Sonatypes
publishing service which runs on oss.sonatype.org.
You will need to have an account on sonatype.org to push releases. You can
override these values if you want to deploy to a different repository
-->
<property name="maven-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />
<property name="maven-repository-id" value="sonatype-nexus-staging" />
<!-- proto compiler used to generate java classes from .proto files -->
<property name="protoc.executable" value="protoc"/>
<property file="build.properties" />
<!-- gather release version -->
<target name="relversion">
<exec outputproperty="build.relVersion"
executable="git"
failonerror="false"
failifexecutionfails="false"
dir=".">
<arg value="describe"/>
<arg value="--tag"/>
<arg value="--always"/>
</exec>
</target>
<target name="protobuf-gen">
<fileset dir="${src.dir}" id="proto.classpath">
<include name="**/*.proto"/>
</fileset>
<pathconvert property="protofiles" pathsep=" " refid="proto.classpath"/>
<echo message="${protoc.executable} -I ${src.dir} --java_out=${gen.dir} ${protofiles}"/>
<exec executable="${protoc.executable}" searchpath="true">
<arg line="-I ${src.dir}"/>
<arg line="--java_out=${gen.dir}"/>
<arg line="${protofiles}"/>
</exec>
</target>
<!-- set the classpath for the project -->
<!-- this includes the generated source class files -->
<!-- and every jar in the /lib directory -->
<path id="srcclasspath.path">
<pathelement location="${classes.dir}" />
<fileset dir="${lib.dir}">
<include name="args4j.jar"/>
<include name="guava.jar"/>
<include name="gson.jar"/>
<include name="jsr305.jar"/>
<include name="protobuf-java.jar"/>
</fileset>
</path>
<path id="allclasspath.path">
<pathelement location="${classes.dir}" />
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="clean" description="delete generated files">
<delete dir="${build.dir}" />
</target>
<target name="compile"
description="compile the source code"
depends="relversion">
<mkdir dir="${classes.dir}" />
<javac srcdir="${gen.dir}"
destdir="${classes.dir}"
excludes=".svn,.git"
debug="${javac.debug}"
includeantruntime="false">
<classpath refid="srcclasspath.path" />
<compilerarg value="-Xlint:unchecked"/>
</javac>
<javac srcdir="${src.dir}"
destdir="${classes.dir}"
excludes=".svn,.git,**/refactoring/**,**/webservice/**,**/testing/**"
debug="${javac.debug}"
includeantruntime="true">
<classpath refid="srcclasspath.path" />
<compilerarg value="-Xlint:unchecked"/>
</javac>
<!-- Move Messages.properties where ScriptRuntime.java expects it. -->
<mkdir dir="${classes.dir}/rhino_ast/java/com/google/javascript/rhino/" />
<copy file="${src.dir}/com/google/javascript/rhino/Messages.properties"
todir="${classes.dir}/rhino_ast/java/com/google/javascript/rhino/" />
<!-- Move ParserConfig.properties where ParserRunner.java expects it. -->
<copy file="${src.dir}/com/google/javascript/jscomp/parsing/ParserConfig.properties"
todir="${classes.dir}/com/google/javascript/jscomp/parsing" />
<propertyfile
file="${classes.dir}/com/google/javascript/jscomp/parsing/ParserConfig.properties"
comment="Parser properties">
<entry key="compiler.date" type="date" value="now"/>
<entry key="compiler.version" value="${build.relVersion}"/>
</propertyfile>
<!-- Move the runtime libraries where the compiler expects them. -->
<mkdir dir="${classes.dir}/com/google/javascript/jscomp/js" />
<copy todir="${classes.dir}/com/google/javascript/jscomp/js">
<fileset dir="${src.dir}/com/google/javascript/jscomp/js" />
</copy>
</target>
<target name="jar"
depends="compile"
description="package compiler as an executable jar">
<zip destfile="${build.dir}/externs.zip" basedir="${externs.dir}" includes="*.js" />
<jar destfile="${compiler-jarfile}" update="true">
<fileset dir="${classes.dir}" />
<fileset dir="${build.dir}" includes="externs.zip" />
<zipfileset src="${lib.dir}/args4j.jar"/>
<zipfileset src="${lib.dir}/guava.jar"/>
<zipfileset src="${lib.dir}/gson.jar"/>
<zipfileset src="${lib.dir}/jsr305.jar"/>
<zipfileset src="${lib.dir}/protobuf-java.jar"/>
<manifest>
<attribute name="Main-Class"
value="com.google.javascript.jscomp.CommandLineRunner" />
</manifest>
</jar>
</target>
<target name="compile-tests"
depends="compile"
description="compile the JUnit tests">
<mkdir dir="${testClasses.dir}" />
<javac srcdir="${src.dir}"
destdir="${testClasses.dir}"
excludes=".svn,.git"
debug="on"
includeantruntime="false">
<classpath refid="allclasspath.path" />
<compilerarg value="-Xlint:unchecked"/>
</javac>
<javac srcdir="${test.dir}"
destdir="${testClasses.dir}"
excludes=".svn,.git"
debug="on"
includeantruntime="false">
<classpath refid="allclasspath.path" />
<compilerarg value="-Xlint:unchecked"/>
</javac>
</target>
<target name="all-classes-jar"
depends="compile,compile-tests"
description="package the compiler and its tests into one jar">
<jar destfile="${compiler-jarfile}" update="true">
<fileset dir="${testClasses.dir}" />
<zipgroupfileset dir="${lib.dir}" includes="*.jar"/>
</jar>
</target>
<target name="test"
depends="compile-tests"
description="Compile and execute the JUnit tests.">
<mkdir dir="build/testoutput"/>
<junit printsummary="on" fork="${test.fork}"
forkmode="once" showoutput="true"
failureproperty="junit.failure">
<classpath refid="allclasspath.path" />
<classpath>
<pathelement location="${build.dir}/test" />
</classpath>
<batchtest todir="build/testoutput">
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<fileset dir="${build.dir}/test">
<include name="**/${test.class}.class" />
</fileset>
</batchtest>
</junit>
<junitreport>
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput"/>
</junitreport>
<fail if="junit.failure"
message="Unit tests failed. See build/testoutput/index.html" />
</target>
<target name="one-test"
depends="compile-tests"
description="Compile and execute one JUnit test
specified with -Dtest.class and -Dtest.method.">
<mkdir dir="build/testoutput"/>
<junit printsummary="on" fork="${test.fork}"
forkmode="once" showoutput="true"
failureproperty="junit.failure">
<classpath refid="allclasspath.path" />
<classpath>
<pathelement location="${build.dir}/test" />
</classpath>
<test todir="build/testoutput" name="${test.class}" methods="${test.method}">
<formatter type="brief" usefile="false" />
<formatter type="xml" />
</test>
</junit>
<junitreport>
<fileset dir="build/testoutput" includes="*.xml"/>
<report todir="build/testoutput"/>
</junitreport>
<fail if="junit.failure"
message="Unit tests failed. See build/testoutput/index.html" />
</target>
<target name="fuzz-test"
depends="all-classes-jar"
description="checks the compiler against a variety of js programs">
<exec executable="java" failonerror="true">
<arg value="-cp" />
<arg value="${compiler-jarfile}" />
<arg value="com.google.javascript.jscomp.regtests.CompileEachLineOfProgramOutput" />
<arg value="generatejs"/>
<arg value="--stdout"/>
<arg value="${num-fuzz-tests}"/>
</exec>
</target>
<target name="javadoc"
description="generate Javadoc">
<mkdir dir="${javadoc.dir}" />
<javadoc
destdir="${javadoc.dir}"
author="false"
protected="true"
windowtitle="Closure Compiler"
additionalparam=" -notimestamp ">
<sourcepath>
<pathelement location="${src.dir}" />
<pathelement location="${gen.dir}" />
</sourcepath>
<classpath refid="allclasspath.path" />
<link href="http://docs.oracle.com/javase/7/docs/api/" />
</javadoc>
</target>
<target name="jar-javadoc" depends="javadoc">
<jar jarfile="${compiler-jarfile-javadoc}">
<fileset dir="${javadoc.dir}" />
</jar>
</target>
<target name="jar-sources" depends="javadoc">
<jar jarfile="${compiler-jarfile-sources}">
<fileset dir="${src.dir}" />
<fileset dir="${gen.dir}" />
</jar>
</target>
<!-- webservce package related targets -->
<!-- set the classpath for the project -->
<!-- this includes the generated source class files -->
<!-- and every jar in the /lib directory -->
<path id="webservice-classpath.path">
<pathelement location="${classes.dir}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${classes.dir}">
<include name="*.class" />
</fileset>
</path>
<target name="webservice-compile"
description="compile the source code of classes from the webservice package"
depends="compile">
<mkdir dir="${webservice-classes.dir}" />
<javac srcdir="${webservice.dir}"
destdir="${webservice-classes.dir}"
excludes=".svn,.git"
debug="${javac.debug}">
<classpath refid="webservice-classpath.path" />
</javac>
</target>
<target name="webservice-jar"
description="package the compiler and Webservice classes"
depends="webservice-compile, compile">
<zip destfile="${build.dir}/externs.zip" basedir="${externs.dir}" includes="*.js" />
<jar destfile="${webservice-jarfile}" update="true">
<zipgroupfileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${classes.dir}" />
<fileset dir="${webservice-classes.dir}" />
</jar>
</target>
<!-- RefasterJS package related targets -->
<!-- set the classpath for the project -->
<!-- this includes the generated source class files -->
<!-- and every jar in the /lib directory -->
<path id="refasterjs-classpath.path">
<pathelement location="${classes.dir}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
<fileset dir="${classes.dir}">
<include name="*.class" />
</fileset>
</path>
<target name="refasterjs-compile"
description="Compiles the source code of classes for RefasterJS"
depends="compile">
<mkdir dir="${refasterjs-classes.dir}" />
<javac srcdir="${refasterjs.dir}"
destdir="${refasterjs-classes.dir}"
excludes=".svn,.git"
debug="${javac.debug}">
<classpath refid="refasterjs-classpath.path" />
</javac>
</target>
<target name="refasterjs-jar"
description="Packages the compiler and RefasterJS classes"
depends="refasterjs-compile, compile">
<zip destfile="${build.dir}/externs.zip" basedir="${externs.dir}" includes="*.js" />
<jar destfile="${refasterjs-jarfile}" update="true">
<zipgroupfileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${build.dir}" includes="externs.zip" />
<fileset dir="${classes.dir}" />
<fileset dir="${refasterjs-classes.dir}" />
<manifest>
<attribute name="Main-Class"
value="com.google.javascript.refactoring.RefasterJs" />
</manifest>
</jar>
</target>
</project>