This repository was archived by the owner on Mar 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.xml
More file actions
337 lines (300 loc) · 11.7 KB
/
Copy pathbuild.xml
File metadata and controls
337 lines (300 loc) · 11.7 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
331
332
333
334
335
336
337
<?xml version="1.0"?>
<project name="dams" default="compile" basedir=".">
<property name="appName" value="dams"/>
<property file="${user.home}/build.properties"/>
<property file="${basedir}/build.properties"/>
<property name="src" value="${basedir}/src"/>
<property name="java" value="${src}/java"/>
<property name="sh" value="${src}/sh"/>
<property name="lib" value="${src}/lib"/>
<property name="lib1" value="${src}/lib1"/>
<property name="lib2" value="${src}/lib2"/>
<property name="root" value="${src}/root"/>
<property name="metainf" value="${src}/metainf"/>
<property name="props" value="${src}/properties"/>
<property name="xsl" value="${src}/xsl"/>
<property name="test" value="${src}/test"/>
<property name="webinf" value="${src}/webinf"/>
<property name="tmp" value="${basedir}/tmp"/>
<property name="webapp" value="${tmp}/webapp"/>
<property name="testexec" value="${tmp}/test"/>
<property name="swiftclient" value="${tmp}/swiftclient"/>
<property name="dist" value="${basedir}/dist"/>
<tstamp>
<format property="build.timestamp" pattern="yyyy-MM-dd'T'HH:mm:ssZ"/>
</tstamp>
<!-- version numbering -->
<target name="version">
<!-- app version from properties files -->
<property file="${props}/version.properties"/>
<property name="app.version"
value="${major.version}.${minor.version}"/>
<!-- src version from 'git describe' -->
<exec executable="git" outputproperty="src.version"
failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--all"/>
<arg value="--always"/>
<arg value="--long"/>
<arg value="--abbrev=40"/>
<arg value="HEAD"/>
</exec>
<condition property="src.version" value="${src.version}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<!-- filters -->
<filterset id="version-filters">
<filter token="app_version" value="${app.version}"/>
<filter token="src_version" value="${src.version}"/>
<filter token="build_timestamp" value="${build.timestamp}"/>
</filterset>
<echo level="info" message="app ver..: ${app.version}"/>
<echo level="info" message="src ver..: ${src.version}"/>
<echo level="info" message="timestamp: ${build.timestamp}"/>
</target>
<path id="classpath">
<fileset dir="${lib}" id="lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib1}" id="lib1">
<include name="*.jar"/>
</fileset>
<fileset dir="${lib2}" id="lib2">
<include name="*.jar"/>
</fileset>
</path>
<!-- remove temp files -->
<target name="clean" description="Delete generated directories">
<delete dir="${tmp}"/>
</target>
<!-- remove temp and dist files -->
<target name="distclean" description="Delete WAR files">
<delete dir="${tmp}"/>
<delete dir="${dist}"/>
</target>
<!-- prepare -->
<target name="prepare" description="Create output directories.">
<mkdir dir="${dist}"/>
<mkdir dir="${tmp}"/>
<mkdir dir="${webapp}/META-INF"/>
<mkdir dir="${webapp}/WEB-INF"/>
<mkdir dir="${webapp}/WEB-INF/lib"/>
<mkdir dir="${webapp}/WEB-INF/classes"/>
<mkdir dir="${webapp}/WEB-INF/xsl"/>
</target>
<!-- compile -->
<target name="compile" description="Compile Java classes."
depends="prepare,version">
<!-- compile -->
<javac destdir="${webapp}/WEB-INF/classes" srcdir="${java}"
deprecation="on" debug="true" debuglevel="lines,source" target="1.8"
includeantruntime="false" source="1.8">
<classpath refid="classpath"/>
<!-- <compilerarg line="-Xlint:unchecked"/> -->
<!-- <compilerarg line="-Xlint:all"/> -->
</javac>
<!-- setup command-line scripts -->
<copy todir="${tmp}/commands">
<fileset dir="${sh}"/>
</copy>
<chmod dir="${tmp}/commands" perm="ugo+rx" includes="**/*.sh"/>
<!-- validation files -->
<copy todir="${tmp}/commands">
<fileset dir="${src}/webinf" includes="**/valid*"/>
</copy>
<!-- jars -->
<copy todir="${tmp}/lib">
<fileset dir="${lib}"/>
<fileset dir="${lib1}"/>
<fileset dir="${lib2}"/>
</copy>
<!-- compiled classes -->
<copy todir="${tmp}/classes">
<fileset dir="${webapp}/WEB-INF/classes"/>
</copy>
<copy todir="${tmp}/test">
<fileset dir="${test}" includes="**/*"/>
</copy>
<!-- sample files -->
<copy todir="${tmp}/sample">
<fileset dir="${src}/sample"/>
</copy>
</target>
<target name="jar" depends="compile">
<!-- jar up classes -->
<jar destfile="${dist}/dams-${app.version}.jar"
basedir="${webapp}/WEB-INF/classes"/>
</target>
<!-- build webapp -->
<target name="webapp" description="Build WAR file" depends="compile">
<!-- move old war file out of the way -->
<move file="${dist}/${appName}.war" tofile="${dist}/${appName}.bak"
failonerror="false"/>
<!-- copy files -->
<copy todir="${webapp}">
<fileset dir="${root}" includes="**/*"/>
</copy>
<copy todir="${webapp}/WEB-INF/lib">
<fileset refid="lib"/>
</copy>
<copy todir="${webapp}/WEB-INF/lib">
<fileset refid="lib1"/>
</copy>
<copy todir="${webapp}/WEB-INF/classes">
<fileset dir="${props}" includes="**/*.properties, fits.xml"/>
</copy>
<copy todir="${webapp}/WEB-INF/xsl">
<fileset dir="${xsl}" includes="**/*.*"/>
</copy>
<copy todir="${webapp}/WEB-INF/">
<fileset dir="${webinf}" includes="*" excludes="context.xml"/>
<fileset dir="${webinf}" includes="**/valid*"/>
<filterset refid="version-filters"/>
</copy>
<copy todir="${webapp}/META-INF/">
<fileset dir="${webinf}" includes="context.xml"/>
</copy>
<!-- generate new war file -->
<war destfile="${dist}/${appName}.war" webxml="${webapp}/WEB-INF/web.xml">
<fileset dir="${webapp}">
<exclude name="WEB-INF/**"/>
<exclude name="META-INF/**"/>
</fileset>
<webinf dir="${webapp}/WEB-INF" excludes="web.xml"/>
<metainf dir="${webapp}/META-INF"/>
</war>
</target>
<!-- deploy webapp -->
<target name="local-deploy" description="Deploy webapp to local dir">
<echo level="info" message="war = 'file://${dist}/${appName}.war'"/>
<copy file="${dist}/${appName}.war" todir="${deploy.home}"/>
</target>
<!-- remote deployment -->
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"
classpathref="classpath"/>
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"
classpathref="classpath"/>
<target name="remote-redeploy"
description="Undeploy and then redeploy webapp to remote tomcat">
<antcall target="remote-undeploy"/>
<waitfor maxwait="1000" maxwaitunit="millisecond">
<equals arg1="1" arg2="2"/>
</waitfor>
<antcall target="remote-deploy"/>
</target>
<target name="remote-deploy" description="Deploy webapp to remote tomcat">
<echo level="info" message="war = 'file://${dist}/${appName}.war'"/>
<deploy url="http://${manager.host}:8080/manager/text" path="/${appName}"
username="${manager.user}" password="${manager.pass}"
war="file://${dist}/${appName}.war"/>
</target>
<target name="remote-undeploy" description="Remove webapp from remote tomcat">
<undeploy url="http://${manager.host}:8080/manager/text" path="/${appName}"
username="${manager.user}" password="${manager.pass}" failonerror="false"/>
</target>
<!-- tomcat -->
<target name="tomcat" description="Update scripts and files in tomcat"
depends="webapp,tomcat-files">
<!-- copy webapp -->
<copy file="${dist}/${appName}.war" todir="${tomcat.home}/tomcat/webapps"/>
</target>
<target name="tomcat-files" description="Update tomcat scripts, sample files">
<!-- command-line scripts -->
<copy todir="${tomcat.home}/dams/bin">
<fileset dir="${sh}"/>
</copy>
<chmod dir="${tomcat.home}/dams/bin" perm="ugo+rx" includes="**/*.sh"/>
<!-- jars -->
<copy todir="${tomcat.home}/dams/lib">
<fileset dir="${lib}"/>
<fileset dir="${lib1}"/>
<fileset dir="${lib2}"/>
</copy>
<!-- compiled classes -->
<copy todir="${tomcat.home}/dams/classes">
<fileset dir="${webapp}/WEB-INF/classes"/>
<fileset dir="${props}" includes="**/*.properties, jhove.conf"/>
</copy>
<!-- copy database driver -->
<copy file="${lib2}/hsqldb.jar" tofile="${tomcat.home}/tomcat/lib/hsqldb.jar"/>
<!-- sample files -->
<copy todir="${tomcat.home}/dams/sample">
<fileset dir="${src}/sample"/>
</copy>
<!-- validation files -->
<copy todir="${tomcat.home}/dams/bin">
<fileset dir="${src}/webinf" includes="**/valid*"/>
</copy>
</target>
<!-- test-compile -->
<target name="test-compile" description="Compile tests" depends="compile">
<mkdir dir="${testexec}"/>
<javac destdir="${testexec}" srcdir="${test}"
deprecation="on" debug="true" debuglevel="lines,source" target="1.8"
includeantruntime="false" source="1.8">
<classpath refid="classpath"/>
<classpath location="${tmp}/classes"/>
</javac>
</target>
<target name="test" description="Run tests" depends="compile,test-compile">
<junit showoutput="true" printsummary="withOutAndErr" haltonfailure="yes">
<sysproperty key="dams.samples" value="${src}/sample"/>
<formatter type="plain"/>
<classpath refid="classpath"/>
<classpath location="${tmp}/classes"/>
<classpath>
<pathelement path="${testexec}"/>
</classpath>
<batchtest todir="${tmp}">
<fileset dir="${test}">
<include name="**/*Test*.java"/>
<exclude name="**/AbstractIntegrationTest.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="junit" depends="distclean,compile,test-compile">
<junit showoutput="true" printsummary="withOutAndErr" haltonfailure="yes">
<sysproperty key="dams.samples" value="${src}/sample"/>
<formatter type="plain"/>
<classpath refid="classpath"/>
<classpath location="${tmp}/classes"/>
<classpath>
<pathelement path="${testexec}"/>
</classpath>
<batchtest todir="${tmp}">
<fileset dir="${test}">
<include name="**/*Test.java"/>
<exclude name="**/integration/*.java"/>
</fileset>
</batchtest>
</junit>
</target>
<!-- package swiftclient and deps -->
<target name="swiftclient" description="Package SwiftClient" depends="jar">
<!-- create directories -->
<mkdir dir="${swiftclient}"/>
<mkdir dir="${swiftclient}/lib"/>
<!-- copy files -->
<copy file="${sh}/swiftclient.sh" todir="${swiftclient}"/>
<copy file="${props}/swiftclient.properties.sample" tofile="${swiftclient}/swiftclient.properties"/>
<copy file="${dist}/dams-${app.version}.jar" todir="${swiftclient}/lib"/>
<copy file="${lib}/commons-logging-1.1.1.jar" todir="${swiftclient}/lib"/>
<copy file="${lib}/httpclient-4.2.1.jar" todir="${swiftclient}/lib"/>
<copy file="${lib}/httpcore-4.2.1.jar" todir="${swiftclient}/lib"/>
<copy file="${lib}/httpmime-4.2.1.jar" todir="${swiftclient}/lib"/>
<copy file="${lib}/log4j-1.2.16.jar" todir="${swiftclient}/lib"/>
<!-- make scripts executable -->
<chmod dir="${swiftclient}" perm="ugo+rx" includes="*.sh"/>
<!-- create tarball -->
<tar destfile="${dist}/swiftclient.tar.gz" compression="gzip"
basedir="${tmp}" includes="swiftclient/**" excludes="**/*.sh">
<tarfileset dir="${tmp}" filemode="755">
<include name="swiftclient/swiftclient.sh"/>
</tarfileset>
</tar>
</target>
</project>