forked from CharlesZ-Chen/ReadChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
199 lines (173 loc) · 8.32 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
<!-- I follow the target naming convention of Apache Ant Style here: https://wiki.apache.org/ant/TheElementsOfAntStyle -->
<!-- This Ant build xml serves for two purposes:
1. build & distribute Read Checker:
init dist
2. test Read Checker:
init-test test
The build.xml manages the internal dependences of Read Checker (i.e. test depends on Read Checker bin, etc.)
The external dependencies needed for building and testing Read Checker are described in file build.properties
-->
<project name="ReadChecker" basedir="." default="dist">
<dirname property="read-checker.basedir" file="${ant.file.ReadChecker}"/>
<!-- load properties of external dependencies -->
<loadproperties srcFile="build.properties"/>
<!-- build properties -->
<property name="readchecker.bin" value="${read-checker.basedir}/bin"/>
<property name="readchecker.src" value="${read-checker.basedir}/src"/>
<property name="build.lib" value="${read-checker.basedir}/lib"/>
<!-- <property name="checker.dist" value="${read-checker.basedir}/bin"/> -->
<!-- if using jdk.astub, un-comment below properties, and re-configure the right place of your jdk.astub-->
<property name="jdk.astub" value="${readchecker.src}/read/jdk.astub"/>
<property name="jdk.astub.bin.dir" value="${readchecker.bin}/read"/>
<!-- test properties -->
<property name="test" value="${read-checker.basedir}/tests" />
<property name="test.src" value="${test}/src" />
<property name="test.lib" value="${test}/lib" />
<property name="test.build" value="${test}/build"/>
<property name="test.build.reports" value="${test.build}/reports"/>
<property name="cf.util.build" value="${checker-framework}/util/build/classes/java/main"/>
<!-- Defaults, used if the Ant invocation does not set a value. -->
<property name="halt.on.test.error" value="true" />
<property name="halt.on.test.failure" value="true" />
<!-- build targets start -->
<target name="init"
description="link all necessary dependences into ${build.deps}">
<mkdir dir="${readchecker.bin}"/>
<mkdir dir="${build.lib}"/>
<symlink link="${build.lib}/framework.jar" resource="${framework.lib}" overwrite="true"/>
<symlink link="${build.lib}/javac.jar" resource="${javac.lib}" overwrite="true"/>
<!-- <symlink link="${build.deps}/annotation-file-utilities.jar" resource="${annotation-file-utilities.lib}" overwrite="true"/> -->
<!-- using jdk.astub specific, need to re-configure the right place of yoru jdk.astub.bin.dir-->
<copy file="${jdk.astub}" todir="${jdk.astub.bin.dir}"/>
</target>
<target name="dist" depends="init"
description="compile this checker">
<pathconvert pathsep=":" property="build.lib.jars">
<path>
<fileset dir="${build.lib}">
<include name="*.jar"/>
</fileset>
</path>
</pathconvert>
<pathconvert pathsep=" " property="src.checker">
<path>
<fileset dir="${readchecker.src}">
<include name="**/*.java"/>
</fileset>
</path>
</pathconvert>
<java fork="true"
failonerror="true"
classpath="${build.lib.jars}"
classname="com.sun.tools.javac.Main">
<jvmarg line="-Xbootclasspath/p:${javac.lib}"/>
<arg value="-g"/>
<arg value="-source"/>
<arg value="7"/>
<arg value="-target"/>
<arg value="7"/>
<!-- To not get a warning about bootstrap classpath -->
<arg value="-Xlint:-options"/>
<arg line="-sourcepath ${readchecker.src}"/>
<arg line="-d ${readchecker.bin}"/>
<arg line="${src.checker}"/>
</java>
</target>
<target name="clean" depends="clean-build,clean-test" description="delete all generated files and directories">
</target>
<target name="clean-build"
description="delete all generated files and directories by dist target">
<delete dir="${readchecker.bin}" quiet="true"/>
<delete dir="${build.lib}" quiet="true"/>
</target>
<!-- build targets end -->
<!-- test target start -->
<target name="init-test"
description="create needs dirs, and prepare the dependences of running tests">
<mkdir dir="${test.build}"/>
<mkdir dir="${test.build.reports}"/>
<mkdir dir="${test.lib}"/>
<symlink link="${test.lib}/framework.jar" resource="${framework.lib}" overwrite="true"/>
<symlink link="${test.lib}/javac.jar" resource="${javac.lib}" overwrite="true"/>
<symlink link="${test.lib}/hamcrest-core.jar" resource="${hamcrest.lib}" overwrite="true"/>
<symlink link="${test.lib}/junit.jar" resource="${junit.lib}" overwrite="true"/>
<pathconvert pathsep=" " property="src.test">
<path>
<fileset dir="${test.src}">
<include name="**/*.java"/>
</fileset>
</path>
</pathconvert>
<pathconvert pathsep=":" property="test.lib.jars">
<path>
<fileset dir="${test.lib}">
<include name="*.jar"/>
</fileset>
</path>
</pathconvert>
</target>
<target name="dist-test" depends="init-test,dist" description="Compile tests">
<java fork="true"
failonerror="true"
classpath="${test.lib.jars}:${readchecker.bin}:${cf.util.build}"
classname="com.sun.tools.javac.Main">
<jvmarg line="-Xbootclasspath/p:${javac.lib}"/>
<arg value="-g"/>
<!-- Make sure we only have Java 7 source code and generate Java 7 bytecode. -->
<arg value="-source"/>
<arg value="7"/>
<arg value="-target"/>
<arg value="7"/>
<!-- To not get a warning about bootstrap classpath -->
<arg value="-Xlint:-options"/>
<arg line="-sourcepath ${test.src}"/>
<arg line="-d ${test.build}"/>
<arg line="${src.test}"/>
</java>
</target>
<target name="test" depends="dist-test"
description="Run tests for this checker, WITHOUT building anything">
<!-- set this on the command line for like -Dtest.filter="**/TargetedTest.java" to target specific tests-->
<property name="test.filter" value="**/*Test.java"/>
<condition property="should.emit.debug.str" value="true" else="false">
<isset property="emit.test.debug"/>
</condition>
<condition property="debugger.str" value="-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005" else="">
<isset property="debugger.on"/>
</condition>
<!-- Copied from -run-tests target -->
<mkdir dir="${test.build.reports}"/>
<junit fork="true"
dir="${read-checker.basedir}"
printsummary="false"
haltonerror="${halt.on.test.error}"
haltonfailure="${halt.on.test.failure}">
<!--Set JAVAC_JAR so the insert-annotations-to-source can use it-->
<!-- <env key="JAVAC_JAR" value="${javac.lib}"/> -->
<classpath path="${test.lib.jars}:${test.build}:${readchecker.bin}:${cf.util.build}"/>
<jvmarg line="-Xbootclasspath/p:${javac.lib}"/>
<jvmarg line="-ea"/>
<!-- <jvmarg line="${debugger.str}"/> -->
<sysproperty key="use.hacks" value="${use.hacks.str}"/>
<sysproperty key="emit.test.debug" value="${should.emit.debug.str}"/>
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
<!-- <test name="ReadTest"/> -->
<batchtest todir="${test.build.reports}">
<fileset dir="${test.src}">
<include name="${test.filter}"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="clean-test"
description="delete all generated files and directories by test target">
<delete dir="${test.lib}" quiet="true"/>
<delete dir="${test.build}" quiet="true"/>
</target>
<!-- test target end -->
<!-- debugging -->
<target name="debug">
<echoproperties/>
</target>
</project>