This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
278 lines (227 loc) · 10.7 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="ant-sfdx" default="default" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless" xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:jacoco="antlib:org.jacoco.ant" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3">
<description>Builds, tests, and runs the project ant-sfdx.</description>
<property name="verbosity" value="info" />
<property environment="env" />
<property name="bin.dir" value="${basedir}/build" />
<property name="doc.dir" value="${basedir}/docs" />
<property name="ivy.dir" value="${basedir}/ivy" />
<property name="tmp.dir" value="${basedir}/tmp" />
<property name="_tmp.dir" value="${basedir}/.tmp" />
<property name="ivy.lib.dir" value="${ivy.dir}/lib" />
<property name="src.dir" value="${basedir}/src/main" />
<property name="test.dir" value="${basedir}/src/test" />
<property name="tmp.bin.dir" value="${tmp.dir}/bin" />
<property name="tmp.obj.dir" value="${tmp.dir}/obj" />
<property name="tmp.out.dir" value="${tmp.dir}/out" />
<property name="tmp.test.dir" value="${tmp.dir}/test" />
<property name="tmp.out.bin.dir" value="${tmp.out.dir}/bin" />
<import file="nbproject/build-impl.xml" />
<!-- prepare -->
<target name="prepare" depends="prepare.log" />
<target name="-pre-init" depends="prepare.log,prepare.dependencies" />
<target name="prepare.tasks.ivy">
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
<classpath>
<pathelement location="${ivy.dir}/ivy.jar" />
<fileset dir="${ivy.lib.dir}/build">
<include name="**/*.jar" />
</fileset>
</classpath>
</taskdef>
</target>
<target name="prepare.dependencies" depends="prepare.tasks.ivy">
<ivy:retrieve pattern="${ivy.lib.dir}/[conf]/[artifact].[ext]" log="quiet" />
<pathconvert property="ivy.compile.classpath" dirsep="/" pathsep=":">
<path>
<fileset dir="${ivy.lib.dir}/compile" includes="**/*.jar" />
</path>
<map from="${basedir}${file.separator}" to="" />
</pathconvert>
<pathconvert property="ivy.test.classpath" dirsep="/" pathsep=":">
<path>
<fileset dir="${ivy.lib.dir}/test" includes="**/*.jar" />
</path>
<map from="${basedir}${file.separator}" to="" />
</pathconvert>
<uptodate property="prepare.ivy.nbproject.isuptodate" srcfile="${basedir}/ivy.xml" targetfile="nbproject/project.properties" />
<propertyfile file="nbproject/project.properties" unless:set="prepare.ivy.nbproject.isuptodate">
<entry operation="=" key="ivy.compile.classpath" value="${ivy.compile.classpath}" />
<entry operation="=" key="ivy.test.classpath" value="${ivy.test.classpath}" />
</propertyfile>
</target>
<target name="prepare.tasks.jacoco" depends="prepare.dependencies">
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath path="${ivy.test.classpath}" />
</taskdef>
</target>
<target name="prepare.log">
<record name="${basedir}/build.log" loglevel="${verbosity}" append="false" />
</target>
<target name="prepare.tmp">
<mkdir dir="${tmp.dir}" />
</target>
<target name="prepare.jacoco" depends="prepare.tasks.jacoco">
<delete file="${build.test.results.dir}/jacoco.exec" quiet="true" />
<property name="jacoco.exec" value="${build.test.results.dir}/jacoco.exec" />
<jacoco:agent property="test.jvmargs" destfile="${jacoco.exec}" append="true" />
</target>
<target name="prepare.version" if="env.PACKAGE_VERSION">
<property name="package.version" value="${env.PACKAGE_VERSION}" />
<echo message="Package version is ${package.version}" />
<loadresource property="package.revision">
<string value="${package.version}" />
<filterchain>
<tokenfilter>
<replaceregex pattern="(\d+\.\d+)\.\d+" replace="\1" />
</tokenfilter>
</filterchain>
</loadresource>
<replaceregexp file="${basedir}/ivy.xml" match="(revision=").*(")" replace="\1${package.revision}\2" byline="true" />
<replaceregexp match="(<span\s+class="version-number">).*?(</span>)" replace="\1${package.revision}\2" flags="gs">
<fileset dir="${doc.dir}" includes="**/*.html"/>
</replaceregexp>
<replaceregexp file="${basedir}/manifest.mf" match="^(Implementation-Version:\s).*$" replace="\1${package.version}" byline="true" />
</target>
<!-- Redefinition allows to add jacoco agent parameters -->
<target depends="-init-macrodef-test-impl,-init-macrodef-junit-impl,-init-macrodef-testng-impl" name="-init-macrodef-test">
<macrodef name="test" uri="http://www.netbeans.org/ns/j2se-project/3">
<attribute default="${includes}" name="includes"/>
<attribute default="${excludes}" name="excludes"/>
<attribute default="**" name="testincludes"/>
<attribute default="" name="testmethods"/>
<sequential>
<j2seproject3:test-impl excludes="@{excludes}" includes="@{includes}" testincludes="@{testincludes}" testmethods="@{testmethods}">
<customize>
<classpath>
<path path="${run.test.classpath}"/>
</classpath>
<jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
<jvmarg line="${run.jvmargs}"/>
<jvmarg line="${run.jvmargs.ide}"/>
<jvmarg line="${test.jvmargs}"/>
</customize>
</j2seproject3:test-impl>
</sequential>
</macrodef>
</target>
<!-- clean (already defined by NetBeans) -->
<target name="-post-clean" depends="clean.tmp" />
<target name="clean.tmp">
<delete dir="${tmp.dir}" includeemptydirs="true" quiet="true" failonerror="false" />
</target>
<target name="clean.ivy">
<delete dir="${ivy.lib.dir}" includeemptydirs="true" quiet="true" failonerror="false" />
</target>
<!-- compile (already defined by NetBeans) -->
<target name="-pre-compile" depends="prepare.dependencies" />
<target name="-pre-compile-single" depends="prepare.dependencies" />
<!-- test (already defined by NetBeans) -->
<target name="-pre-test-run" if="have.tests" depends="init,prepare.jacoco">
<mkdir dir="${build.test.results.dir}" />
</target>
<target name="-pre-test-run-single" if="have.tests" depends="init,prepare.jacoco">
<mkdir dir="${build.test.results.dir}" />
</target>
<target name="test-report" if="have.tests" depends="init,test.report.junit,test.report.jacoco" />
<target name="test.report.junit" if="have.tests">
<junitreport todir="${tmp.dir}" tofile="junit-results.xml">
<fileset dir="${build.test.results.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${tmp.dir}/junit-results" />
</junitreport>
</target>
<target name="test.report.jacoco" if="have.tests">
<jacoco:report>
<executiondata>
<file file="${jacoco.exec}" />
</executiondata>
<structure name="${ant.project.name}">
<classfiles>
<fileset dir="${build.classes.dir}" />
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${file.reference.ant-sfdx-src}" />
</sourcefiles>
</structure>
<html destdir="${tmp.dir}/jacoco-results" locale="en" />
<xml destfile="${tmp.dir}/jacoco-results.xml" />
</jacoco:report>
</target>
<!-- Required by NetBeans (cf. https://issues.apache.org/jira/browse/NETBEANS-591) -->
<target name="debug-single-method" depends="debug-test-method" />
<!-- analyze -->
<target name="analyze" depends="prepare.log,analyze.pmd,analyze.cloc" description="Performs code analysis on the project." />
<target name="analyze.cloc" depends="prepare.tmp" description="Runs CLOC on the project.">
<exec executable="${_tmp.dir}/cloc.exe" osfamily="windows">
<arg value="--3" />
<arg line="--progress-rate=0" />
<arg value="--xml" />
<arg line="--exclude-dir=.tmp,.vscode,build,ivy,tmp" />
<arg line="--out "${tmp.dir}/cloc-results.xml"" />
<arg value="." />
</exec>
<exec executable="perl" osfamily="unix">
<arg line=""${_tmp.dir}/cloc.pl"" />
<arg value="--3" />
<arg line="--progress-rate=0" />
<arg value="--xml" />
<arg line="--exclude-dir=.tmp,.vscode,build,ivy,tmp" />
<arg line="--out "${tmp.dir}/cloc-results.xml"" />
<arg value="." />
</exec>
</target>
<target name="analyze.pmd" depends="prepare.tmp,prepare.dependencies,init" if="env.PMD_HOME" description="Runs PMD on the project.">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
<classpath>
<fileset dir="${env.PMD_HOME}/lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</taskdef>
<condition property="pmd.formatter" value="textcolor" else="text">
<os family="unix" />
</condition>
<pmd failOnRuleViolation="true" cacheLocation="${tmp.obj.dir}/pmd.cache">
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<sourceLanguage name="java" version="${javac.source}"/>
<ruleset>${basedir}/.ruleset.xml</ruleset>
<formatter type="${pmd.formatter}" toConsole="true" />
<formatter type="html" toFile="${tmp.dir}/pmd-results.html" />
<formatter type="xml" toFile="${tmp.dir}/pmd-results.xml" />
</pmd>
</target>
<!-- package -->
<target name="package" depends="prepare.log,prepare.version,jar,package.pom" description="Packages the project.">
<copy todir="${tmp.out.bin.dir}" preservelastmodified="true">
<resources>
<file file="${dist.jar}" />
<file file="${basedir}/ivy.xml" />
</resources>
</copy>
<zip destfile="${tmp.out.bin.dir}/${ant.project.name}.zip" compress="true" level="9" filesonly="true">
<resources>
<file file="${dist.jar}" />
<file file="${basedir}/ivy.xml" />
<file file="${ivy.runtime.classpath}" />
</resources>
<zipfileset dir="docs" prefix="docs" />
</zip>
</target>
<target name="package.pom" depends="prepare.version" if="package.revision">
<ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${tmp.out.bin.dir}/pom.xml" conf="default,compile">
<mapping conf="default" scope="default" />
<mapping conf="test" scope="test" />
<mapping conf="compile" scope="compile" />
</ivy:makepom>
</target>
<!-- build -->
<target name="build" depends="prepare.log,compile,test,analyze" description="Builds the project." />
<!-- rebuild -->
<target name="rebuild" depends="prepare.log,clean,build" description="Rebuilds the project." />
<!-- release -->
<target name="release" depends="prepare.log,prepare.version,rebuild,package" description="Creates a release for the project." />
</project>