-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
executable file
·250 lines (215 loc) · 9.05 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
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="protrade-data">
<property name="build.dir" value="build" />
<property name="build.prod.dir" value="${build.dir}/prod" />
<property name="build.test.dir" value="${build.dir}/test" />
<property name="build.jar.dir" value="${build.dir}/jar" />
<property name="src.dir" value="src" />
<property name="unit.test.dir" value="tests-unit" />
<property name="system.test.dir" value="tests-system" />
<property name="lib.dir" value="lib"/>
<property file="build.properties" />
<property name="instrumented.dir" value="build/instrumented-classes" />
<!-- IVY properties -->
<property name="ivy.install.version" value="2.1.0" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ant" />
<property name="ivy.jar.dir" value="${ivy.home}/lib" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<property name="reports.dir" value="${build.dir}/reports" />
<property name="unit.test.report.dir" value="${reports.dir}/unit-tests" />
<property name="system.test.report.dir" value="${reports.dir}/system-tests" />
<property name="pmd.report.dir" value="${reports.dir}/pmd" />
<property name="coverage.report.dir" value="${reports.dir}/test-coverage" />
<property name="config.dir" value="config" />
<property name="config.pmd.dir" value="${config.dir}/pmd" />
<property name="config.log4j.dir" value="${config.dir}/log4j" />
<property name="build.agent" value="git" />
<!-- Set the CLASSPATH -->
<path id="classpath">
<pathelement location="${build.prod.dir}" />
<pathelement location="${build.test.dir}" />
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<!-- IVY targets -->
<target name="download-ivy" unless="offline">
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="init-ivy" depends="download-ivy">
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
</target>
<target name="resolve" description="--> retrieve dependencies with ivy">
<ivy:retrieve pattern="lib/[artifact].[ext]" type="jar,bundle"/>
</target>
<!-- Create the folders for required for build -->
<target name="prepare">
<mkdir dir="${build.dir}" />
<mkdir dir="${build.prod.dir}" />
<mkdir dir="${build.test.dir}" />
</target>
<!-- COMPILE task -->
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}" includeantruntime="false" destdir="${build.prod.dir}" classpathref="classpath" debug="true" debuglevel="vars,lines,source" />
<copy todir="${build.prod.dir}" file="${config.log4j.dir}/log4j.properties" />
</target>
<!-- RUN task - runs the main class -->
<target name="run" depends="compile">
<java classname="org.ic.protrade.data.demo.ScoreDemo" fork="true" classpathref="classpath"/>
</target>
<!-- JAR and RUN tasks to create & run a jar, running the tests first -->
<target name="jar" depends="compile,unit-tests,system-tests">
<mkdir dir="${build.jar.dir}" />
<jar destfile="${build.jar.dir}/protrade-data.jar" basedir="${build.prod.dir}" excludes="log4j.properties"/>
</target>
<!-- CLEAN task -->
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${build.prod.dir}" />
<delete dir="${build.test.dir}" />
<delete dir="${coverage.report.dir}" />
<delete file="cobertura.ser" />
</target>
<target name="clean-lib">
<delete>
<fileset dir="lib" includes="*.jar" excludes="generated.jar"/>
</delete>
</target>
<!-- COMPILE all tests -->
<target name="compile-tests" depends="compile">
<javac srcdir="${unit.test.dir}" destdir="${build.test.dir}" classpathref="classpath" />
<javac srcdir="${system.test.dir}" destdir="${build.test.dir}" classpathref="classpath" />
</target>
<!-- Coverage tasks -->
<taskdef classpathref="classpath" resource="tasks.properties" />
<target name="instrument" depends="compile">
<cobertura-instrument todir="${instrumented.dir}">
<fileset dir="build/prod">
<include name="**/*.class" />
</fileset>
</cobertura-instrument>
</target>
<target name="coverage" depends="clean, instrument, unit-tests, system-tests">
<cobertura-report destdir="${coverage.report.dir}">
<fileset dir="${src.dir}">
</fileset>
<include name="**/*.java" />
</cobertura-report>
</target>
<target name="coverage-unit-tests" depends="clean, instrument, unit-tests">
<cobertura-report destdir="${coverage.report.dir}">
<fileset dir="${src.dir}">
</fileset>
<include name="**/*.java" />
</cobertura-report>
</target>
<target name="coverage-system-tests" depends="clean, instrument, unit-tests">
<cobertura-report destdir="${coverage.report.dir}">
<fileset dir="${src.dir}">
</fileset>
<include name="**/*.java" />
</cobertura-report>
</target>
<!-- RUN unit tests -->
<target name="unit-tests" depends="compile,compile-tests">
<mkdir dir="${unit.test.report.dir}" />
<junit printsummary="yes" errorProperty="test.failed" failureProperty="test.failed">
<classpath location="${instrumented.dir}" />
<classpath refid="classpath" />
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${unit.test.report.dir}">
<fileset dir="${unit.test.dir}" includes="**/*Test.java" />
</batchtest>
</junit>
<junitreport todir="${unit.test.report.dir}">
<fileset dir="${unit.test.report.dir}" includes="TEST-*.xml" />
<report todir="${unit.test.report.dir}" />
</junitreport>
</target>
<!-- Run system tests -->
<target name="system-tests" depends="compile,compile-tests">
<mkdir dir="${system.test.report.dir}" />
<junit printsummary="yes" errorProperty="test.failed" failureProperty="test.failed">
<classpath location="${instrumented.dir}" />
<classpath refid="classpath" />
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${system.test.report.dir}">
<fileset dir="${system.test.dir}" includes="**/*Test.java" />
</batchtest>
</junit>
<junitreport todir="${system.test.report.dir}">
<fileset dir="${system.test.report.dir}" includes="TEST-*.xml" />
<report todir="${system.test.report.dir}" />
</junitreport>
</target>
<!-- PMD task -->
<target name="pmd">
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="classpath" />
<mkdir dir="${pmd.report.dir}" />
<pmd shortFilenames="true">
<!-- <ruleset>rulesets/favorites.xml</ruleset> -->
<ruleset>basic,design,braces,junit</ruleset>
<!-- <formatter type="html" toFile="pmd_report.html" linkPrefix="http://pmd.sourceforge.net/xref/"/>-->
<formatter type="xml" toFile="${pmd.report.dir}/pmd.xml" />
<fileset dir="${src.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${unit.test.dir}">
<include name="**/*.java" />
</fileset>
<fileset dir="${system.test.dir}">
<include name="**/*.java" />
</fileset>
</pmd>
<xslt in="${pmd.report.dir}/pmd.xml" style="${config.pmd.dir}/format.xslt" out="${pmd.report.dir}/pmd.html" />
</target>
<!-- ALL task -->
<target name="all" depends="coverage, pmd" />
<!-- Git tasks -->
<target name="git-all" depends="clean, git-unit-tests, git-system-tests" />
<!-- Run system tests from git -->
<target name="git-system-tests" depends="compile,compile-tests">
<mkdir dir="${system.test.report.dir}" />
<junit printsummary="yes" errorProperty="test.failed" failureProperty="test.failed" haltonfailure="true">
<classpath location="${instrumented.dir}" />
<classpath refid="classpath" />
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${system.test.report.dir}">
<fileset dir="${system.test.dir}" includes="**/*Test.java" />
</batchtest>
</junit>
<junitreport todir="${system.test.report.dir}">
<fileset dir="${system.test.report.dir}" includes="TEST-*.xml" />
<report todir="${system.test.report.dir}" />
</junitreport>
<fail if="test.failed" />
</target>
<!-- Run unit tests from git -->
<target name="git-unit-tests" depends="compile,compile-tests">
<mkdir dir="${unit.test.report.dir}" />
<junit printsummary="yes" errorProperty="test.failed" failureProperty="test.failed" haltonfailure="true">
<classpath location="${instrumented.dir}" />
<classpath refid="classpath" />
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest fork="yes" todir="${unit.test.report.dir}">
<fileset dir="${unit.test.dir}" includes="**/*Test.java" />
</batchtest>
</junit>
<junitreport todir="${unit.test.report.dir}">
<fileset dir="${unit.test.report.dir}" includes="TEST-*.xml" />
<report todir="${unit.test.report.dir}" />
</junitreport>
<fail if="test.failed" />
</target>
</project>