-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
316 lines (270 loc) · 10.8 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
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<project name="springapp" basedir="." default="usage">
<property file="build.properties" />
<property name="src.dir" value="src" />
<property name="web.dir" value="war" />
<property name="build.dir" value="${web.dir}/WEB-INF/classes" />
<property name="name" value="springapp" />
<property name="appserver" value="${appserver.home}" />
<property name="appserver.lib" value="${appserver}/lib" />
<property name="test.dir" value="test" />
<property name="report.dir" value="test-report" />
<path id="master-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<!-- We need the servlet API classes: -->
<!-- * for Tomcat 5/6 use servlet-api.jar -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="servlet*.jar" />
</fileset>
<pathelement path="${build.dir}" />
</path>
<path id="test-classpath">
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
<pathelement path="${test.dir}"/>
<pathelement path="${web.dir}/WEB-INF/classes"/>
</path>
<target name="usage">
<echo message="" />
<echo message="${name} build file" />
<echo message="-----------------------------------" />
<echo message="" />
<echo message="Available targets are:" />
<echo message="" />
<echo message="clean --> Clean application" />
<echo message="clean-report --> Clean test reports" />
<echo message="build --> Build the application" />
<echo message="deploy --> Deploy application as directory" />
<echo message="deploywar --> Deploy application as a WAR file" />
<echo message="install --> Install application in Tomcat" />
<echo message="reload --> Reload application in Tomcat" />
<echo message="start --> Start Tomcat application" />
<echo message="stop --> Stop Tomcat application" />
<echo message="list --> List Tomcat applications" />
<echo message="" />
</target>
<target name="clean" description="Clean output directories">
<delete>
<fileset dir="${build.dir}">
<include name="**/*.class" />
</fileset>
</delete>
</target>
<target name="undeploy" description="Un-Deploy application">
<delete>
<fileset dir="${deploy.path}/${name}">
<include name="**/*.*" />
</fileset>
</delete>
</target>
<target name="clean-report">
<delete dir="${report.dir}" />
<mkdir dir="${report.dir}" />
</target>
<target name="build" description="Compile main source tree java files" depends="clean">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.8" target="1.8" debug="true" deprecation="false" optimize="false" failonerror="true" includeantruntime="false">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
<target name="buildtests" description="Compile test tree java files" depends="build">
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.8" target="1.8" debug="true" deprecation="false" optimize="false" failonerror="true" includeantruntime="false">
<src path="${test.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
<target name="tests" depends="clean-report, buildtests" description="Run tests">
<junit printsummary="true" fork="false" haltonfailure="false" failureproperty="tests.failed" showoutput="true">
<classpath refid="master-classpath" />
<!--formatter type="brief" usefile="false"/-->
<formatter type="plain" />
<formatter type="xml" />
<classpath refid="test-classpath"/>
<classpath location="${build.dir}" />
<!--test name="springapp.web.HelloControllerTest"
haltonfailure="no" todir="${report.dir}">
<formatter type="plain" />
<formatter type="xml" />
</test-->
<batchtest todir="${report.dir}" fork="false">
<fileset dir="${build.dir}">
<include name="**/*Tests.*" />
<exclude name="**/Jdbc*Tests.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
***********************************************************
</fail>
</target>
<target name="dbTests" depends="buildtests,dropTables,createTables,loadData"
description="Run db tests">
<junit printsummary="on"
fork="false"
haltonfailure="false"
failureproperty="tests.failed"
showoutput="true">
<classpath refid="test-classpath"/>
<formatter type="brief" usefile="false"/>
<batchtest>
<fileset dir="${build.dir}">
<include name="**/Jdbc*Tests.*"/>
</fileset>
</batchtest>
</junit>
<fail if="tests.failed">
tests.failed=${tests.failed}
***********************************************************
***********************************************************
**** One or more tests failed! Check the output ... ****
***********************************************************
***********************************************************
</fail>
</target>
<target name="deploy" depends="build" description="Deploy application">
<copy todir="${deploy.path}/${name}" preservelastmodified="true">
<fileset dir="${web.dir}">
<include name="**/*.*" />
</fileset>
</copy>
</target>
<target name="deploywar" depends="build" description="Deploy application as a WAR file">
<war destfile="${name}.war" webxml="${web.dir}/WEB-INF/web.xml">
<fileset dir="${web.dir}">
<include name="**/*.*" />
</fileset>
</war>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.war" />
</fileset>
</copy>
</target>
<!-- ============================================================== -->
<!-- Tomcat tasks - remove these if you don't have Tomcat installed -->
<!-- ============================================================== -->
<path id="catalina-ant-classpath">
<!-- We need the Catalina jars for Tomcat -->
<!-- * for other app servers - check the docs -->
<fileset dir="${appserver.lib}">
<include name="catalina-ant.jar" />
<include name="tomcat-coyote.jar" />
<include name="tomcat-util.jar" />
</fileset>
<fileset dir="${appserver.home}/bin">
<include name="tomcat-juli.jar" />
<include name="bootstrap.jar" />
</fileset>
</path>
<taskdef name="install" classname="org.apache.catalina.ant.DeployTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<taskdef name="list" classname="org.apache.catalina.ant.ListTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<taskdef name="start" classname="org.apache.catalina.ant.StartTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<taskdef name="stop" classname="org.apache.catalina.ant.StopTask">
<classpath refid="catalina-ant-classpath" />
</taskdef>
<target name="install" description="Install application in Tomcat">
<install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}.war" />
</target>
<target name="reload" description="Reload application in Tomcat">
<reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" />
</target>
<target name="start" description="Start Tomcat application">
<start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" />
</target>
<target name="stop" description="Stop Tomcat application">
<stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" />
</target>
<target name="list" description="List Tomcat applications">
<list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" />
</target>
<target name="createTables">
<echo message="CREATE TABLES USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
src="db/create_products.sql">
<classpath refid="master-classpath"/>
</sql>
</target>
<target name="dropTables">
<echo message="DROP TABLES USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue">
<classpath refid="master-classpath"/>
DROP TABLE products;
</sql>
</target>
<target name="loadData">
<echo message="LOAD DATA USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
src="db/load_data.sql">
<classpath refid="master-classpath"/>
</sql>
</target>
<target name="printData">
<echo message="PRINT DATA USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue"
print="true">
<classpath refid="master-classpath"/>
SELECT * FROM products;
</sql>
</target>
<target name="clearData">
<echo message="CLEAR DATA USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue">
<classpath refid="master-classpath"/>
DELETE FROM products;
</sql>
</target>
<target name="shutdownDb">
<echo message="SHUT DOWN DATABASE USING: ${db.driver} ${db.url}"/>
<sql driver="${db.driver}"
url="${db.url}"
userid="${db.user}"
password="${db.pw}"
onerror="continue">
<classpath refid="master-classpath"/>
SHUTDOWN;
</sql>
</target>
<!-- End Tomcat tasks -->
</project>