forked from antlibs/ant-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
355 lines (318 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
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
<project name="ant-contrib" default="jar" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="root.dir" location="."/>
<property name="src.main.dir" location="src/main/java"/>
<property name="resources.main.dir" location="src/main/resources"/>
<property name="src.test.dir" location="src/test/java"/>
<property name="resources.test.dir" location="src/test/resources"/>
<property name="docs.dir" location="src/site/resources"/>
<property name="xdoc.dir" location="src/site/xdoc"/>
<property name="target.dir" location="target"/>
<property name="lib.dir" value="${target.dir}/lib"/>
<property name="jacoco.log" value="${target.dir}/jacoco.data"/>
<property name="target.classes.dir" location="${target.dir}/classes"/>
<property name="target.test-classes.dir" location="${target.dir}/test-classes"/>
<property name="target.docs.dir" location="${target.dir}/docs"/>
<property name="checkstyle.src.dir" location="src/config"/>
<property name="checkstyle.report.dir" location="${target.docs.dir}/checkstyle"/>
<property name="coverage.report.dir" location="${target.docs.dir}/coverage"/>
<property name="target.stage.dir" location="${target.dir}/stage"/>
<property name="xml.log.dir" value="${target.dir}/test-report"/>
<property name="dist.dir" location="dist"/>
<property name="skip.tests" value="walls"/>
<property name="project.java.baseline" value="1.5"/>
<!-- Ivy -->
<property name="central.repo" value="http://repo1.maven.org/maven2"/>
<property name="ivy.version" value="2.4.0"/>
<property name="ivy.dir" value="${user.home}/.ivy2/cache/org.apache.ivy/jars"/>
<property name="ivy.jar.name" value="ivy-${ivy.version}.jar"/>
<available property="has.ivy" file="${ivy.dir}/${ivy.jar.name}" type="file"/>
<target name="get-ivy" description="o Get Ivy jar unless already cached" unless="has.ivy">
<mkdir dir="${ivy.dir}"/>
<get usetimestamp="true" src="https://repository.apache.org/content/repositories/releases/org/apache/ivy/ivy/${ivy.version}/${ivy.jar.name}"
skipexisting="true"
dest="${ivy.dir}/${ivy.jar.name}"/>
</target>
<target name="init" description="o Initialize Ivy" depends="get-ivy">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpath="${ivy.dir}/${ivy.jar.name}"/>
<ivy:settings file="${basedir}/ivy.settings.xml"/>
</target>
<target name="get-deps" description="o Retrieve dependencies" depends="init" unless="noget">
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]" sync="true" type="jar"/>
</target>
<target name="classpath" depends="get-deps">
<ivy:cachepath pathid="compile.classpath" type="jar" conf="compile"/>
<ivy:cachepath pathid="runtime.classpath" type="jar" conf="runtime"/>
<ivy:cachepath pathid="test.classpath" type="jar" conf="test"/>
<ivy:cachepath pathid="doxia.classpath" type="jar" conf="doxia"/>
<ivy:cachefileset setid="compile.fileset" type="jar" conf="compile"/>
<ivy:cachefileset setid="runtime.fileset" type="jar" conf="runtime"/>
<ivy:cachefileset setid="test.fileset" type="jar" conf="test"/>
</target>
<target name="compile" description="o Compile Java classes and copy antlib" depends="classpath">
<mkdir dir="${target.classes.dir}"/>
<javac srcdir="${src.main.dir}"
destdir="${target.classes.dir}"
debug="true"
classpathref="compile.classpath"
source="${project.java.baseline}"
target="${project.java.baseline}"
includeantruntime="false"/>
<copy todir="${target.classes.dir}">
<fileset dir="${resources.main.dir}"
includes="**/*.xml"/>
</copy>
</target>
<target name="compile-tests" description="o Compile test Java classes and copy test resources" depends="compile">
<mkdir dir="${target.test-classes.dir}"/>
<javac srcdir="${src.test.dir}"
destdir="${target.test-classes.dir}"
debug="true"
source="${project.java.baseline}"
target="${project.java.baseline}"
includeantruntime="true">
<classpath>
<path refid="test.classpath"/>
<pathelement location="${target.classes.dir}"/>
</classpath>
</javac>
<copy todir="${target.test-classes.dir}">
<!-- antclipse expects .classpath in basedir -->
<fileset dir="${resources.test.dir}"
includes="**/*.java,**/*.properties,**/*.xml,**/*.txt,.classpath"/>
</copy>
</target>
<target name="jar" description="o Build jar file" depends="compile-tests">
<mkdir dir="${target.dir}"/>
<property name="jar.file" value="${target.dir}/${ivy.module}.jar"/>
<tstamp>
<format property="tstamp" pattern="dd/MM/yyyy HH:mm:ss"/>
</tstamp>
<jar file="${jar.file}">
<manifest>
<attribute name="Implementation-Title" value="Ant Contrib Tasks for Apache Ant"/>
<attribute name="Implementation-Vendor" value="http://ant-contrib.sourceforge.net/"/>
<attribute name="Implementation-Version" value="${ivy.revision}"/>
<attribute name="Build-Timestamp" value="${tstamp}"/>
<attribute name="Main-Class" value="net.sf.antcontrib.AntContribVersion"/>
</manifest>
<fileset dir="${target.classes.dir}"/>
</jar>
</target>
<target name="init-jacoco" depends="jar">
<ivy:cachepath organisation="org.jacoco" module="org.jacoco.ant" revision="0.7.9"
inline="true" conf="default" pathid="jacoco.classpath" log="download-only"/>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"
classpathref="jacoco.classpath"/>
</target>
<target name="test-internal" depends="init-jacoco">
<mkdir dir="${xml.log.dir}"/>
<loadresource property="exclude.tests">
<propertyresource name="skip.tests"/>
<filterchain>
<tokenfilter>
<replacestring from="," to="/**,**/"/>
</tokenfilter>
</filterchain>
</loadresource>
<!-- multiple runs into the same logfile cause the later report generation fail -->
<delete file="${jacoco.log}"/>
<jacoco:coverage xmlns:jacoco="antlib:org.jacoco.ant" destfile="${jacoco.log}"
exclclassloader="sun.reflect.DelegatingClassLoader:javassist.Loader">
<junit fork="true" tempdir="${target.dir}"
haltonerror="false" haltonfailure="false"
errorproperty="junit.error" failureproperty="junit.failure"
showoutput="off" printsummary="on">
<formatter type="xml"/>
<sysproperty key="basedir" value="${target.test-classes.dir}"/>
<sysproperty key="antcontrib.jar" file="${jar.file}"/>
<batchtest todir="${xml.log.dir}">
<fileset dir="${target.test-classes.dir}"
includes="net/sf/antcontrib/**/*Test.class"
excludes="**/${exclude.tests}/**"/>
</batchtest>
<classpath>
<path refid="test.classpath"/>
<pathelement location="${target.classes.dir}"/>
<pathelement location="${target.test-classes.dir}"/>
</classpath>
</junit>
</jacoco:coverage>
</target>
<target name="test" depends="test-internal" description="o Run JUnit tests">
<fail message="JUnit error (${junit.error}) encountered. See logs (in ${xml.log.dir}) for details (use the target test-report to run the test with a report)" if="junit.error"/>
<fail message="JUnit failure (${junit.failure}) encountered. See logs (in ${xml.log.dir}) for details (use the target test-report to run the test with a report)" if="junit.failure"/>
</target>
<target name="test-report" depends="test-internal" description="o Make report of JUnit tests and code coverage">
<junitreport todir="${xml.log.dir}">
<fileset dir="${xml.log.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${target.docs.dir}/test-reports"/>
</junitreport>
<mkdir dir="${coverage.report.dir}"/>
<jacoco:report xmlns:jacoco="antlib:org.jacoco.ant">
<executiondata>
<file file="${jacoco.log}"/>
</executiondata>
<structure name="Ant Contrib">
<classfiles>
<fileset dir="${target.classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.main.dir}"/>
</sourcefiles>
</structure>
<html destdir="${coverage.report.dir}"/>
</jacoco:report>
<fail message="JUnit error (${junit.error}) encountered. See logs (in ${xml.log.dir}) or report (in ${target.docs.dir}/test-reports)" if="junit.error"/>
<fail message="JUnit failure (${junit.failure}) encountered. See logs (in ${xml.log.dir}) or report (in ${target.docs.dir}/test-reports)" if="junit.failure"/>
</target>
<target name="init-checkstyle" depends="jar">
<ivy:cachepath organisation="com.puppycrawl.tools" module="checkstyle" revision="7.8"
inline="true" conf="default" pathid="checkstyle.classpath" log="download-only"/>
<taskdef uri="antlib:com.puppycrawl.tools.checkstyle.ant"
resource="com/puppycrawl/tools/checkstyle/ant/antlib.xml" classpathref="checkstyle.classpath"/>
</target>
<!-- Checks ant-contrib codebase according to ${checkstyle.src.dir}/checkstyle.xml -->
<target name="checkstyle-internal" depends="init-checkstyle">
<mkdir dir="${checkstyle.report.dir}"/>
<cs:checkstyle xmlns:cs="antlib:com.puppycrawl.tools.checkstyle.ant"
config="${checkstyle.src.dir}/checkstyle.xml"
failOnViolation="false" failureProperty="checkstyle.failed">
<classpath>
<path refid="runtime.classpath"/>
</classpath>
<formatter type="xml" toFile="${checkstyle.report.dir}/checkstyle.xml"/>
<fileset dir="${src.main.dir}">
<include name="**/*.java"/>
</fileset>
</cs:checkstyle>
</target>
<target name="checkstyle" depends="checkstyle-internal"
description="o Check Ivy codebase according to src/config/checkstyle.xml">
<fail if="checkstyle.failed"
message="Checkstyle has errors. See report in ${checkstyle.report.dir}"/>
</target>
<target name="checkstyle-report" depends="checkstyle-internal">
<property name="checkstyle.basedir" location="${src.main.dir}"/>
<xslt in="${checkstyle.report.dir}/checkstyle.xml"
style="${checkstyle.src.dir}/checkstyle-frames.xsl"
out="${checkstyle.report.dir}/output.txt">
<param name="basedir" expression="${checkstyle.basedir}"/>
<param name="output.dir" expression="${checkstyle.report.dir}"/>
</xslt>
</target>
<target name="javadoc" description="o Build javadoc" depends="classpath">
<javadoc sourcepath="${src.main.dir}"
destdir="${target.docs.dir}/api"
packagenames="net.sf.antcontrib.*"
author="true"
version="true"
windowtitle="Ant Contrib"
classpathref="compile.classpath">
<tag name="ant.task" enabled="false" description="Task:" scope="types"/>
<tag name="ant.datatype" enabled="false"
description="Data type:" scope="types"/>
<tag name="ant.attribute" enabled="false"
description="Attribute:" scope="types"/>
<tag name="ant.attribute.group" enabled="false"
description="Attribute group:" scope="types"/>
<tag name="ant.element" enabled="false"
description="Nested element:" scope="types"/>
</javadoc>
</target>
<target name="site" description="o Build manual from xdoc files" depends="test-report,checkstyle-report,javadoc">
<taskdef resource="net/sf/antcontrib/antlib.xml" classpath="${jar.file}" onerror="ignore"/>
<for param="xdoc.source">
<path>
<fileset dir="${xdoc.dir}" includes="*.xml"/>
</path>
<sequential>
<propertyregex property="xdoc.html" input="@{xdoc.source}"
regexp=".*[\\/]xdoc[\\/](.*)\.xml$" replace="\1.html" override="true"/>
<echo>${xdoc.html}</echo>
<java classname="org.apache.maven.doxia.cli.ConverterCli" classpathref="doxia.classpath">
<arg line="-from xdoc -to xhtml"/>
<arg value="-in"/>
<arg file="@{xdoc.source}"/>
<arg value="-out"/>
<arg file="${target.docs.dir}/manual/${xdoc.html}"/>
</java>
</sequential>
</for>
<copy todir="${target.docs.dir}/manual">
<fileset dir="${docs.dir}" includes="**/*.html"/>
</copy>
</target>
<target name="dist-stage" description="o Stage distribution" depends="site">
<mkdir dir="${target.stage.dir}"/>
<mkdir dir="${target.stage.dir}/lib"/>
<copy file="${jar.file}"
tofile="${target.stage.dir}/${ivy.module}-${ivy.revision}.jar"/>
<copy todir="${target.stage.dir}">
<fileset dir="${root.dir}" includes="README.txt"/>
<fileset dir="${target.dir}" includes="docs/**/*"/>
</copy>
<copy todir="${target.stage.dir}/lib" flatten="true">
<fileset refid="runtime.fileset"/>
</copy>
</target>
<target name="zip" depends="dist-stage">
<mkdir dir="${dist.dir}"/>
<zip file="${dist.dir}/${ivy.module}-${ivy.revision}-bin.zip">
<zipfileset prefix="ant-contrib" dir="${target.stage.dir}"
includes="**/*"/>
</zip>
<zip file="${dist.dir}/${ivy.module}-${ivy.revision}-src.zip">
<zipfileset prefix="ant-contrib"
dir="${root.dir}"
includes="**/*"
excludes="target,target/**/*,dist,dist/**/*"/>
</zip>
</target>
<target name="tar.gz" depends="dist-stage">
<mkdir dir="${dist.dir}"/>
<tar destfile="${dist.dir}/${ivy.module}-${ivy.revision}-bin.tar.gz"
compression="gzip">
<tarfileset prefix="ant-contrib"
dir="${target.stage.dir}"
includes="**/*"/>
</tar>
<tar destfile="${dist.dir}/${ivy.module}-${ivy.revision}-bin.tar.bz2"
compression="bzip2">
<tarfileset prefix="ant-contrib"
dir="${target.stage.dir}"
includes="**/*"/>
</tar>
<tar destfile="${dist.dir}/${ivy.module}-${ivy.revision}-src.tar.gz"
compression="gzip">
<tarfileset prefix="ant-contrib"
dir="${root.dir}"
includes="**/*"
excludes="target,target/**/*,dist,dist/**/*"/>
</tar>
<tar destfile="${dist.dir}/${ivy.module}-${ivy.revision}-src.tar.bz2"
compression="bzip2">
<tarfileset prefix="ant-contrib"
dir="${root.dir}"
includes="**/*"
excludes="target,target/**/*,dist,dist/**/*"/>
</tar>
</target>
<target name="package" description="o Package and checksum the distribution" depends="tar.gz,zip">
<checksum fileext=".md5">
<fileset dir="${dist.dir}">
<include name="*.zip"/>
<include name="*.tar.bz2"/>
<include name="*.tar.gz"/>
</fileset>
</checksum>
</target>
<target name="dist" depends="package"/>
<target name="clean">
<delete includeemptydirs="true" failonerror="false">
<fileset dir="${target.dir}" includes="**/*"/>
<fileset dir="${dist.dir}" includes="**/*"/>
</delete>
</target>
</project>