-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuild.xml
More file actions
330 lines (310 loc) · 16.1 KB
/
build.xml
File metadata and controls
330 lines (310 loc) · 16.1 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
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- Ant build file (http://ant.apache.org/) for Ant 1.7.2 or above. -->
<!-- ====================================================================== -->
<project name="utilities" default="zip" basedir="." xmlns:artifact="antlib:org.apache.maven.artifact.ant" xmlns:ac="antlib:net.sf.antcontrib" xmlns:sonar="antlib:org.sonar.ant">
<tstamp><format property="MYTIME" pattern="yyyyMMddHHmmss" /></tstamp>
<!-- ====================================================================== -->
<!-- Defining classpaths & Task Defs -->
<!-- ====================================================================== -->
<property environment="env"/>
<path id="maven-ant-tasks.classpath" path="${ant.home}/lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
<path id="ant.contrib.classpath" path="${ant.home}/lib/ant-contrib.jar"/>
<typedef resource="net/sf/antcontrib/antlib.xml" classpathref="ant.contrib.classpath"/>
<!-- ====================================================================== -->
<!-- Build environment properties -->
<!-- ====================================================================== -->
<property name="environment.type.default" value="dev"/>
<if>
<equals arg1="${basesrcdir}" arg2="$${basesrcdir}"/>
<then>
<property name="build.basesrcdir" value="."/>
</then>
<else>
<property name="build.basesrcdir" value="${basesrcdir}"/>
</else>
</if>
<if>
<equals arg1="${buildtype}" arg2="$${buildtype}"/>
<then>
<property name="maven.build.resourceDir" value="${build.basesrcdir}/src/main/resources/${environment.type.default}"/>
<property name="actualbuildtype" value="${environment.type.default}"/>
</then>
<else>
<property name="maven.build.resourceDir" value="${build.basesrcdir}/src/main/resources/${buildtype}"/>
<property name="actualbuildtype" value="${buildtype}"/>
</else>
</if>
<echo message="resource dir: ${maven.build.resourceDir}, Source Dir: ${build.basesrcdir}/src/main/java"/>
<property file="${build.basesrcdir}/build.properties"/>
<artifact:pom id="pom" file="pom.xml" />
<property name="actualbuildname" value="${pom.artifactId}"/>
<property name="actualversion" value="${pom.version}"/>
<echo message="Artifact ID/Version: ${actualbuildname}/${actualversion}"/>
<property name="build.version" value="${version}"/>
<property name="maven.build.finalName" value="${actualbuildname}-${actualversion}"/>
<property name="maven.build.dir" value="${build.basesrcdir}/target"/>
<property name="maven.build.outputDir" value="${maven.build.dir}/classes"/>
<property name="maven.build.srcDir" value="${build.basesrcdir}/src/main/java"/>
<property name="maven.build.testDir" value="${build.basesrcdir}/src/test/java"/>
<property name="maven.build.testResourceDir" value="${build.basesrcdir}/src/test/resources"/>
<property name="maven.build.testOutputDir" value="${maven.build.dir}/test-classes"/>
<property name="maven.test.reports" value="${maven.build.dir}/test-reports"/>
<property name="maven.reporting.outputDirectory" value="reports"/>
<property name="project.3rdpartylibdir" value="${build.basesrcdir}/lib"/>
<property name="maven.build.pmddir" value="${build.basesrcdir}/src/main/pmd"/>
<property name="sonar.host.url" value="${env.SONAR_URL}" />
<property name="sonar.jdbc.url" value="jdbc:mysql://${env.SONAR_DBSERVER}:${env.SONAR_DBPORT}/${env.SONAR_DBNAME}?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" />
<property name="sonar.jdbc.username" value="${env.SONAR_DBUSER}"/>
<property name="sonar.jdbc.password" value="${env.SONAR_DBPASSWORD}"/>
<property name="sonar.projectKey" value="${ant.project.name}"/>
<property name="sonar.projectName" value="${ant.project.name}"/>
<property name="sonar.projectVersion" value="${actualversion}"/>
<property name="sonar.sources" value="${build.basesrcdir}/src/main/java"/>
<path id="libpath">
<fileset dir="${project.3rdpartylibdir}"/>
</path>
<path id="build.test.classpath">
<pathelement location="${project.3rdpartylibdir}/junit-4.11.jar"/>
</path>
<echo message="***************************************************************************"/>
<echo message="Start the build for: ${ant.project.name} "/>
<echo message="Base Dir: ${build.basesrcdir} ${actualbuildtype}"/>
<mkdir dir="${project.3rdpartylibdir}"/>
<echo message="***************************************************************************"/>
<echo message="Skip Test? ${maven.test.skip}"/>
<!-- ====================================================================== -->
<!-- Cleaning up target -->
<!-- ====================================================================== -->
<target name="clean" description="Clean the output directory">
<delete dir="${maven.build.dir}"/>
<delete dir="${project.3rdpartylibdir}"/>
<delete dir="${maven.reporting.outputDirectory}"/>
<delete dir="./.sonar"/>
<delete dir="reports"/>
</target>
<!-- ====================================================================== -->
<!-- Copy Maven dependencies -->
<!-- ====================================================================== -->
<target name="maven_dep_copy" depends="clean" description="Copies Maven Dependencies into local Lib folder">
<artifact:dependencies filesetId="deps.fileset" scopes="provided, test, runtime, compile">
<pom file="pom.xml"/>
</artifact:dependencies>
<mkdir dir="${project.3rdpartylibdir}"/>
<copy todir="${project.3rdpartylibdir}">
<fileset refid="deps.fileset" />
<mapper type="flatten" />
</copy>
</target>
<!-- ====================================================================== -->
<!-- Compilation target -->
<!-- ====================================================================== -->
<target name="compile" depends="maven_dep_copy" description="Compiles the code.">
<mkdir dir="${maven.build.outputDir}"/>
<javac includeantruntime="false" destdir="${maven.build.outputDir}"
nowarn="false" debug="true"
optimize="false" deprecation="true"
target="1.6" verbose="false"
fork="false" source="1.6">
<src>
<pathelement location="${maven.build.srcDir}"/>
</src>
<classpath>
<fileset dir="${project.3rdpartylibdir}"/>
</classpath>
</javac>
<copy todir="${maven.build.outputDir}">
<fileset dir="${maven.build.resourceDir}"/>
</copy>
</target>
<!-- ====================================================================== -->
<!-- Test-compilation target -->
<!-- ====================================================================== -->
<target name="compile-tests"
depends="compile"
description="Compiles the test code, unless maven's skip test property is unset">
<mkdir dir="${maven.build.testOutputDir}"/>
<javac includeantruntime="false" destdir="${maven.build.testOutputDir}"
nowarn="false" debug="true"
optimize="false" deprecation="true"
target="1.6" verbose="false"
fork="false" source="1.6">
<src>
<pathelement location="${maven.build.testDir}"/>
</src>
<classpath>
<fileset dir="${project.3rdpartylibdir}"/>
<pathelement location="${maven.build.outputDir}"/>
</classpath>
</javac>
<copy todir="${maven.build.testOutputDir}">
<fileset dir="${maven.build.testResourceDir}"/>
</copy>
</target>
<!-- ====================================================================== -->
<!-- Run all tests -->
<!-- ====================================================================== -->
<target name="test"
depends="compile-tests"
description="Runs the test cases">
<mkdir dir="${maven.test.reports}"/>
<junit printSummary="yes" haltonerror="false" haltonfailure="false" fork="true" dir=".">
<sysproperty key="basedir" value="."/>
<formatter type="xml"/>
<formatter type="plain" usefile="false"/>
<classpath>
<fileset dir="${project.3rdpartylibdir}"/>
<pathelement location="${maven.build.outputDir}"/>
<pathelement location="${maven.build.testOutputDir}"/>
</classpath>
<batchtest skipNonTests="false" todir="${maven.test.reports}">
<fileset dir="${maven.build.testDir}">
<include name="**/Test*.java"/>
<include name="**/*Test.java"/>
<include name="**/*TestCase.java"/>
<exclude name="**/*Abstract*Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="test-junit-present" description="Checks if JUNIT is present">
<available classname="junit.framework.Test" property="junit.present" classpathref="build.test.classpath"/>
<echo message="${junit.present}"/>
</target>
<target name="test-junit-status"
depends="test-junit-present" description="Set condition if JUNIT tests are to be run.">
<condition property="junit.missing">
<and>
<isfalse value="${junit.present}"/>
<isfalse value="${maven.test.skip}"/>
</and>
</condition>
<condition property="junit.skipped">
<or>
<isfalse value="${junit.present}"/>
<istrue value="${maven.test.skip}"/>
</or>
</condition>
</target>
<target name="junit-missing"
depends="test-junit-status"
if="junit.missing" description="Reports if JUNIT library is missing so to avoid running JUNIT Tests">
<echo>=================================== WARNING ==========================================</echo>
<echo> JUnit is not present in the test classpath or your $ANT_HOME/lib directory. Tests not executed. </echo>
<echo>=======================================================================================</echo>
</target>
<!-- ====================================================================== -->
<!-- Javadoc target -->
<!-- ====================================================================== -->
<target name="javadoc" description="Generates the Javadoc of the application">
<javadoc sourcepath="${maven.build.srcDir}"
packagenames="*"
destdir="${maven.reporting.outputDirectory}/apidocs"
access="protected"
old="false"
verbose="false"
version="true"
use="true"
author="true"
splitindex="false"
nodeprecated="false"
nodeprecatedlist="false"
notree="false"
noindex="false"
nohelp="false"
nonavbar="false"
serialwarn="false"
charset="ISO-8859-1"
linksource="false"
breakiterator="false"/>
</target>
<!-- ====================================================================== -->
<!-- Package target -->
<!-- ====================================================================== -->
<target name="package" depends="compile,test" description="Package the application as a JAR/WAR whatever">
<pathconvert property="manifest.classpath" pathsep=" ">
<path refid="libpath"/>
<mapper>
<chainedmapper>
<flattenmapper/>
<globmapper from="*.jar" to="${project.3rdpartylibdir}/*.jar"/>
</chainedmapper>
</mapper>
</pathconvert>
<jar jarfile="${maven.build.dir}/${maven.build.finalName}.jar"
compress="true" index="false"
basedir="${maven.build.outputDir}" excludes="**/package.html">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Created-By" value="Build Tool V1"/>
<attribute name="Implementation-Title" value="${actualbuildname}.jar"/>
<attribute name="Implementation-Version" value="${maven.build.version}-${MYTIME}"/>
<attribute name="Implementation-Vendor" value="SeshagiriSriram"/>
<attribute name="Class-Path" value="${manifest.classpath}"/>
</manifest>
</jar>
</target>
<!-- ====================================================================== -->
<!-- A dummy target for the package named after the type it creates -->
<!-- ====================================================================== -->
<target name="jar" depends="package" description="Builds the jar for the application"/>
<!-- ====================================================================== -->
<!-- Zips files into a zip for deployment -->
<!-- ====================================================================== -->
<target name="zip" depends="package" description="Zips all Resources">
<if>
<equals arg1="${zipoutput}" arg2="$${zipoutput}"/>
<then>
<property name="zipoutputdir" value="${maven.build.dir}"/>
</then>
<else>
<property name="zipoutputdir" value="${zipoutput}"/>
</else>
</if>
<echo message="Copying files from ${maven.build.resourceDir} to ${maven.build.dir}/tmp"/>
<mkdir dir="${maven.build.dir}/tmp"/>
<mkdir dir="${zipoutputdir}"/>
<echo message="Resource Directory: ${maven.build.resourceDir}" />
<copy todir="${maven.build.dir}/tmp" overwrite="true">
<fileset dir="${maven.build.resourceDir}"/>
<file name="${maven.build.dir}/${maven.build.finalName}.jar"/>
</copy>
<zip destfile="${zipoutputdir}/${maven.build.finalName}.zip">
<zipfileset dir="${maven.build.dir}/tmp" includes="*.properties,*.xml,*.txt, ${maven.build.finalName}.jar"/>
<zipfileset dir="./lib" prefix="lib"/>
</zip>
<delete dir="${maven.build.dir}/tmp"/>
<delete dir="${project.3rdpartylibdir}"/>
<mkdir dir="${project.3rdpartylibdir}"/>
<delete file="${maven.build.dir}/../${maven.build.finalName}.zip"/>
</target>
<!-- ====================================================================== -->
<!-- Download dependencies target -->
<!-- ====================================================================== -->
<target name="test-offline" description="Checks if Maven has been configured to run in offline mode">
<condition property="maven.mode.offline">
<equals arg1="${maven.settings.offline}" arg2="true"/>
</condition>
</target>
<!-- ====================================================================== -->
<!-- Installs components to Artifactory -->
<!-- ====================================================================== -->
<target name="install" depends="zip" description="Installs the JAR to artifactory">
<echo message="Maven is found in: ${env.MAVEN_HOME}"/>
<artifact:deploy file="${maven.build.dir}/${maven.build.finalName}.jar">
<pom file="pom.xml"/>
<remoteRepository url="${env.BUILD_URL}"/>
</artifact:deploy>
</target>
<!-- ====================================================================== -->
<!-- Performs SonarQube Analysis on code -->
<!-- ====================================================================== -->
<target name="sonar" description="Performs SonarQube Analysis on code">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml" classpathref="maven-ant-tasks.classpath" />
<!-- Execute the SonarQube analysis -->
<sonar:sonar />
</target>
</project>