-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
407 lines (352 loc) · 23.2 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
403
404
405
406
407
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- =============================================================================================================== -->
<!-- Build file for the muCommander File API. -->
<!-- -->
<!-- Author: Nicolas Rinaudo -->
<!-- =============================================================================================================== -->
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="muCommander File" default="release">
<!-- = API properties ========================================================================================== -->
<!-- =========================================================================================================== -->
<!-- Library's name -->
<property name="api.name" value="muCommander commons File"/>
<!-- Library's vendor. -->
<property name="api.vendor" value="Maxence Bernard"/>
<!-- Library's version. -->
<property name="api.version" value="1.0.0"/>
<!-- = Java properties ========================================================================================= -->
<!-- =========================================================================================================== -->
<!-- Required version of the Java language. -->
<property name="source.version" value="1.5"/>
<!-- Character encoding of the source files. -->
<property name="source.encoding" value="UTF-8"/>
<!-- = Project structure ======================================================================================= -->
<!-- =========================================================================================================== -->
<!-- Source directory. -->
<property name="src" location="src"/>
<!-- Test sources directory. -->
<property name="src.test" location="${src}/test"/>
<!-- Main sources directory. -->
<property name="src.main" location="${src}/main"/>
<!-- Main resources directory. -->
<property name="res" location="res"/>
<!-- Ivy resources directory. -->
<property name="res.ivy" location="${res}/ivy"/>
<!-- Runtime resources directory. -->
<property name="res.runtime" location="${res}/runtime"/>
<!-- External libraries directory. -->
<property name="lib" location="lib"/>
<!-- Libraries required at runtime. -->
<property name="lib.runtime" location="${lib}/runtime"/>
<!-- External libraries used for tests. -->
<property name="lib.test" location="${lib}/test"/>
<!-- External tools. -->
<property name="lib.tools" location="${lib}/tools"/>
<!-- Where to store temporary files. -->
<property name="tmp" location="tmp"/>
<!-- Where to store the main source's code compilation output. -->
<property name="tmp.main" location="${tmp}/main"/>
<!-- Where to store the test source's code compilation output. -->
<property name="tmp.test" location="${tmp}/test"/>
<!-- Where to store temporary Cobertura files. -->
<property name="tmp.cobertura" location="${tmp}/cobertura"/>
<!-- Where to store various project reports. -->
<property name="reports" location="reports"/>
<!-- Where to store Javac reports. -->
<property name="javac.reports" location="${reports}/javac"/>
<!-- Where to store TestNG reports. -->
<property name="testng.reports" location="${reports}/testng"/>
<!-- Where to store Cobertura reports. -->
<property name="cobertura.reports" location="${reports}/cobertura"/>
<!-- Where to store Checkstyle reports. -->
<property name="checkstyle.reports" location="${reports}/checkstyle"/>
<!-- Where to store CPD reports. -->
<property name="cpd.reports" location="${reports}/cpd"/>
<!-- Where to store FindBugs reports. -->
<property name="findbugs.reports" location="${reports}/findbugs"/>
<!-- Where to store PMD reports. -->
<property name="pmd.reports" location="${reports}/pmd"/>
<!-- Where to store Ivy dependency reports. -->
<property name="ivy.reports" location="${reports}/ivy"/>
<!-- Where to store JavaNCSS reports. -->
<property name="javancss.reports" location="${reports}/javancss"/>
<!-- Where to store the API's Javadoc. -->
<property name="docs" location="docs"/>
<!-- Where to store distribution files. -->
<property name="dist" location="dist"/>
<!-- JAR distribution file. -->
<property name="dist.jar" location="${dist}/com.mucommander.commons.file.jar"/>
<!-- Documentation distribution file. -->
<property name="dist.doc" location="${dist}/com.mucommander.commons.file-javadoc.jar"/>
<!-- Source distribution file. -->
<property name="dist.source" location="${dist}/com.mucommander.commons.file-sources.jar"/>
<!-- Ivy dependencies retrieval pattern. -->
<property name="ivy.retrieve.pattern" value="${lib}/[conf]/[organisation]/[artifact].[ext]"/>
<!-- Path to the Ivy settings file. -->
<property name="ivy.settings.file" value="${res.ivy}/ivysettings.xml"/>
<!-- Runtime classpath. -->
<path id="lib.runtime">
<fileset dir="${lib.runtime}" includes="**/*.jar"/>
</path>
<!-- Test classpath. -->
<path id="lib.test">
<fileset dir="${lib.test}" includes="**/*.jar"/>
</path>
<!-- Tools classpath. -->
<path id="lib.tools">
<fileset dir="${lib.tools}" includes="**/*.jar"/>
</path>
<!-- = Compilation targets ===================================================================================== -->
<!-- =========================================================================================================== -->
<target name="compile" depends="retrieve-runtime" description="Compiles the library's sources">
<echo>Compiling sources...</echo>
<mkdir dir="${tmp.main}"/>
<mkdir dir="${javac.reports}"/>
<record name="${javac.reports}/javac.log" action="start"/>
<javac destdir="${tmp.main}" debug="on" deprecation="on"
encoding="${source.encoding}" source="${source.version}" target="${source.version}"
srcdir="${src.main}" classpathref="lib.runtime">
<compilerarg value="-Xlint:unchecked"/>
</javac>
<record name="${javac.reports}/javac.log" action="stop"/>
<copy todir="${tmp.main}">
<fileset dir="${res.runtime}"/>
</copy>
</target>
<target name="compile-tests" depends="compile,retrieve-test">
<echo>Compiling test sources...</echo>
<mkdir dir="${tmp.test}"/>
<javac destdir="${tmp.test}" debug="on" deprecation="on"
encoding="${source.encoding}" source="${source.version}" target="${source.version}"
srcdir="${src.test}">
<classpath>
<pathelement location="${tmp.main}"/>
<path refid="lib.test"/>
</classpath>
</javac>
<!-- Defines the Cobertura Ant task and instruments the non-test code. -->
<taskdef classpathref="lib.test" resource="net/sourceforge/cobertura/ant/antlib.xml"/>
<echo>Instrumenting source code...</echo>
<mkdir dir="${tmp.cobertura}"/>
<mkdir dir="${cobertura.reports}"/>
<instrument todir="${tmp.cobertura}" datafile="${tmp.cobertura}/cobertura.ser">
<fileset dir="${tmp.main}"/>
</instrument>
</target>
<!-- = Test targets ============================================================================================ -->
<!-- =========================================================================================================== -->
<target name="check-failed-tests">
<condition property="testng.suite" value="${testng.reports}/testng-failed.xml">
<available file="${testng.reports}/testng-failed.xml"/>
</condition>
<property name="testng.suite" value="${src.test}/testng.xml"/>
</target>
<target name="locate-properties">
<condition property="test.properties" else="test_template.properties">
<available file="test.properties"/>
</condition>
<echo>Using test properties file: ${test.properties}</echo>
</target>
<target name="test" depends="compile-tests,locate-properties,check-failed-tests" description="Runs the library's tests.">
<echo>Running self-tests...</echo>
<taskdef classpathref="lib.test" resource="testngtasks"/>
<mkdir dir="${testng.reports}"/>
<testng outputdir="${testng.reports}" haltonfailure="true" listeners="com.mucommander.commons.file.FileTestTransformer">
<jvmarg value="-Xmx256m" />
<sysproperty key="net.sourceforge.cobertura.datafile" file="${tmp.cobertura}/cobertura.ser"/>
<sysproperty key="java.awt.headless" value="true"/>
<sysproperty key="test.properties.file" value="${test.properties}"/>
<classpath>
<pathelement location="${tmp.cobertura}"/>
<pathelement location="${tmp.main}"/>
<pathelement location="${tmp.test}"/>
<path refid="lib.test"/>
</classpath>
<xmlfileset file="${testng.suite}"/>
</testng>
<echo>Generating coverage report...</echo>
<report format="xml" destdir="${cobertura.reports}"
srcdir="${src.main}" datafile="${tmp.cobertura}/cobertura.ser" encoding="${source.encoding}"/>
<report format="html" destdir="${cobertura.reports}"
srcdir="${src.main}" datafile="${tmp.cobertura}/cobertura.ser" encoding="${source.encoding}"/>
</target>
<!-- = Packaging targets ======================================================================================= -->
<!-- =========================================================================================================== -->
<target name="release" depends="compile,javadoc,jar" description="Generates the library's release artifacts.">
<echo>Packaging sources...</echo>
<jar jarfile="${dist.source}" basedir="${src.main}"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${dist}"/>
<!-- Retrieves the implementation version. -->
<exec executable="svnversion" failifexecutionfails="no" outputproperty="svn.version">
<arg value="."/>
<arg value="-n"/>
</exec>
<echo>Creating JAR file...</echo>
<jar jarfile="${dist.jar}">
<fileset dir="${tmp.main}"/>
<fileset dir="${res.runtime}"/>
<manifest>
<attribute name="Specification-Title" value="${api.name}"/>
<attribute name="Specification-Vendor" value="${api.vendor}"/>
<attribute name="Specification-Version" value="${api.version}"/>
<attribute name="Implementation-Title" value="${api.name}"/>
<attribute name="Implementation-Vendor" value="${api.vendor}"/>
<attribute name="Implementation-Version" value="${svn.version}"/>
</manifest>
</jar>
</target>
<!-- = Documentation targets =================================================================================== -->
<!-- =========================================================================================================== -->
<target name="javadoc" depends="retrieve-runtime">
<echo>Creating API javadoc...</echo>
<mkdir dir="${docs}"/>
<javadoc destdir="${docs}" author="true" windowtitle="${api.name}" doctitle="${api.name}" encoding="UTF-8"
access="protected" classpathref="lib.runtime">
<packageset dir="${src.main}" defaultexcludes="yes"/>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
</javadoc>
<echo>Packaging API javadoc...</echo>
<mkdir dir="${dist}"/>
<jar jarfile="${dist.doc}" basedir="${docs}"/>
</target>
<!-- = Publish to local repo = -->
<target name="publish" depends="release" description="Publish into local repository">
<property name="pub.ivy.file" value="${res.ivy}/ivy.xml"/>
<echo>Publishing jars to local repository ...</echo>
<ivy:publish pubrevision="${api.version}"
status="release"
resolver="local-repo"
srcivypattern="${pub.ivy.file}"
organisation="mucommander"
module="mucommander-commons-file"
overwrite="true"
update="true">
<artifacts pattern="${dist}/[artifact].[ext]"/>
</ivy:publish>
</target>
<!-- = Reports targets ========================================================================================= -->
<!-- =========================================================================================================== -->
<target name="reports" depends="checkstyle,pmd,cpd,javancss,findbugs,ivy,test" description="Generates all available reports."/>
<target name="javancss" depends="retrieve-tools" description='Generates JavaNCSS reports.'>
<echo>Generating JavaNCSS reports...</echo>
<taskdef name="javancss" classname="javancss.JavancssAntTask" classpathref="lib.tools"/>
<mkdir dir="${javancss.reports}"/>
<javancss srcdir="${src.main}" includes="**/*.java" generateReport="true"
outputfile="${javancss.reports}/javancss.xml" format="xml"/>
<xslt in="${javancss.reports}/javancss.xml" out="${javancss.reports}/javancss.html"
style="${lib.tools}/mucommander/javancss.xsl"/>
</target>
<target name="checkstyle" depends="compile,retrieve-tools" description='Generates CheckStyle reports.'>
<echo>Generating CheckStyle reports...</echo>
<mkdir dir="${checkstyle.reports}"/>
<taskdef resource="checkstyletask.properties" classpathref="lib.tools"/>
<checkstyle config="${lib.tools}/mucommander/checkstyle.xml" failOnViolation="false">
<fileset dir="${src.main}" includes="**/*.java"/>
<formatter type="xml" toFile="${checkstyle.reports}/checkstyle.xml"/>
<classpath>
<path refid="lib.runtime"/>
<pathelement location="${tmp.main}"/>
</classpath>
</checkstyle>
<xslt in="${checkstyle.reports}/checkstyle.xml" out="${checkstyle.reports}/checkstyle.html"
style="${lib.tools}/mucommander/checkstyle.xsl">
<param name="root" expression="${src.main}/"/>
</xslt>
</target>
<target name="pmd" depends="retrieve-tools,compile" description="Generates PMD reports.">
<echo>Generating PMD report...</echo>
<taskdef classpathref="lib.tools" name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"/>
<mkdir dir="${pmd.reports}"/>
<pmd encoding="${source.encoding}" rulesetfiles="${lib.tools}/mucommander/pmd.xml">
<formatter type="xml" toFile="${pmd.reports}/pmd.xml"/>
<auxclasspath path="${tmp.main}"/>
<auxclasspath refid="lib.runtime"/>
<fileset dir="${src.main}">
<include name="**/*.java"/>
</fileset>
</pmd>
<xslt in="${pmd.reports}/pmd.xml" out="${pmd.reports}/pmd.html"
style="${lib.tools}/mucommander/pmd.xsl">
<param name="root" expression="${src.main}/"/>
</xslt>
</target>
<target name="cpd" depends="retrieve-tools" description="Generates CPD reports.">
<echo>Generating CPD reports...</echo>
<taskdef name="cpd" classpathref="lib.tools" classname="net.sourceforge.pmd.cpd.CPDTask" />
<property file="${lib.tools}/mucommander/cpd.properties"/>
<mkdir dir="${cpd.reports}"/>
<cpd minimumTokenCount="${cpd.tokens}" encoding="${source.encoding}" format="xml" outputFile="${cpd.reports}/cpd.xml"
ignoreidentifiers="${cpd.ignoreIdentifiers}" ignoreliterals="${cpd.ignoreLiterals}">
<fileset dir="${src.main}">
<include name="**/*.java"/>
</fileset>
</cpd>
<xslt in="${cpd.reports}/cpd.xml" out="${cpd.reports}/cpd.html"
style="${lib.tools}/mucommander/cpd.xsl">
<param name="root" expression="${src.main}/"/>
</xslt>
</target>
<target name="findbugs" depends="retrieve-tools" description="Generates FindBugs reports.">
<echo>Generating FindBugs reports...</echo>
<taskdef classpathref="lib.tools" name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
<mkdir dir="${findbugs.reports}"/>
<findbugs classpathref="lib.tools" output="xml:withMessages" outputFile="${findbugs.reports}/findbugs.xml"
effort="max" jvmargs="-Xmx512m" excludefilter="${lib.tools}/mucommander/findbugs.xml">
<auxClasspath>
<path refid="lib.runtime"/>
</auxClasspath>
<sourcePath path="${src.main}"/>
<class location="${tmp.main}"/>
</findbugs>
<xslt in="${findbugs.reports}/findbugs.xml" out="${findbugs.reports}/findbugs.html"
style="${lib.tools}/mucommander/findbugs.xsl"/>
</target>
<target name="ivy" depends="ivy-config" description="Generates Ivy dependency reports." unless="ivy.offline">
<echo>Generating Ivy dependency report...</echo>
<mkdir dir="${ivy.reports}"/>
<ivy:report todir="${ivy.reports}" xml="true" graph="false" conf="runtime,test,tools"/>
</target>
<!-- = Maintenance targets ===================================================================================== -->
<!-- =========================================================================================================== -->
<target name="all" description="Generates all reports and release files." depends="reports,release"/>
<target name="clean" description="Deletes all temporary files.">
<echo>Deleting temporary files...</echo>
<delete dir="${tmp}"/>
<delete dir="${dist}"/>
<delete dir="${reports}"/>
<delete dir="${docs}"/>
<delete includeEmptyDirs="true">
<fileset dir="." includes="**/*~" defaultexcludes="no"/>
</delete>
</target>
<target name="clean-all" depends="clean" description="Deletes all libraries imported by Ivy and temporary files.">
<echo>Deleting external libraries...</echo>
<delete dir="${lib}"/>
</target>
<!-- = Dependencies targets ==================================================================================== -->
<!-- =========================================================================================================== -->
<target name="offline" description="Forces usage of the ivy cache.">
<property name="ivy.cache.ttl.default" value="eternal"/>
<property name="ivy.offline" value="true"/>
</target>
<target name="synchronize" description="Forces synchronisation of all dependencies."
depends="retrieve-runtime,retrieve-test,retrieve-tools"/>
<target name="ivy-config" unless="ivy.offline">
<echo>Resolving dependencies repository...</echo>
<ivy:configure/>
<ivy:resolve file="${res.ivy}/ivy.xml" haltonfailure="false"/>
</target>
<target name="retrieve-runtime" depends="ivy-config" unless="ivy.offline">
<echo>Retrieving runtime libraries...</echo>
<ivy:retrieve symlink="true" conf="runtime" type="jar"/>
</target>
<target name="retrieve-tools" depends="ivy-config" unless="ivy.offline">
<echo>Retrieving external tools...</echo>
<ivy:retrieve symlink="true" conf="tools" type="jar,conf"/>
</target>
<target name="retrieve-test" depends="ivy-config" unless="ivy.offline">
<echo>Retrieving test dependencies...</echo>
<ivy:retrieve symlink="true" conf="test" type="jar"/>
</target>
</project>