-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
291 lines (259 loc) · 13.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
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2016 Matt Bertolini
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="jxr-ant" basedir="." default="build" xmlns="antlib:org.apache.tools.ant"
xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:ac="antlib:net.sf.antcontrib" xmlns:jacoco="antlib:org.jacoco.ant"
xmlns:findbugs="antlib:edu.umd.cs.findbugs.anttask" xmlns:jxr="antlib:com.mattbertolini.jxr.ant">
<property file="build.properties"/>
<condition property="offline" value="true" else="false">
<not>
<http url="http://www.google.com/"/>
</not>
</condition>
<!-- Private targets -->
<target name="check-configuration">
<fail message="Need Ant version 1.8.0 or later to run.">
<condition>
<not>
<antversion atleast="1.8"/>
</not>
</condition>
</fail>
<echo level="info">Offline Mode: ${offline}</echo>
</target>
<target name="clean" depends="check-configuration" if="${param.full.build}">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="init" depends="clean">
<mkdir dir="${lib.default.dir}"/>
<mkdir dir="${lib.provided.dir}"/>
<mkdir dir="${lib.test.dir}"/>
<mkdir dir="${lib.build.dir}"/>
<mkdir dir="${build.temp.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.instrumentedclasses.dir}"/>
<mkdir dir="${build.test.classes.dir}"/>
<mkdir dir="${build.resources.dir}"/>
<mkdir dir="${build.test.resources.dir}"/>
<mkdir dir="${build.javadoc.dir}"/>
<mkdir dir="${build.reports.dependency.dir}"/>
<mkdir dir="${build.reports.coverage.dir}"/>
<mkdir dir="${build.reports.unittest.dir}"/>
<mkdir dir="${build.reports.findbugs.dir}"/>
<mkdir dir="${build.reports.xref.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="download-ivy" depends="init" unless="${offline}">
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${project.ivy.version}/ivy-${project.ivy.version}.jar" dest="${lib.build.dir}/ivy-${project.ivy.version}.jar" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy">
<path id="ivy-classpath">
<fileset dir="${lib.build.dir}"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy-classpath"/>
</target>
<target name="retrieve-dependencies" depends="init-ivy" unless="${offline}">
<ivy:configure file="${project.home}/ivysettings-ant.xml"/>
<ivy:resolve file="${project.home}/ivy.xml" haltonfailure="false"/>
<ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision](-[classifier]).[ext]" sync="true" haltonfailure="false"/>
<ivy:report todir="${build.reports.dependency.dir}"/>
<ivy:artifactproperty name="dependency.[conf].[artifact]" value="${lib.dir}/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
</target>
<target name="create-paths" depends="retrieve-dependencies">
<path id="build-classpath">
<fileset dir="${lib.build.dir}"/>
</path>
<path id="findbugs-classpath">
<fileset dir="${lib.findbugs.dir}"/>
</path>
<path id="default-classpath">
<fileset dir="${lib.default.dir}"/>
</path>
<path id="provided-classpath">
<fileset dir="${lib.provided.dir}"/>
</path>
<path id="test-classpath">
<fileset dir="${lib.test.dir}"/>
</path>
<path id="compile-source-classpath">
<path refid="default-classpath"/>
<path refid="provided-classpath"/>
</path>
<path id="compile-tests-classpath">
<path location="${build.classes.dir}"/>
<path refid="test-classpath"/>
<path refid="default-classpath"/>
<path refid="provided-classpath"/>
</path>
<path id="run-unit-tests-classpath">
<path location="${build.instrumentedclasses.dir}"/>
<path location="${build.resources.dir}"/>
<path location="${build.test.classes.dir}"/>
<path location="${build.test.resources.dir}"/>
<path refid="test-classpath"/>
<path refid="default-classpath"/>
<path refid="build-classpath"/>
</path>
</target>
<target name="load-third-party-tasks" depends="create-paths">
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="build-classpath" uri="antlib:net.sf.antcontrib"/>
<taskdef resource="org/jacoco/ant/antlib.xml" classpathref="build-classpath" uri="antlib:org.jacoco.ant"/>
<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties" classpathref="findbugs-classpath" uri="antlib:edu.umd.cs.findbugs.anttask"/>
<taskdef name="jxr" classname="com.mattbertolini.jxr.ant.JxrTask" uri="antlib:com.mattbertolini.jxr.ant">
<classpath>
<path location="${build.classes.dir}"/>
<path location="${build.resources.dir}"/>
<path refid="default-classpath"/>
</classpath>
</taskdef>
</target>
<target name="sync-resources" depends="init">
<sync todir="${build.resources.dir}">
<fileset dir="${src.main.resources.dir}"/>
</sync>
<sync todir="${build.test.resources.dir}">
<fileset dir="${src.test.resources.dir}"/>
</sync>
</target>
<target name="compile-source" depends="create-paths">
<depend srcdir="${src.main.java.dir}" destdir="${build.classes.dir}" cache="${build.temp.dir}" closure="true">
<include name= "**/*.java"/>
</depend>
<javac srcdir="${src.main.java.dir}" destdir="${build.classes.dir}" source="1.7" target="1.7" fork="true" failonerror="true" includeantruntime="false" debug="true" encoding="UTF-8">
<classpath refid="compile-source-classpath"/>
</javac>
</target>
<target name="compile-tests" depends="compile-source">
<depend srcdir="${src.test.java.dir}" destdir="${build.test.classes.dir}" cache="${build.temp.dir}" closure="true">
<include name= "**/*.java"/>
</depend>
<javac srcdir="${src.test.java.dir}" destdir="${build.test.classes.dir}" source="1.7" target="1.7" fork="true" failonerror="true" includeantruntime="false" debug="true" encoding="UTF-8">
<classpath refid="compile-tests-classpath"/>
</javac>
</target>
<target name="run-unit-tests" depends="compile-source, compile-tests, load-third-party-tasks, sync-resources">
<sync todir="${build.instrumentedclasses.dir}">
<fileset dir="${build.classes.dir}"/>
</sync>
<jacoco:coverage destfile="${build.reports.coverage.dir}/${project.name}-coverage.exec">
<junit haltonerror="false" haltonfailure="false" printsummary="true" errorproperty="test.failed" failureproperty="test.failed" fork="true" forkmode="once">
<classpath refid="run-unit-tests-classpath"/>
<formatter type="xml"/>
<batchtest fork="true" todir="${build.reports.unittest.dir}">
<fileset dir="${build.test.classes.dir}">
<include name="**/*Test.class"/>
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
<junitreport todir="${build.reports.unittest.dir}">
<fileset dir="${build.reports.unittest.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${build.reports.unittest.dir}"/>
</junitreport>
<jacoco:report>
<jacoco:executiondata>
<file file="${build.reports.coverage.dir}/${project.name}-coverage.exec"/>
</jacoco:executiondata>
<jacoco:structure name="${project.name}">
<jacoco:classfiles>
<fileset dir="${build.instrumentedclasses.dir}"/>
</jacoco:classfiles>
<jacoco:sourcefiles encoding="UTF-8" tabwidth="4">
<fileset dir="${src.main.java.dir}"/>
</jacoco:sourcefiles>
</jacoco:structure>
<jacoco:html destdir="${build.reports.coverage.dir}" encoding="UTF-8" locale="en_US"/>
<jacoco:xml destfile="${build.reports.coverage.dir}/${project.name}-coverage.xml" encoding="UTF-8"/>
</jacoco:report>
<fail if="test.failed">One or more unit tests failed/errored. Check ${build.reports.unittest.dir} for details.</fail>
</target>
<target name="run-findbugs" depends="create-paths, load-third-party-tasks, compile-source"> <!-- ,compile-tests -->
<path id="aux-classpath">
<path refid="default-classpath"/>
<path refid="provided-classpath"/>
<path refid="test-classpath"/>
<path refid="build-classpath"/>
</path>
<findbugs:findbugs classpathref="findbugs-classpath" pluginlist="" output="xml:withMessages" outputFile="${build.reports.findbugs.dir}/${project.name}-findbugs.xml" jvmargs="-Xms${findbugs.mem.initial} -Xmx${findbugs.mem.max}">
<findbugs:class location="${build.classes.dir}"/>
<findbugs:class location="${build.test.classes.dir}"/>
<findbugs:auxClasspath refid="aux-classpath"/>
<findbugs:sourcePath path="${src.main.java.dir}"/>
<findbugs:sourcePath path="${src.test.java.dir}"/>
</findbugs:findbugs>
<xslt in="${build.reports.findbugs.dir}/${project.name}-findbugs.xml" out="${build.reports.findbugs.dir}/${project.name}-findbugs.html">
<style>
<url url="jar:file:${dependency.findbugs.findbugs}!/default.xsl"/>
</style>
</xslt>
</target>
<target name="compile-javadoc" depends="init, load-third-party-tasks">
<ac:outofdate>
<ac:sourcefiles>
<fileset dir="${src.main.java.dir}" includes="**/*.java"/>
</ac:sourcefiles>
<ac:mapper type="glob" dir="${src.main.java.dir}" from="*.java" to="${build.javadoc.dir}/*.html"/>
<ac:sequential>
<javadoc destdir="${build.javadoc.dir}" failonerror="true" classpathref="compile-source-classpath" windowtitle="JXR Ant Documentation" charset="UTF-8">
<packageset dir="${src.main.java.dir}" defaultexcludes="true"/>
<link href="http://docs.oracle.com/javase/6/docs/api/"/>
<link href="http://maven.apache.org/jxr/apidocs/"/>
<doctitle>JXR Ant Documentation</doctitle>
</javadoc>
</ac:sequential>
</ac:outofdate>
</target>
<target name="compile-xref-doc" depends="init, create-paths, compile-source, sync-resources, load-third-party-tasks">
<jxr:jxr destdir="${build.reports.xref.dir}" sourcepath="${src.main.java.dir}" inputencoding="UTF-8" outputencoding="UTF-8"/>
</target>
<target name="make-jar" depends="compile-source, sync-resources">
<jar destfile="${dist.dir}/${project.name}-${project.version}.jar">
<fileset dir="${build.classes.dir}"/>
<fileset dir="${build.resources.dir}"/>
<manifest>
<attribute name="Implementation-Title" value="${project.name}"/>
<attribute name="Implementation-Version" value="${project.version}"/>
</manifest>
</jar>
</target>
<target name="make-javadoc-jar" depends="compile-javadoc">
<jar destfile="${dist.dir}/${project.name}-${project.version}-javadoc.jar">
<fileset dir="${build.javadoc.dir}"/>
</jar>
</target>
<target name="make-sources-jar">
<jar destfile="${dist.dir}/${project.name}-${project.version}-sources.jar">
<fileset dir="${src.main.java.dir}"/>
</jar>
</target>
<target name="make-pom" depends="retrieve-dependencies">
<ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${dist.dir}/${project.name}-${project.version}.pom" artifactpackaging="jar" templatefile="pom-template.xml" conf="default, provided">
<ivy:mapping conf="default" scope="compile"/>
<ivy:mapping conf="provided" scope="provided"/>
</ivy:makepom>
</target>
<target name="make-artifacts" depends="make-jar, make-javadoc-jar, make-sources-jar, make-pom"/>
<!-- Public targets -->
<target name="build" description="Runs a build and makes artifacts.">
<antcall>
<param name="param.full.build" value="true"/>
<target name="run-unit-tests"/>
<target name="run-findbugs"/>
<target name="compile-xref-doc"/>
<target name="make-artifacts"/>
</antcall>
</target>
</project>