forked from kordamp/json-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
330 lines (300 loc) · 16.3 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
<project name="json-lib" default="compile" basedir="." xmlns:artifact="urn:maven-artifact-ant">
<property file="${user.home}/.m2/maven.properties" />
<property file="build.properties" />
<property name="maven.project.build.finalName" value="json-lib-2.4.1" />
<property name="maven.build.output" value="target/classes" />
<property name="maven.build.directory" value="target" />
<property name="maven.test.reports" value="${maven.build.directory}/test-reports" />
<property name="maven.test.output" value="target/test-classes" />
<property name="project.lib.dir" value="${basedir}/src/lib" />
<property name="project.src.jdk3.dir" value="${basedir}/src/main/java" />
<property name="project.src.jdk5.dir" value="${basedir}/src/main/jdk15" />
<property name="project.src.groovy.dir" value="${basedir}/src/main/groovy" />
<property name="project.test.jdk3.dir" value="${basedir}/src/test/java" />
<property name="project.test.jdk5.dir" value="${basedir}/src/test/jdk15" />
<property name="project.test.groovy.dir" value="${basedir}/src/test/groovy" />
<property name="javadoc.jdk3.dir" value="${maven.build.directory}/site/apidocs" />
<property name="javadoc.jdk5.dir" value="${maven.build.directory}/site/apidocs/jdk15" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
<classpath>
<pathelement location="${project.lib.dir}/maven-ant-tasks-2.0.9.jar" />
</classpath>
</typedef>
<artifact:pom file="pom.xml" id="maven.project" />
<artifact:dependencies pathId="build.classpath" filesetId="compile.fileset" useScope="compile">
<pom refid="maven.project" />
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
<pom refid="maven.project" />
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
<pom refid="maven.project" />
</artifact:dependencies>
<target name="clean" description="Clean the output directory">
<delete dir="${maven.build.directory}" />
</target>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="build.classpath" />
<target name="compile" description="Compile the code (jdk1.3)">
<mkdir dir="${maven.build.output}" />
<javac destdir="${maven.build.output}" excludes="**/package.html" debug="true" deprecation="true" source="1.3" target="1.1">
<src path="${project.src.jdk3.dir}" />
<classpath refid="build.classpath" />
</javac>
</target>
<target name="compile.jdk5" depends="compile" description="Compile the code (jdk5)">
<delete file="${maven.build.output}/net/sf/json/JSONObject.class" />
<delete file="${maven.build.output}/net/sf/json/JSONArray.class" />
<javac destdir="${maven.build.output}" debug="true" deprecation="true" source="1.5" target="1.5">
<src path="${project.src.jdk5.dir}" />
<classpath>
<path refid="build.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</javac>
</target>
<target name="compile.groovy" depends="compile" description="Compile the code (Groovy)">
<groovyc srcdir="${project.src.groovy.dir}" destdir="${maven.build.output}">
<classpath>
<path refid="build.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</groovyc>
</target>
<target name="compile-tests" depends="junit-present, compile" description="Compile the test code (jdk1.3)" if="junit.present">
<mkdir dir="${maven.test.output}" />
<javac destdir="${maven.test.output}" debug="true" deprecation="true" optimize="false" source="1.3" target="1.1">
<src path="${project.test.jdk3.dir}" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</javac>
<copy todir="${maven.test.output}">
<fileset dir="src/test/resources" />
</copy>
</target>
<target name="compile-tests.jdk5" depends="junit-present, compile.jdk5, compile-tests" description="Compile the test code (jdk5)" if="junit.present">
<mkdir dir="${maven.test.output}" />
<javac destdir="${maven.test.output}" debug="true" deprecation="true" optimize="false" source="1.5" target="1.5">
<src path="${project.test.jdk5.dir}" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</javac>
</target>
<target name="compile-tests.groovy" depends="compile.groovy" description="Compile the test code (Groovy)">
<mkdir dir="${maven.test.output}" />
<groovyc srcdir="${project.test.groovy.dir}" destdir="${maven.test.output}">
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<pathelement location="${maven.build.output}" />
</classpath>
</groovyc>
</target>
<target name="test" depends="test.jdk3,test.groovy" description="Run JDK13 & Groovy test cases" />
<target name="test.jdk3" depends="junit-present, compile-tests" if="junit.present" description="Run the test cases (jdk1.3)">
<mkdir dir="${maven.test.reports}" />
<junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir="." forkmode="once">
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<formatter type="plain" usefile="true" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<path refid="runtime.classpath" />
<pathelement location="${maven.build.output}" />
<pathelement location="${maven.test.output}" />
</classpath>
<batchtest todir="${maven.test.reports}">
<fileset dir="src/test/java">
<include name="**/Test*.java" />
<exclude name="**/*Abstract*Test.java" />
</fileset>
</batchtest>
</junit>
</target>
<target name="test.jdk5" depends="junit-present, compile-tests.jdk5" if="junit.present" description="Run the test cases (jdk5)">
<mkdir dir="${maven.test.reports}" />
<junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir="." forkmode="once">
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<formatter type="plain" usefile="true" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<path refid="runtime.classpath" />
<pathelement location="${maven.build.output}" />
<pathelement location="${maven.test.output}" />
</classpath>
<batchtest todir="${maven.test.reports}">
<path>
<fileset dir="src/test/java">
<include name="**/Test*.java" />
<exclude name="**/*Abstract*Test.java" />
</fileset>
<fileset dir="src/test/jdk15">
<include name="**/Test*.java" />
<exclude name="**/*Abstract*Test.java" />
</fileset>
</path>
</batchtest>
</junit>
<antcall target="test.groovy"/>
</target>
<target name="test.groovy" depends="junit-present, compile-tests.groovy" if="junit.present" description="Run the test cases (Groovy)">
<mkdir dir="${maven.test.reports}" />
<junit printSummary="yes" haltonerror="true" haltonfailure="true" fork="true" dir="." forkmode="once">
<sysproperty key="basedir" value="." />
<formatter type="xml" />
<formatter type="plain" usefile="true" />
<classpath>
<path refid="build.classpath" />
<path refid="test.classpath" />
<path refid="runtime.classpath" />
<pathelement location="${maven.build.output}" />
<pathelement location="${maven.test.output}" />
</classpath>
<batchtest todir="${maven.test.reports}">
<fileset dir="${maven.test.output}">
<include name="net/sf/json/groovy/AllTests.class" />
</fileset>
</batchtest>
</junit>
</target>
<target name="test-junit-present">
<available classname="junit.framework.Test" property="junit.present" />
</target>
<target name="junit-present" depends="test-junit-present" unless="junit.present">
<echo>================================= WARNING ================================</echo>
<echo> Junit isn't present in your $ANT_HOME/lib directory. Tests not executed. </echo>
<echo>==========================================================================</echo>
</target>
<target name="jar" depends="clean,test" description="Binary jar (jdk3)">
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk13.jar" basedir="${maven.build.output}" excludes="**/package.html" />
</target>
<target name="jar.jdk5" depends="clean,test.jdk5" description="Binary jar (jdk5)">
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk15.jar" basedir="${maven.build.output}" excludes="**/package.html" />
</target>
<target name="jarjar" depends="jar">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${project.lib.dir}/jarjar-1.0.jar"/>
<property name="jarfile" value="${maven.build.directory}/${maven.project.name}-all-${maven.project.version}-jdk13.jar"/>
<delete file="${jarfile}"/>
<jarjar jarfile="${jarfile}">
<zipfileset src="${maven.build.directory}/${maven.project.build.finalName}-jdk13.jar"/>
<zipfileset src="${maven.repo.local}/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar"/>
<zipfileset src="${maven.repo.local}/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar"/>
<zipfileset src="${maven.repo.local}/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
<zipfileset src="${maven.repo.local}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
<zipfileset src="${maven.repo.local}/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar"/>
<rule pattern="org.apache.commons.**" result="_json.org.apache.commons.@1"/>
<rule pattern="net.sf.ezmorph.**" result="_json.net.sf.ezmorph.@1"/>
</jarjar>
</target>
<target name="jarjar.jdk5" depends="jar.jdk5">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"
classpath="${project.lib.dir}/jarjar-1.0.jar"/>
<property name="jarfile" value="${maven.build.directory}/${maven.project.name}-all-${maven.project.version}-jdk15.jar"/>
<delete file="${jarfile}"/>
<jarjar jarfile="${jarfile}">
<zipfileset src="${maven.build.directory}/${maven.project.build.finalName}-jdk15.jar"/>
<zipfileset src="${maven.repo.local}/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar"/>
<zipfileset src="${maven.repo.local}/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar"/>
<zipfileset src="${maven.repo.local}/commons-lang/commons-lang/2.5/commons-lang-2.5.jar"/>
<zipfileset src="${maven.repo.local}/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar"/>
<zipfileset src="${maven.repo.local}/net/sf/ezmorph/ezmorph/1.0.6/ezmorph-1.0.6.jar"/>
<rule pattern="org.apache.commons.**" result="_json.org.apache.commons.@1"/>
<rule pattern="net.sf.ezmorph.**" result="_json.net.sf.ezmorph.@1"/>
</jarjar>
</target>
<target name="source.jar" description="Source jar (jdk1.3)">
<delete dir="${maven.build.directory}/source/jdk13" />
<mkdir dir="${maven.build.directory}/source/jdk13" />
<copy todir="${maven.build.directory}/source/jdk13">
<fileset dir="src/main/java">
<include name="**/*.java" />
</fileset>
</copy>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk13-sources.jar" basedir="${maven.build.directory}/source/jdk13" />
</target>
<target name="source.jar.jdk5" description="Source jar (jdk5)">
<delete dir="${maven.build.directory}/source/jdk15" />
<mkdir dir="${maven.build.directory}/source/jdk15" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/java">
<include name="**/*.java" />
</fileset>
</copy>
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONObject.java" />
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONArray.java" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/jdk15">
<include name="**/*.java" />
</fileset>
</copy>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk15-sources.jar" basedir="${maven.build.directory}/source/jdk15" />
</target>
<target name="javadoc" description="Build javadocs (jdk1.3)" depends="setup">
<mkdir dir="${javadoc.jdk3.dir}" />
<mkdir dir="${maven.build.directory}/source/jdk13" />
<copy todir="${maven.build.directory}/source/jdk13">
<fileset dir="src/main/java">
<include name="**/*" />
</fileset>
</copy>
<javadoc destdir="${javadoc.jdk3.dir}" windowtitle="Overview (json-lib jdk 1.3 API)" useexternalfile="true">
<packageset dir="${maven.build.directory}/source/jdk13">
<include name="**/*" />
</packageset>
<classpath>
<path refid="build.classpath" />
</classpath>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
<link href="http://www.junit.org/junit/javadoc/" />
<link href="http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/docs/api/" />
<link href="http://jakarta.apache.org/commons/lang/api-2.2/" />
<link href="http://ezmorph.sourceforge.net/apidocs/" />
</javadoc>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk13-javadoc.jar" basedir="${javadoc.jdk3.dir}" />
</target>
<target name="javadoc.jdk5" description="Build javadocs (jdk5)" depends="setup">
<delete dir="${javadoc.jdk5.dir}" />
<delete dir="${maven.build.directory}/source/jdk15" />
<mkdir dir="${javadoc.jdk5.dir}" />
<mkdir dir="${maven.build.directory}/source/jdk15" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/java">
<include name="**/*" />
</fileset>
</copy>
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONObject.java" />
<delete file="${maven.build.directory}/source/jdk15/net/sf/json/JSONArray.java" />
<copy todir="${maven.build.directory}/source/jdk15">
<fileset dir="src/main/jdk15">
<include name="**/*.java" />
</fileset>
</copy>
<javadoc destdir="${javadoc.jdk5.dir}" windowtitle="Overview (json-lib jdk 5 API)" useexternalfile="true">
<packageset dir="${maven.build.directory}/source/jdk15">
<include name="**/*" />
</packageset>
<classpath>
<path refid="build.classpath" />
</classpath>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/" />
<link href="http://www.junit.org/junit/javadoc/" />
<link href="http://jakarta.apache.org/commons/beanutils/commons-beanutils-1.7.0/docs/api/" />
<link href="http://jakarta.apache.org/commons/lang/api-2.2/" />
<link href="http://ezmorph.sourceforge.net/apidocs/" />
</javadoc>
<jar jarfile="${maven.build.directory}/${maven.project.build.finalName}-jdk15-javadoc.jar" basedir="${javadoc.jdk5.dir}" />
</target>
<target name="setup" if="use.proxy">
<echo message="Setting proxy values [${maven.proxy.host}:${maven.proxy.port}]" />
<setproxy proxyhost="${maven.proxy.host}" proxyport="${maven.proxy.port}" proxyuser="${maven.proxy.username}" proxypassword="${maven.proxy.password}" />
</target>
</project>