-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
266 lines (243 loc) · 10.5 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
<?xml version="1.0"?>
<project name="detyper" default="compile" basedir=".">
<property name="src.dir" value="src/main/java"/>
<property name="tsrc.dir" value="src/test/java"/>
<property name="deploy.dir" value="dist"/>
<property name="classes.dir" value="${deploy.dir}/classes"/>
<!-- read in the desired configuration local configuration -->
<property file="build.properties"/>
<!-- if build.properties does not specify javac.home we provide a default -->
<property name="javac.home" value="${java.home}/.."/>
<property name="javac.jar" value="tools.jar"/>
<!-- we need this for <if> -->
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath><pathelement location="lib/ant-contrib.jar"/></classpath>
</taskdef>
<!-- defines our classpath -->
<path id="base.classpath">
<pathelement location="${classes.dir}"/>
<fileset dir="${deploy.dir}/lib" includes="*.jar"/>
<fileset dir="${javac.home}/lib" includes="${javac.jar}"/>
</path>
<path id="build.classpath">
<path refid="base.classpath"/>
</path>
<!-- defines our runtime and build-time library dependencies -->
<fileset dir="lib" id="runtime.libs">
<include name="guava.jar"/>
</fileset>
<fileset dir="lib" id="build.libs">
<include name="junit4.jar"/>
</fileset>
<target name="-prepare">
<mkdir dir="${deploy.dir}"/>
<mkdir dir="${deploy.dir}/lib"/>
<mkdir dir="${classes.dir}"/>
<copy todir="${deploy.dir}/lib" flatten="true">
<fileset refid="build.libs"/>
<fileset refid="runtime.libs"/>
</copy>
</target>
<target name="clean" description="Cleans out build results.">
<delete dir="${deploy.dir}"/>
</target>
<target name="compile" depends="-prepare" description="Compiles the code.">
<javac fork="yes" executable="${javac.home}/bin/javac" debug="on"
source="1.6" target="1.6" encoding="utf-8" includeAntRuntime="no"
srcdir="${src.dir}" destdir="${classes.dir}">
<classpath refid="build.classpath"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
</javac>
</target>
<target name="dist" depends="compile"
description="Compiles the code and builds our jar file.">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="lib/jarjar-1.0.jar"/>
<jarjar destfile="${deploy.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<service type="javax.annotation.processing.Processor"
provider="org.ductilej.detyper.Processor"/>
<zipfileset src="${deploy.dir}/lib/guava.jar"/>
<rule pattern="com.google.**" result="gc.@1"/>
</jarjar>
</target>
<target name="javadoc" depends="-prepare" description="Generates javadoc documentation.">
<mkdir dir="${deploy.dir}/docs"/>
<javadoc windowtitle="${ant.project.name} API" doctitle="${ant.project.name} API"
destdir="${deploy.dir}/docs" additionalparam="-breakiterator">
<packageset dir="${src.dir}"/>
<classpath refid="build.classpath"/>
<link href="http://java.sun.com/javase/6/docs/api/"/>
</javadoc>
</target>
<target name="all" depends="clean,-prepare,compile,javadoc,dist"
description="Cleans and rebuilds everything including documentation."/>
<target name="test-all" depends="test-stock,test-ductile,test-ductile-only"
description="Runs all tests.">
</target>
<target name="test-ductile" depends="compile"
description="Compiles and runs the unit tests (with detyper).">
<property name="dtclass.dir" value="${deploy.dir}/dtclass"/>
<delete dir="${dtclass.dir}"/>
<mkdir dir="${dtclass.dir}"/>
<!-- compile our helper classes, let them be treated like lib classes -->
<javac fork="yes" executable="${javac.home}/bin/javac" debug="on"
source="1.6" target="1.6" encoding="utf-8" includeAntRuntime="no"
srcdir="${tsrc.dir}" destdir="${dtclass.dir}">
<classpath>
<pathelement location="${dtclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<include name="**/tests/helper/**"/>
</javac>
<!-- allows passing -Dtest=NamePrefix to restrict to subset of tests -->
<property name="test" value=""/>
<javac fork="yes" executable="${javac.home}/bin/javac" debug="on"
source="1.6" target="1.6" encoding="utf-8" includeAntRuntime="no"
srcdir="${tsrc.dir}" destdir="${dtclass.dir}">
<classpath>
<pathelement location="${dtclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<compilerarg value="-J-ea"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<!--<compilerarg value="-XprintProcessorInfo"/>-->
<compilerarg value="-implicit:class"/>
<compilerarg value="-processor"/>
<compilerarg value="org.ductilej.detyper.Processor"/>
<compilerarg value="-Aorg.ductilej.warnings=true"/>
<compilerarg value="-Aorg.ductilej.keepifcs=true"/> <!-- TEMP -->
<compilerarg value="-Aorg.ductilej.showclass=${showclass}"/>
<compilerarg value="-Aorg.ductilej.debug=${debug}"/>
<include name="**/tests/${test}*Test.java"/>
</javac>
<!-- now run the tests (that match the 'test' property) -->
<antcall target="runtests">
<param name="tclass.dir" value="${dtclass.dir}"/>
</antcall>
</target>
<target name="test-stock" depends="compile"
description="Compiles and runs the unit tests (without detyper).">
<property name="stclass.dir" value="${deploy.dir}/stclass"/>
<delete dir="${stclass.dir}"/>
<mkdir dir="${stclass.dir}"/>
<!-- allows passing -Dtest=NamePrefix to restrict to subset of tests -->
<property name="test" value=""/>
<javac fork="yes" executable="${javac.home}/bin/javac" debug="on"
source="1.6" target="1.6" encoding="utf-8" includeAntRuntime="no"
srcdir="${tsrc.dir}" destdir="${stclass.dir}">
<classpath>
<pathelement location="${stclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<compilerarg value="-J-ea"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<include name="**/tests/${test}*Test.java"/>
</javac>
<!-- now run the tests (that match the 'test' property) -->
<antcall target="runtests">
<param name="tclass.dir" value="${stclass.dir}"/>
</antcall>
</target>
<target name="test-ductile-only" depends="compile"
description="Compiles and runs the Ductile-only unit tests.">
<property name="dotclass.dir" value="${deploy.dir}/dotclass"/>
<delete dir="${dotclass.dir}"/>
<mkdir dir="${dotclass.dir}"/>
<!-- allows passing -Dtest=NamePrefix to restrict to subset of tests -->
<property name="test" value=""/>
<javac fork="yes" executable="${javac.home}/bin/javac" debug="on"
source="1.6" target="1.6" encoding="utf-8" includeAntRuntime="no"
srcdir="${tsrc.dir}" destdir="${dotclass.dir}">
<classpath>
<pathelement location="${dotclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<compilerarg value="-J-ea"/>
<compilerarg value="-Xlint"/>
<compilerarg value="-Xlint:-serial"/>
<!--<compilerarg value="-XprintProcessorInfo"/>-->
<compilerarg value="-implicit:class"/>
<compilerarg value="-processor"/>
<compilerarg value="org.ductilej.detyper.Processor"/>
<compilerarg value="-Aorg.ductilej.warnings=${warnings}"/>
<compilerarg value="-Aorg.ductilej.keepifcs=true"/> <!-- TEMP -->
<compilerarg value="-Aorg.ductilej.showclass=${showclass}"/>
<compilerarg value="-Aorg.ductilej.debug=${debug}"/>
<include name="**/dtests/${test}*Test.java"/>
</javac>
<!-- now run the tests (that match the 'test' property) -->
<junit printsummary="off" haltonfailure="yes" fork="${junit.fork}">
<classpath>
<pathelement location="${classes.dir}"/>
<pathelement location="${dotclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<assertions><enable/></assertions>
<jvmarg value="-Dorg.ductilej.debug=${debug}"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${tsrc.dir}">
<include name="**/dtests/${test}*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- a helper for the tests and stock-tests targets -->
<target name="runtests">
<junit printsummary="off" haltonfailure="yes" fork="${junit.fork}">
<classpath>
<pathelement location="${classes.dir}"/>
<pathelement location="${tclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<assertions><enable/></assertions>
<jvmarg value="-Dorg.ductilej.debug=${debug}"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${tsrc.dir}">
<include name="**/tests/${test}*Test.java"/>
<exclude name="**/ConstructorPackageTest*.java"/>
<exclude name="**/tests/StaticMethod*.java"/>
</fileset>
</batchtest>
</junit>
<!-- these tests require special package naming conventions and must
handled in separate <unit> blocks which may run (or not) depending
on the value of the "test" property -->
<antcall target="runspecial">
<param name="testpkg" value="OtherPackage"/>
<param name="testname" value="ConstructorPackage"/>
</antcall>
<antcall target="runspecial">
<param name="testpkg" value="StaticMethodResolutionTestPackage"/>
<param name="testname" value="StaticMethodResolution"/>
</antcall>
<antcall target="runspecial">
<param name="testpkg" value="MyInterfaceTest"/>
<param name="testname" value="StaticMethodAmbiguousInterface"/>
</antcall>
</target>
<!-- a helper for the runtests target -->
<target name="runspecial">
<if><or><equals arg1="${test}" arg2="${testname}"/>
<equals arg1="${test}" arg2=""/></or>
<then>
<junit printsummary="off" haltonfailure="yes" fork="${junit.fork}">
<classpath>
<pathelement location="${classes.dir}"/>
<pathelement location="${tclass.dir}"/>
<path refid="build.classpath"/>
</classpath>
<assertions><enable/></assertions>
<formatter type="brief" usefile="false"/>
<test name="${testpkg}.${testname}Test"/>
</junit>
</then>
</if>
</target>
</project>