forked from Wikicrimes/Wikicrimes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
executable file
·475 lines (426 loc) · 20.2 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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
<?xml version="1.0"?>
<project name="wikicrimes" basedir="." default="help" xmlns:artifact="urn:maven-artifact-ant">
<property name="src.dir" value="src/main/java"/>
<property name="resources.dir" value="src/main/resources"/>
<property name="web.dir" value="src/main/webapp"/>
<property name="test.src" value="src/test/java"/>
<property name="test.resources.dir" value="src/test/resources"/>
<property name="build.dir" value="target"/>
<property name="test.dir" value="${build.dir}/test"/>
<property name="admin.dir" value="wikicrimesadmin"/>
<property file="build.properties"/>
<property file="${resources.dir}/jdbc.properties"/>
<property name="webapp.name" value="wikicrimes"/>
<property name="webapp.version" value="1.0"/>
<property environment="env"/>
<property name="cargo.server" value="tomcat6x"/>
<property name="server.home" value="/home/carlos/Programas/tomcat/apache-tomcat-6.0.20/"/>
<property name="deploy.dir" value="${server.home}/webapps"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">
<classpath>
<pathelement location="${basedir}/lib/maven-ant-tasks-2.0.7.jar" />
</classpath>
</typedef>
<artifact:pom file="pom.xml" id="maven.project"/>
<artifact:dependencies pathId="compile.classpath" filesetId="compile.fileset" useScope="compile">
<pom refid="maven.project"/>
</artifact:dependencies>
<artifact:dependencies pathId="test.classpath" filesetId="test.fileset" useScope="test">
<pom refid="maven.project"/>
</artifact:dependencies>
<artifact:dependencies pathId="runtime.classpath" filesetId="runtime.fileset" useScope="runtime">
<pom refid="maven.project"/>
</artifact:dependencies>
<target name="help">
<echo message=""/>
<echo message="${webapp.name} build file"/>
<echo message="-----------------------------------"/>
<echo message=""/>
<echo message="Available targets are:"/>
<echo message=""/>
<echo message="compile --> Compile all Java files"/>
<echo message="test --> Runs JUnit tests"/>
<echo message="test-web --> Runs jWebUnit tests in a running container"/>
<echo message="test-tomcat --> Starts Tomcat to run jWebUnit tests"/>
<echo message="test-all --> Runs all JUnit and jWebUnit tests"/>
<echo message=""/>
<echo message="war --> Package as WAR file"/>
<echo message="deploy --> Deploy application as directory"/>
<echo message="undeploy --> Deletes application from server"/>
<echo message="deploywar --> Deploy application as a WAR file"/>
<echo message=""/>
<echo message="clean --> Deletes compiled classes and WAR"/>
<echo message="new --> Creates a new project"/>
</target>
<target name="compile" description="Compile main source tree java files">
<mkdir dir="${build.dir}/classes"/>
<javac destdir="${build.dir}/classes" debug="true" optimize="false"
deprecation="false" failonerror="true" source="1.5" target="1.5">
<src path="${src.dir}"/>
<classpath>
<path refid="compile.classpath"/>
<fileset dir="${web.dir}/WEB-INF/lib" includes="*.jar"/>
</classpath>
</javac>
<!-- compile tests -->
<mkdir dir="${test.src}/java"/>
<mkdir dir="${test.dir}/classes"/>
<javac destdir="${test.dir}/classes" debug="true" optimize="false"
deprecation="false" failonerror="true" source="1.5" target="1.5">
<src path="${test.src}"/>
<classpath>
<path refid="test.classpath"/>
<path location="${build.dir}/classes"/>
<fileset dir="${web.dir}/WEB-INF/lib" includes="*.jar"/>
</classpath>
</javac>
<!-- Copy XML files to ${build.dir}/classes -->
<copy todir="${build.dir}/classes">
<fileset dir="${src.dir}" includes="**/*.vm"/>
<fileset dir="${src.dir}" includes="**/*.xml"/>
</copy>
</target>
<target name="compileIvia" description="Compile main source tree java files">
<mkdir dir="${build.dir}/classes"/>
<javac destdir="${build.dir}/classes" debug="true" optimize="false"
deprecation="false" failonerror="true" source="1.5" target="1.5">
<src path="${src.dir}"/>
<classpath>
<path refid="compile.classpath"/>
<fileset dir="${web.dir}/WEB-INF/lib" includes="*.jar"/>
</classpath>
</javac>
<!-- compile tests -->
<mkdir dir="${test.src}/java"/>
<mkdir dir="${test.dir}/classes"/>
<javac destdir="${test.dir}/classes" debug="true" optimize="false"
deprecation="false" failonerror="true" source="1.5" target="1.5">
<src path="${test.src}"/>
<classpath>
<path refid="test.classpath"/>
<path location="${build.dir}/classes"/>
<fileset dir="${web.dir}/WEB-INF/lib" includes="*.jar"/>
</classpath>
</javac>
<!-- Copy XML files to ${build.dir}/classes -->
<copy todir="${build.dir}/classes">
<fileset dir="${src.dir}" includes="**/*.xml"/>
</copy>
</target>
<target name="test" depends="compile" description="Runs JUnit tests">
<!-- Check that junit.jar is in $ANT_HOME/lib -->
<available classname="junit.framework.TestCase" property="junit.present"/>
<fail unless="junit.present"
message="Please copy ~/.m2/repository/junit/junit/4.4/junit-4.4.jar into ${env.ANT_HOME}/lib"/>
<mkdir dir="${test.dir}/data"/>
<junit printsummary="no" fork="true" forkmode="once"
errorProperty="test.failed" failureProperty="test.failed">
<classpath>
<path refid="compile.classpath"/>
<path refid="test.classpath"/>
<path location="${build.dir}/classes"/>
<path location="${resources.dir}"/>
<path location="${test.dir}/classes"/>
<path location="${test.resources.dir}"/>
<path location="${web.dir}"/>
<fileset dir="${web.dir}/WEB-INF/lib" includes="*.jar"/>
</classpath>
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
<batchtest todir="${test.dir}/data" if="test">
<fileset dir="${test.dir}/classes">
<include name="**/*${test}*"/>
<exclude name="**/*TestCase.class"/>
<exclude name="**/*$*.class"/>
</fileset>
</batchtest>
<batchtest todir="${test.dir}/data" unless="test">
<fileset dir="${test.dir}/classes">
<include name="**/*Test.class*"/>
<exclude name="**/*WebTest.class"/>
</fileset>
</batchtest>
</junit>
<fail if="test.failed">
Unit tests failed. For error messages, check the log files in
${test.dir}/data or run "ant test-reports"
to generate reports at ${test.dir}/reports.</fail>
</target>
<target name="test-web" depends="compile" description="Runs Canoo WebTests in Tomcat to test JSPs">
<taskdef resource="webtest_base_relaxed.taskdef">
<classpath>
<path refid="test.classpath"/>
<!-- for log4j.xml -->
<path location="${resources.dir}"/>
</classpath>
</taskdef>
<mkdir dir="${test.dir}/data"/>
<!-- Delete old results file if it exists -->
<delete file="${test.dir}/data/web-tests-result.xml"/>
<!-- This is so the default will be used if no test case is specified -->
<property name="testcase" value="run-all-tests"/>
<ant antfile="${test.resources.dir}/web-tests.xml" target="${testcase}"/>
</target>
<target name="test-tomcat" depends="war"
description="Starts Tomcat, runs jWebUnit tests, stops Tomcat">
<property name="cargo.wait" value="false"/>
<taskdef resource="cargo.tasks" classpathref="test.classpath"/>
<cargo containerId="${cargo.server}" id="cargo.server" home="${server.home}"
action="start" wait="${cargo.wait}">
<configuration>
<deployable type="war" file="${basedir}/${build.dir}/${webapp.name}.war">
<property name="context" value="ROOT"/>
</deployable>
</configuration>
</cargo>
<antcall target="test-web"/>
<cargo refid="cargo.server" action="stop"/>
</target>
<!-- <target name="test-all" depends="clear,test,test-tomcat", clear not needed with H2 -->
<target name="test-all" depends="test,test-tomcat"
description="Runs JUnit tests and starts Tomcat to run jWebUnit tests"/>
<target name="test-reports" description="Generate test reports">
<mkdir dir="${test.dir}/reports"/>
<junitreport todir="${test.dir}">
<fileset dir="${test.dir}/data">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${test.dir}/reports"/>
</junitreport>
</target>
<target name="copy-jars" description="Copies JARs from local repository">
<mkdir dir="${build.dir}/jars"/>
<copy todir="${build.dir}/jars">
<fileset refid="compile.fileset"/>
<fileset refid="runtime.fileset"/>
<mapper type="flatten"/>
</copy>
<delete>
<fileset dir="${build.dir}/jars" includes="servlet-api*"/>
</delete>
</target>
<target name="war" depends="compile,copy-jars" description="Packages app as WAR">
<mkdir dir="${build.dir}"/>
<war destfile="${build.dir}/${webapp.name}.war"
webxml="${web.dir}/WEB-INF/web.xml" compress="true">
<classes dir="${build.dir}/classes"/>
<classes dir="${resources.dir}"/>
<fileset dir="${web.dir}" excludes="**/web.xml"/>
<zipfileset prefix="WEB-INF/lib" dir="${build.dir}/jars"/>
</war>
</target>
<target name="warIvia" depends="compile,copy-jars" description="Packages app as WAR">
<mkdir dir="${build.dir}"/>
<copy todir="${build.dir}/WEB-INF">
<fileset dir="${src.dir}/main/resources/ivia" includes="*.xml"/>
</copy>
<war destfile="${build.dir}/${webapp.name}.war"
webxml="${web.dir}/WEB-INF/web.xml" compress="true">
<classes dir="${build.dir}/classes"/>
<classes dir="${resources.dir}"/>
<fileset dir="${web.dir}" excludes="**/web.xml"/>
<zipfileset prefix="WEB-INF/lib" dir="${build.dir}/jars"/>
</war>
</target>
<target name="deploy" depends="compile,copy-jars" description="Deploy application">
<copy todir="${deploy.dir}/${webapp.name}" preservelastmodified="true">
<fileset dir="${web.dir}"/>
</copy>
<copy todir="${deploy.dir}/${webapp.name}/WEB-INF/classes" preservelastmodified="true">
<fileset dir="${build.dir}/classes"/>
<fileset dir="${resources.dir}"/>
</copy>
<copy todir="${deploy.dir}/${webapp.name}/WEB-INF/lib">
<fileset dir="${build.dir}/jars"/>
</copy>
</target>
<target name="compileAdmin" description="Compile projeto de Administracao do Wikicrimes">
<javac destdir="${admin.dir}/web/WEB-INF/classes" debug="true" optimize="false"
deprecation="false" failonerror="true" source="1.5" target="1.5">
<src path="${admin.dir}/src"/>
<classpath>
<path refid="compile.classpath"/>
<fileset dir="${admin.dir}/web/WEB-INF/lib" includes="*.jar"/>
</classpath>
</javac>
<!-- Copy XML files to ${admin.dir}/classes -->
<copy todir="${admin.dir}/web/WEB-INF/classes">
<fileset dir="${admin.dir}/src" includes="**/*.xml"/>
</copy>
<!-- Copy Properties files to ${admin.dir}/classes -->
<copy todir="${admin.dir}/web/WEB-INF/classes">
<fileset dir="${admin.dir}/src" includes="**/*.properties"/>
</copy>
</target>
<target name="deployAdmin" depends="compileAdmin" description="Deploy Wikicrimes Admin">
<mkdir dir="${deploy.dir}/wikicrimesadmin"/>
<copy todir="${deploy.dir}/wikicrimesadmin" preservelastmodified="true">
<fileset dir="${admin.dir}/web">
<exclude name="**/el-api.jar"/>
</fileset>
</copy>
</target>
<target name="undeploy" description="Deletes application from server">
<delete dir="${deploy.dir}/${webapp.name}"/>
</target>
<target name="deploywar" depends="war" description="Deploy application as a WAR file">
<copy todir="${deploy.dir}" preservelastmodified="true"
file="${build.dir}/${webapp.name}.war"/>
</target>
<target name="geraSchedulerJar" description="Gera o jar do Scheduler">
<mkdir dir="Scheduler/classes"/>
<javac destdir="Scheduler/classes" debug="true" optimize="false"
deprecation="false" failonerror="true" source="1.5" target="1.5">
<src path="Scheduler/src"/>
<classpath>
<path refid="compile.classpath"/>
<fileset dir="Scheduler/api" includes="*.jar"/>
</classpath>
</javac>
<jar destfile="Scheduler/Scheduler.jar"
compress="true">
<fileset dir="Scheduler/classes" />
<fileset dir="Scheduler/api" includes="*.jar"/>
<manifest>
<attribute name="Class-Path" value="commons-email-1.1.jar mail.jar mysql-connector-java-3.1.12-bin.jar"/>
<attribute name="Main-Class" value="org.wikicrimes.main.Main"/>
</manifest>
</jar>
</target>
<target name="clean" description="Clean output directories">
<delete dir="${build.dir}"/>
</target>
<!-- Creates release (source) distribution -->
<target name="dist" depends="clean"
description="create zip and tar.gz of ${webapp.name} for distribution">
<property name="archive.name" value="${webapp.name}-${webapp.version}"/>
<mkdir dir="${build.dir}"/>
<property name="archive.target" value="${build.dir}/${archive.name}"/>
<zip zipfile="${archive.target}.zip">
<zipfileset prefix="${webapp.name}-${webapp.version}" dir="${basedir}">
<patternset id="srcfiles">
<exclude name="*.log"/>
<exclude name="**/*.log"/>
<exclude name="*.i*"/>
<exclude name=".classpath"/>
<exclude name=".project"/>
<exclude name="junit*.properties"/>
<exclude name="**/*~"/>
<exclude name="**/*.bak"/>
<exclude name="*/**.java.txt"/>
<exclude name="${build.dir}/**"/>
<exclude name="**/${build.dir}/**"/>
<exclude name="db/**"/>
<exclude name="sandbox/**"/>
<exclude name="www/**"/>
<exclude name="*.sh"/>
<exclude name=".#*"/>
<exclude name="**/.#*"/>
<exclude name="test-all*"/>
<exclude name="release.*"/>
<include name="**"/>
</patternset>
</zipfileset>
</zip>
<tar tarfile="${archive.target}.tar">
<tarfileset dir="${basedir}" mode="644"
prefix="${webapp.name}"
username="ant" group="ant">
<patternset refid="srcfiles"/>
</tarfileset>
</tar>
<gzip zipfile="${archive.target}.tar.gz" src="${archive.target}.tar"/>
<delete file="${archive.target}.tar"/>
</target>
<!-- populate the database -->
<target name="populate" description="Loads sample data into database">
<echo message="Loading sample data..."/>
<sql driver="${jdbc.driverClassName}" url="${jdbc.url}"
userid="${jdbc.username}" password="${jdbc.password}">
<classpath refid="compile.classpath"/>
<![CDATA[
INSERT INTO app_user (id, first_name, last_name)
values (5, 'Julie', 'Raible');
INSERT INTO app_user (id, first_name, last_name)
values (6, 'Abbie', 'Raible');
]]>
</sql>
</target>
<!-- clear the database -->
<target name="clear" description="Deletes data from database">
<echo message="Deleting data from database..."/>
<sql driver="${jdbc.driverClassName}" url="${jdbc.url}"
userid="${jdbc.username}" password="${jdbc.password}">
<classpath refid="compile.classpath"/>
<![CDATA[
DELETE FROM app_user;
]]>
</sql>
</target>
<!-- Create a new project using this one as a template -->
<target name="new" depends="clean" description="creates a new project with the specified name">
<!-- Prompt user for input -->
<input message="What would you like to name your application [myapp]?"
addproperty="app.name" defaultvalue="myapp"/>
<echo level="info">Creating new application named '${app.name}'...</echo>
<copy todir="../${app.name}">
<fileset dir="${basedir}">
<exclude name="${build.dir}/**"/>
<exclude name="db/**"/>
<exclude name="sandbox/**"/>
<exclude name="${webapp.name}*"/>
<exclude name="*.log"/>
<exclude name="release.xml"/>
<exclude name="**/.#**"/>
<exclude name="*.sh"/>
<exclude name="www/**"/>
<include name="**"/>
</fileset>
</copy>
<!-- Replace current app.name with new app.name -->
<replaceregexp flags="g">
<regexp pattern="wikiCrimes"/>
<substitution expression="${app.name}"/>
<fileset dir="../${app.name}">
<include name="build.xml"/>
<include name="pom.xml"/>
<include name="**/*WebTest.java"/>
</fileset>
</replaceregexp>
</target>
<!-- Fix carriage-return line feeds for installers -->
<target name="fixcrlf" description="Fixed CR/LF problems for installers">
<echo>Running fixcrlf....</echo>
<fixcrlf eol="lf" srcdir="${basedir}"
includes="**/*.sh,
**/*.properties,
**/*.sql,
**/*.java,
**/*.jsp,
**/*.ftl,
**/*.vm,
**/*.xml,
**/*.page,
**/*.html"/>
</target>
<target name="beandoc" description="Generate beandoc reports">
<artifact:dependencies pathId="beandoc.classpath">
<remoteRepository url="http://static.appfuse.org/repository"/>
<dependency groupId="org.springframework" artifactId="beandoc" version="0.7.0"/>
</artifact:dependencies>
<taskdef name="beandoc" classname="org.springframework.beandoc.client.AntTask">
<classpath refid="beandoc.classpath"/>
</taskdef>
<mkdir dir="${build.dir}/beandoc"/>
<beandoc outputDir="${build.dir}/beandoc">
<fileset dir="${web.dir}/WEB-INF">
<include name="*-servlet.xml"/>
<include name="applicationContext*.xml"/>
</fileset>
</beandoc>
<!-- To add graphs to the reports, download/install GraphViz from graphviz.org. -->
<!-- 1. create a beandoc.properties and add the following line to it: -->
<!-- compiler.dotExe=C:/Program Files/ATT/GraphViz/bin/dot.exe -->
<!-- 2. Add beandocProps="beandoc.properties" to the <beandoc> task. -->
</target>
</project>