forked from harvard-lts/fits
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.xml
More file actions
313 lines (252 loc) · 11.7 KB
/
build.xml
File metadata and controls
313 lines (252 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
<!-- ====================================================================== -->
<!-- Slightly modified version of OIS Standard Build file. -->
<!-- Removed .java files from JAR -->
<!-- ====================================================================== -->
<project name="FITS Build File" default="compile" basedir=".">
<!-- ===================== Property Definitions =========================== -->
<property file="version.properties"/>
<!-- ==================== File and Directory Names ======================== -->
<property name="app.name" value="fits"/>
<property name="app.longName" value="File Information Toolset"/>
<property name="app.package" value="edu.harvard.hul.ois.fits"/>
<property name="fits.jar.name" value="${app.name}-${build.version}.jar"/> <!-- build.version comes from version.properties file -->
<property name="fits.jar.home" value="lib-fits"/>
<property name="src.dirs" value="src"/>
<property name="test.dirs" value="tests"/>
<property name="javadoc.home" value="javadoc"/>
<property name="manifest.name" value="MANIFEST.MF"/>
<property name="output.location" value="release_temp"/>
<property name="junit.reports.dir" value="test-generated-output/ant-junit-test-reports" />
<property name="build.dir" value="build" />
<!-- ===================== Compilation Control Options ==================== -->
<!--
These properties control option settings on the Javac compiler when it
is invoked using the <javac> task.
compile.debug Should compilation include the debug option?
compile.deprecation Should compilation include the deprecation option?
compile.optimize Should compilation include the optimize option?
-->
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="true"/>
<property name="compile.optimize" value="true"/>
<!-- ==================== Compilation Classpath =========================== -->
<!--
Rather than relying on the CLASSPATH environment variable, Ant includes
features that makes it easy to dynamically construct the classpath you
need for each compilation. The example below constructs the compile
classpath to include the servlet.jar file, as well as the other components
that Tomcat makes available to web applications automatically, plus anything
that you explicitly added.
-->
<path id="compile.classpath">
<!-- Include all JAR files that will be included in lib -->
<!-- Some tool subdirectories may not have any JAR files but are included for future expansion -->
<fileset dir=".">
<include name="lib/*.jar"/>
<include name="lib/adltool/*.jar"/>
<include name="lib/audioinfo/*.jar"/>
<include name="lib/droid/*.jar"/>
<include name="lib/exiftool/*.jar"/>
<include name="lib/ffident/*.jar"/>
<include name="lib/fileinfo/*.jar"/>
<include name="lib/fileutility/*.jar"/>
<include name="lib/jhove/*.jar"/>
<include name="lib/mediainfo/*.jar"/>
<include name="lib/nzmetool/*.jar"/>
<include name="lib/tika/*.jar"/>
<include name="lib/xmlmetadata/*.jar"/>
</fileset>
</path>
<path id="junit.classpath">
<!-- Include all JAR files related to unit tests -->
<pathelement path="${build.dir}"/>
<fileset dir=".">
<include name="lib-ant/*.jar" />
</fileset>
</path>
<!-- ==================== Compile Target ================================== -->
<!--
The "compile" target transforms source files (from your "src" directory)
into object files in the appropriate location in the build directory.
-->
<target name="compile" description="Compile Java sources">
<mkdir dir="${build.dir}"/>
<javac debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
destdir="${build.dir}"
includeantruntime="false" source="1.7" target="1.7">
<src path="${src.dirs}" />
<src path="${test.dirs}" />
<classpath refid="junit.classpath" />
<classpath refid="compile.classpath" />
</javac>
</target>
<target name="compile-create-jar" depends="compile, check-build" description="Compile sources and create fits.jar">
<fail unless="${build.present}" message="${build.dir} not present"/>
<mkdir dir="${fits.jar.home}"/>
<antcall target="create-manifest" />
<jar jarfile="${fits.jar.home}/${fits.jar.name}"
update="true"
manifest="${manifest.name}">
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
</jar>
<antcall target="delete-manifest" />
</target>
<target name="clean-compile-jar" if="fits.jar.preset" depends="clean, compile-create-jar, check-fits-jar" description="Clean, compile all code and create a fits.jar">
</target>
<!-- ==================== Clean Target ==================================== -->
<!--
The "clean" target deletes any previous "build" and "dist" directory,
so that you can be ensured the application can be built from scratch.
-->
<target name="clean" description="Delete old build and dist directories">
<delete dir="${build.dir}" quiet="true" />
<delete dir="${fits.jar.home}" quiet="true"/>
<delete dir="${javadoc.home}" quiet="true"/>
</target>
<!-- ===================== Create Tmp Jar Target ========================== -->
<target name="create-manifest">
<condition property="jar.version"
value="${build.version}">
<and>
<isset property="build.version" />
</and>
</condition>
<tstamp>
<format property="timestamp.isoformat"
pattern="yyyy-MM-dd'T'HH:mm:ss"/>
</tstamp>
<condition property="build.timestamp" value="development" else="${timestamp.isoformat}">
<not>
<isset property="jar.version" />
</not>
</condition>
<condition property="build.date" value="development" else="${TODAY}">
<not>
<isset property="jar.version" />
</not>
</condition>
<condition property="jar.version" value="development">
<not>
<isset property="jar.version" />
</not>
</condition>
<manifest file="${manifest.name}">
<attribute name="Application-Name" value="${app.longName}"/>
<attribute name="Specification-Title" value="${app.name} Java Classes"/>
<attribute name="Specification-Version" value="${jar.version}"/>
<attribute name="Implementation-Title" value="${app.package}"/>
<attribute name="Implementation-Version" value="${jar.version}"/>
<attribute name="Implementation-Vendor" value="OIS Harvard University Library"/>
<attribute name="Build-Date" value="${build.date}"/>
<attribute name="Build-Timestamp" value="${build.timestamp}"/>
</manifest>
</target>
<target name="delete-manifest">
<delete quiet="true" file="${manifest.name}" />
</target>
<!-- ==================== Javadoc Target ================================== -->
<!--
The "javadoc" target creates Javadoc API documentation for the Java
classes included in your application. Normally, this is only required
when preparing a distribution release, but is available as a separate
target in case the developer wants to create Javadocs independently.
-->
<target name="javadoc" description="Create Javadoc API documentation">
<mkdir dir="${javadoc.home}"/>
<javadoc destdir="${javadoc.home}" packagenames="*">
<fileset dir=".">
<include name="${src.dirs}/**/*.java"/>
<include name="${test.dirs}/**/*.java"/>
</fileset>
<classpath refid="compile.classpath"/>
<classpath refid="junit.classpath"/>
</javadoc>
</target>
<!-- ==================== Check and Set Targets =========================== -->
<target name="check-fits-jar">
<available file="${fits.jar.home}/${fits.jar.name}" property="fits.jar.preset" />
</target>
<target name="check-build">
<available file="${build.dir}" type="dir" property="build.present" />
</target>
<!-- ========================= Release Targets ============================ -->
<target name="release" depends="clean-compile-jar, check-fits-jar, javadoc">
<fail unless="fits.jar.preset" message="There is no ${fits.jar.name} in ${fits.jar.home}"/>
<property name="output.location.version"
value="${output.location}/${app.name}-${build.version}"/>
<mkdir dir="${output.location}" />
<copy todir="${output.location.version}/xml">
<fileset dir="xml">
<exclude name="**/CVS"/>
<exclude name="**/.cvsignore"/>
</fileset>
</copy>
<copy todir="${output.location.version}/tools">
<fileset dir="tools">
<exclude name="**/CVS"/>
<exclude name="**/.cvsignore"/>
</fileset>
</copy>
<copy todir="${output.location.version}/lib">
<fileset dir="lib">
<exclude name="**/CVS"/>
<exclude name="**/.cvsignore"/>
</fileset>
</copy>
<copy todir="${output.location.version}/lib" file="${fits.jar.home}/${fits.jar.name}" description="copy fits.jar" />
<copy todir="${output.location.version}/javadoc">
<fileset dir="${javadoc.home}" />
</copy>
<copy file="log4j.properties" todir="${output.location.version}"/>
<copy file="cpappend.bat" todir="${output.location.version}"/>
<copy file="fits.bat" todir="${output.location.version}"/>
<copy file="fits.sh" todir="${output.location.version}"/>
<copy file="fits-env.sh" todir="${output.location.version}"/>
<copy file="fits-ngserver.sh" todir="${output.location.version}"/>
<copy todir="${output.location.version}">
<fileset dir="." includes="*.md" />
</copy>
<copy file="version.properties" todir="${output.location.version}"/>
<antcall target="zip-output" />
<antcall target="delete-output" />
</target>
<target name="zip-output">
<input message="Enter output location for zip file:" addproperty="zip.output"/>
<zip destfile="${zip.output}/${app.name}-${build.version}.zip">
<zipfileset dir="${output.location}" excludes="**/*.sh" />
<zipfileset dir="${output.location}" includes="**/*.sh" filemode="755" />
</zip>
</target>
<target name="delete-output">
<delete dir="${output.location}" quiet="true"/>
</target>
<target name="unit-tests" depends="compile">
<property name="halt.tests.on.failure" value="true"/> <!-- whether to terminate tests once first test failure encountered -->
<property name="halt.tests.on.error" value="true"/> <!-- whether to terminate tests once first test error encountered -->
<!--
Assumes ant-junit4.jar is already on classpath from Ant installation
see https://ant.apache.org/manual/Tasks/junit.html
Also, due to the intensive nature of some of the tests, it may be necessary to increase the
memory for running Ant to avoid a "java.lang.OutOfMemoryError: PermGen space"
Try adding the environment setting ANT_OPTS=-XX:MaxPermSize=1024m
or, when running in Eclipse, modifying the eclipse.ini file by adding -XX:MaxPermSize=1024m
-->
<junit fork="true" forkmode="perTest" logfailedtests="true" printsummary="withOutAndErr"
haltonfailure="${halt.tests.on.failure}" haltonerror="${halt.tests.on.error}">
<classpath refid="junit.classpath" />
<classpath refid="compile.classpath" />
<batchtest skipNonTests="true" todir="${junit.reports.dir}">
<fileset dir="${test.dirs}">
<!-- tests to exclude due to known errors in tests -->
<exclude name="**/FitsOutputXmlTest.java"/>
<exclude name="**/FitsOutputXmlTest.class"/>
</fileset>
</batchtest>
<formatter type="plain"/>
</junit>
</target>
</project>