-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild.xml
More file actions
232 lines (215 loc) · 8.34 KB
/
build.xml
File metadata and controls
232 lines (215 loc) · 8.34 KB
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
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Sample-Project" basedir="." default="all" xmlns:jacoco="antlib:org.jacoco.ant">
<property file="build.properties"/>
<path id="tool.path">
<fileset dir="${tool.jars}">
<include name="*.jar"/>
</fileset>
</path>
<path id="pmd.path">
<fileset dir="${pmd.home}/lib">
<include name="*.jar"/>
</fileset>
</path>
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
classpath="${tool.jars}/checkstyle-13.3.0-all.jar"/>
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask"
classpathref="pmd.path"/>
<taskdef name="cpd" classname="net.sourceforge.pmd.ant.CPDTask"
classpathref="pmd.path"/>
<taskdef resource="edu/umd/cs/findbugs/anttask/tasks.properties"
classpath="${spotbugs.home}/lib/spotbugs-ant.jar"/>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${tool.jars}/jacocoant.jar"/>
</taskdef>
<target name="help"
description="Display detailed usage information">
<echo>To list all of the available build targets:</echo>
<echo>ant -p</echo>
<echo>To invoke a specific target, such as 'clean':</echo>
<echo>ant clean</echo>
</target>
<target name="all" depends="clean,init,dist,doc,quality"
description="Invoke all build and quality targets"/>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile & dist -->
<mkdir dir="${build.dir}"/>
<mkdir dir="${class.dir}"/>
<mkdir dir="${dist.dir}"/>
<!-- Create the directory structure used by javadoc -->
<mkdir dir="${doc.dir}"/>
<!-- Create the directory structure used by tests -->
<mkdir dir="${results.dir}"/>
</target>
<target name="clean"
description="Delete generated files and directories">
<delete dir="${build.dir}"/>
<delete dir="${class.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${doc.dir}"/>
<delete dir="${results.dir}"/>
</target>
<target name="compile" depends="init"
description="Compile the application">
<javac destdir="${class.dir}"
debug="true"
includeantruntime="false">
<src path="${src.dir}"/>
<classpath path="${junit.jar}"/>
</javac>
</target>
<target name="quality" depends="init,pmd,cpd,spotbugs,checkstyle,test"
description="Run all quality checks: PMD, CPD, SpotBugs, Checkstyle, JUnit">
<echo>Results placed in ${results.dir}</echo>
</target>
<target name="junit" depends="test"
description="Synonym for test (runs junit tests)"/>
<target name="test" depends="compile"
description="Run JUnit 5 tests">
<echo>Running JUnit with JaCoCo</echo>
<mkdir dir="${junit.results.dir}"/>
<mkdir dir="${jacoco.results.dir}"/>
<jacoco:coverage destfile="${jacoco.exec.file}">
<java classname="org.junit.platform.console.ConsoleLauncher"
fork="true"
failonerror="false">
<classpath>
<pathelement location="${class.dir}"/>
<pathelement location="${junit.jar}"/>
</classpath>
<arg value="execute"/>
<arg value="--scan-classpath=${class.dir}"/>
<arg value="--reports-dir=${junit.results.dir}"/>
<arg value="--exclude-engine=junit-vintage"/>
</java>
</jacoco:coverage>
<jacoco:report>
<executiondata>
<file file="${jacoco.exec.file}"/>
</executiondata>
<structure name="${project.name} Test Coverage Report">
<classfiles>
<fileset dir="${class.dir}">
<exclude name="**/*Test.class"/>
</fileset>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${src.dir}"/>
</sourcefiles>
</structure>
<html destdir="${jacoco.results.dir}"/>
<csv destfile="${jacoco.results.dir}/jacoco_results.csv"/>
<xml destfile="${jacoco.results.dir}/jacoco_results.xml"/>
</jacoco:report>
<junitreport todir="${junit.results.dir}">
<fileset dir="${junit.results.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.results.dir}"/>
</junitreport>
<echo message="JUnit report: ${junit.results.dir}/index.html"/>
<echo message="JaCoCo report: ${jacoco.results.dir}/index.html"/>
</target>
<target name="junit-simple" depends="compile"
description="Run one JUnit 5 test class">
<java classname="org.junit.platform.console.ConsoleLauncher"
fork="true"
failonerror="false"
output="${results.dir}/junit-simple.txt">
<classpath>
<pathelement location="${class.dir}"/>
<pathelement location="${junit.jar}"/>
</classpath>
<arg value="execute"/>
<arg value="--scan-classpath=${class.dir}"/>
<arg value="--reports-dir=${junit.results.dir}"/>
<arg value="--exclude-engine=junit-vintage"/>
</java>
</target>
<target name="pmd" depends="init, doc"
description="Analyze source using PMD">
<echo>Running PMD</echo>
<pmd noCache="true">
<ruleset>tools/pmd/ruleset.xml</ruleset>
<formatter type="xml"
toFile="${results.dir}/pmd_report.xml"/>
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</pmd>
<xslt in="${results.dir}/pmd_report.xml"
out="${results.dir}/pmd_report.html"
style="${pmd.home}/pmd-report.xsl">
<param name="linkPrefix" expression="../${doc.dir}/src-html/"/>
</xslt>
</target>
<target name="cpd" depends="init"
description="Analyze source using CPD">
<echo>Running CPD</echo>
<cpd minimumTokenCount="100"
outputFile="${results.dir}/cpd.txt"
format="text">
<fileset dir="${src.dir}">
<include name="**/*.java"/>
</fileset>
</cpd>
</target>
<target name="checkstyle" depends="init"
description="Validate style using chestyle">
<echo>Running Checkstyle</echo>
<checkstyle config="${checkstyle.dir}/checkstyle-master.xml"
failureProperty="checkstyle.failure"
failOnViolation="false">
<fileset dir="${src.dir}" includes="**/*.java"/>
<property key="checkstyle.dir" value="${checkstyle.dir}"/>
<property key="checkstyle.suppressions.file" value="${checkstyle.dir}/${checkstyle.suppressions.file}"/>
<property key="checkstyle.importcontrol.file" value="${checkstyle.dir}/${checkstyle.importcontrol.file}"/>
<property key="translation.severity" value="${translation.severity}"/>
<formatter type="plain" tofile="${results.dir}/checkstyle_report.txt"/>
<formatter type="xml" tofile="${results.dir}/checkstyle_report.xml"/>
</checkstyle>
<xslt in="${results.dir}/checkstyle_report.xml"
out="${results.dir}/checkstyle_report.html"
style="${checkstyle.dir}/contrib/checkstyle-noframes.xsl"/>
</target>
<target name="spotbugs" depends="compile"
description="Analyze using SpotBugs">
<echo>Running SpotBugs</echo>
<spotbugs home="${spotbugs.home}"
output="html"
outputFile="${results.dir}/spotbugs.html"
reportLevel="medium"
effort="default">
<auxClasspath path="${junit.jar}" />
<sourcePath path="${src.dir}" />
<class location="${class.dir}" />
</spotbugs>
</target>
<target name="javadoc" depends="doc"
description="Synonym for doc (generates documentation, including javadoc)"/>
<target name="doc" depends="compile"
description="Generate documentation, including javadoc">
<echo>Creating API Documentation</echo>
<javadoc destdir="${doc.dir}"
author="true"
version="true"
use="true"
private="true"
linksource="yes"
classpath="${class.dir}:${junit.jar}">
<fileset dir="src" defaultexcludes="yes">
<include name="*.java"/>
</fileset>
</javadoc>
</target>
<target name="dist" depends="compile"
description="Generate the distribution/jar">
<echo>Generating Distribution</echo>
<!-- Consider using zipfileset -->
<jar destfile="${dist.dir}/${project.name}${DSTAMP}.jar"
basedir="${class.dir}"
excludes="**/*Test.class"/>
</target>
</project>