forked from marc4j/marc4j
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
438 lines (400 loc) · 19.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
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
<?xml version="1.0" encoding="utf-8"?>
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="marc4j" default="jar" basedir=".">
<target name="init">
<tstamp />
<!-- <record name="build.log" loglevel="verbose" append="no" /> -->
</target>
<property file="build.properties" />
<tstamp>
<format property="TODAY" pattern="yyyy-MM-dd HH:mm:ss Z" timezone="GMT" />
</tstamp>
<target name="prepare" depends="init,setup-ivy" unless="prepared">
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${build.test-classes.dir}"/>
<mkdir dir="${build.generated-src.dir}"/>
<mkdir dir="${lib.dir}"/>
<ivy:retrieve />
<!-- <property file="${user.home}/gnupg.properties"/>
<taskdef resource="org/apache/commons/openpgp/ant/antlib.xml">
<classpath>
<pathelement location="${user.home}/.m2/repository/org/bouncycastle/bcprov-jdk12/130/bcprov-jdk12-130.jar"/>
<pathelement location="${user.home}/.m2/repository/org/apache/commons/commons-openpgp/1.0-SNAPSHOT/commons-openpgp-1.0-SNAPSHOT.jar"/>
<pathelement location="${user.home}/.m2/repository/org/bouncycastle/bcpg-jdk12/130/bcpg-jdk12-130.jar"/>
</classpath>
</taskdef><condition property="gpg.dir" value="${user.home}/AppData/Roaming/gnupg"><os family="windows"/></condition><property name="gpg.dir" location="${user.home}/.gnupg"/> -->
<property name="prepared" value="true"/>
</target>
<path id="classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="test.classpath">
<pathelement location="${build.classes.dir}" />
<pathelement location="${build.test-classes.dir}" />
<pathelement location="test/resources"/>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<target name="prepare-codetablegen" depends="prepare">
<mkdir dir="${build.generated-src.dir}/org/marc4j/converter/impl" />
<dependset>
<srcfileset dir="${src.dir}/org/marc4j/converter/impl/"/>
<targetfileset dir="${build.generated-src.dir}/org/marc4j/converter/impl/" includes="*.java"/>
</dependset>
<available file="${build.generated-src.dir}/org/marc4j/converter/impl/CodeTableGenerated.java" property="already.ctged"/>
</target>
<target name="codetablegen" depends="prepare-codetablegen" unless="already.ctged">
<java fork="true" classname="org.marc4j.converter.impl.CodeTableGenerator" errorproperty="CodeTableGenerated.error" output="${build.generated-src.dir}/org/marc4j/converter/impl/CodeTableGenerated.java" >
<classpath location="${build.classes.dir}" />
<arg value="MARC8"/>
</java>
<java fork="true" classname="org.marc4j.converter.impl.ReverseCodeTableGenerator" errorproperty="ReverseCodeTableGenerated.error" output="${build.generated-src.dir}/org/marc4j/converter/impl/ReverseCodeTableGenerated.java" >
<classpath location="${build.classes.dir}" />
<arg value="MARC8"/>
</java>
<java fork="true" classname="org.marc4j.converter.impl.CodeTableGenerator" errorProperty="UnimarcCodeTableGenerated.error" output="${build.generated-src.dir}/org/marc4j/converter/impl/UnimarcCodeTableGenerated.java" >
<classpath location="${build.classes.dir}" />
<arg value="UNIMARC"/>
</java>
<java fork="true" classname="org.marc4j.converter.impl.ReverseCodeTableGenerator" errorProperty="UnimarcReverseCodeTableGenerated.error" output="${build.generated-src.dir}/org/marc4j/converter/impl/UnimarcReverseCodeTableGenerated.java" >
<classpath location="${build.classes.dir}" />
<arg value="UNIMARC"/>
</java>
<!-- <concat >
<fileset dir="${build.generated-src.dir}/org/marc4j/converter/impl" includes="Code*.java" />
<filterchain>
<headfilter lines="15"/>
</filterchain>
</concat>
<concat >
<fileset dir="${build.generated-src.dir}/org/marc4j/converter/impl" includes="Rev*.java" />
<filterchain>
<headfilter lines="15"/>
</filterchain>
</concat> -->
</target>
<target name="compile-codegen" depends="codetablegen">
<javac encoding="UTF-8" srcdir="${build.generated-src.dir}" destdir="${build.classes.dir}" includes="**/*Generated.java" debug="false">
<classpath refid="classpath" />
</javac>
</target>
<target name="compile-all" depends="compile-base,compile-codegen"/>
<target name="compile-base" depends="prepare">
<javac encoding="UTF-8" srcdir="${src.dir}" destdir="${build.classes.dir}" includes="**/*.java" excludes="**/*Generated.java" debug="true" debuglevel="source,lines,vars">
<classpath refid="classpath" />
</javac>
<copy todir="${build.classes.dir}">
<fileset dir="${src.dir}">
<include name="**/*.properties" />
<include name="**/*.xml" />
<exclude name="**/tests/*" />
<exclude name="**/tests" />
</fileset>
</copy>
</target>
<target name="compile-tests" depends="compile-all">
<javac encoding="UTF-8" srcdir="${test.src.dir}" destdir="${build.test-classes.dir}" includes="**/*.java" excludes="**/*Generated.java" debug="true" debuglevel="source,lines,vars">
<classpath refid="test.classpath" />
</javac>
</target>
<target name="test" depends="compile-all,compile-tests">
<junit fork="yes" forkmode="perBatch" haltonfailure="true">
<batchtest>
<fileset dir="${test.src.dir}">
<exclude name="org/marc4j/test/utils/**"/>
</fileset>
</batchtest>
<formatter type="brief" usefile="false" />
<classpath refid="test.classpath" />
</junit>
</target>
<target name="jar" depends="compile-all,version">
<jar jarfile="${build.dir}/${jar.name}">
<manifest>
<attribute name="Main-Class" value="org.marc4j.util.UtilDriver"/>
<attribute name="Version" value="${version}"/>
<attribute name="Built-Date" value="${TODAY}"/>
<section name="org/marc4j">
<attribute name="Specification-Title" value="marc4j"/>
<attribute name="Specification-Version" value="${specversion}"/>
<attribute name="Specification-Vendor" value="org.marc4j"/>
<attribute name="Implementation-Title" value="marc4j"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="Team marc4j"/>
</section>
</manifest>
<fileset dir="${build.classes.dir}">
<include name="**/*.class" />
<exclude name="**/CodeTableGenerator.class" />
<exclude name="**/ReverseCodeTableGenerator.class" />
<exclude name="**/samples/**/*.*" />
<exclude name="**/solrmarc/**/*.class" />
<exclude name="**/test/**/*.*" />
<include name="**/*.properties" />
<exclude name="**/*.xml" />
</fileset>
</jar>
</target>
<target name="javadoc" depends="prepare" unless="javadoc.already.run" >
<mkdir dir="${apidoc.dir}" />
<javadoc encoding="UTF-8" charset="UTF-8" docencoding="UTF-8" destdir="${apidoc.dir}" author="true" version="true" overview="overview.html" use="true" windowtitle="MARC4J API" doctitle="MARC4J API" bottom="Copyright © 2002-2006 Bas Peters. All Rights Reserved.">
<packageset dir="${src.dir}" defaultexcludes="yes">
<exclude name="org/marc4j/samples" />
<exclude name="org/marc4j/test" />
</packageset>
<classpath refid="classpath" />
<link offline="true" href="http://java.sun.com/products/jdk/1.6/docs/api/" packagelistLoc="." />
</javadoc>
<property name="javadoc.already.run" value="true" />
</target>
<target name="clean" depends="init">
<delete includeEmptyDirs="true">
<fileset dir="${dist.dir}" includes="**/*" defaultexcludes="no"/>
</delete>
<delete dir="${build.dir}" />
</target>
<target name="distclean" depends="clean">
<delete dir="${lib.dir}"/>
<delete dir="${ivy.jar.dir}"/>
</target>
<target name="dist" depends="jar,javadoc" unless="dist.already.run" >
<property name="prefix" value="${project.name}-${version}" />
<property name="tmp.dir" value="${dist.dir}/tmp" />
<property name="tmp.arc.dir" value="${tmp.dir}/${prefix}" />
<property name="dist.arc" value="${dist.dir}/${prefix}" />
<mkdir dir="${tmp.arc.dir}" />
<copy file="${build.dir}/${jar.name}" tofile="${dist.dir}/${jar.name}" overwrite="true" />
<copy file="${basedir}/pom_template.xml" tofile="${dist.dir}/${project.name}-${version}.pom" overwrite="true" >
<filterchain>
<replacetokens>
<token key="VERSION" value="${version}"/>
</replacetokens>
</filterchain>
</copy>
<copy todir="${tmp.arc.dir}">
<fileset dir=".">
<include name="LICENSE.*" />
<include name="build.*" />
<exclude name="*.log" />
<include name="*.jar" />
<include name="*.html" />
</fileset>
</copy>
<copy todir="${tmp.arc.dir}" file="${build.dir}/${jar.name}"/>
<copy todir="${tmp.arc.dir}/${src.dir}">
<fileset dir="${src.dir}" >
<exclude name="**/CodeTableGenerated.java" />
</fileset>
</copy>
<copy todir="${tmp.arc.dir}/${test.src.dir}">
<fileset dir="${test.src.dir}" >
</fileset>
</copy>
<copy todir="${tmp.arc.dir}/${lib.dir}">
<fileset dir="${lib.dir}">
<exclude name="junit*.jar" />
</fileset>
</copy>
<copy todir="${tmp.arc.dir}/apidoc">
<fileset dir="${apidoc.dir}" />
</copy>
<tar tarfile="${dist.arc}.tar" basedir="${tmp.arc.dir}" />
<gzip zipfile="${dist.arc}.tar.gz" src="${dist.arc}.tar" />
<delete file="${dist.arc}.tar" />
<delete file="${dist.arc}.zip" />
<zip compress="true" basedir="${tmp.dir}" zipfile="${dist.arc}.zip" />
<delete dir="${tmp.dir}" />
<jar jarfile="${dist.dir}/${jar.javadoc.name}">
<manifest>
<section name="org/marc4j">
<attribute name="Specification-Title" value="marc4j"/>
<attribute name="Specification-Version" value="${specversion}"/>
<attribute name="Specification-Vendor" value="org.marc4j"/>
<attribute name="Implementation-Title" value="marc4j"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="Team marc4j"/>
</section>
</manifest>
<fileset dir="${apidoc.dir}">
<include name="**" />
</fileset>
</jar>
<jar jarfile="${dist.dir}/${jar.sources.name}" >
<manifest>
<section name="org/marc4j">
<attribute name="Specification-Title" value="marc4j"/>
<attribute name="Specification-Version" value="${specversion}"/>
<attribute name="Specification-Vendor" value="org.marc4j"/>
<attribute name="Implementation-Title" value="marc4j"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Implementation-Vendor" value="Team marc4j"/>
</section>
</manifest>
<fileset dir="${src.dir}">
<include name="**/*.java" />
<exclude name ="**/samples/**" />
</fileset>
<fileset dir="${build.generated-src.dir}">
<include name="**/*.java" />
</fileset>
</jar>
<property name="dist.already.run" value="true" />
</target>
<target name="sign" depends="dist" if="gpg.exe" unless="is.snapshot" >
<delete dir="${dist.dir}" includes="*.asc" />
<input message="Enter Pass Phrase for Signing" addproperty="passphrase" >
<!-- <handler classname="org.apache.tools.ant.input.SecureInputHandler" /> -->
</input>
<!-- - -batch -a - -passphrase "ENTERED_PASSPHRASE" - -detach-sign $file -->
<exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
<arg value="${passphrase}" />
<arg value="--detach-sign" />
<arg value="${jar.name}" />
</exec>
<exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
<arg value="${passphrase}" />
<arg value="--detach-sign" />
<arg value="${jar.sources.name}" />
</exec>
<exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
<arg value="${passphrase}" />
<arg value="--detach-sign" />
<arg value="${jar.javadoc.name}" />
</exec>
<exec executable="${gpg.exe}" dir="${dist.dir}" searchpath="true" >
<arg value="--batch" />
<arg value="-a" />
<arg value="--passphrase" />
<arg value="${passphrase}" />
<arg value="--detach-sign" />
<arg value="${project.name}-${version}.pom" />
</exec>
<jar jarfile="${dist.dir}/bundle-${version}.jar" >
<fileset dir="${dist.dir}">
<include name="marc4j*.jar" />
<include name="marc4j*.pom" />
<include name="marc4j*.asc" />
</fileset>
</jar>
</target>
<property name="ivy.install.version" value="2.5.0" />
<property name="ivy.jar.dir" value="${basedir}/ivy" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<target name="check-download" >
<available file="${ivy.jar.file}" property="skip.download"/>
</target>
<target name="download-ivy" depends="check-download" unless="skip.download">
<mkdir dir="${ivy.jar.dir}"/>
<echo message="installing ivy..."/>
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true"/>
</target>
<target name="setup-ivy" depends="download-ivy" description="--> setup ivy" unless="prepared">
<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="-version1" unless="version" >
<mkdir dir="${dist.dir}/tmp" />
<get src="https://api.github.com/repos/marc4j/marc4j/releases/latest" dest="${dist.dir}/tmp/git.release.txt" />
<loadfile srcfile="${dist.dir}/tmp/git.release.txt" property="versionstr" >
<filterchain>
<tokenfilter>
<replacestring from="," to=",${line.separator}" />
</tokenfilter>
<linecontains>
<contains value="tag_name"/>
</linecontains>
<tokenfilter>
<replaceregex pattern=".*"tag_name":[ ]*"([0-9.]*).*" replace="\1" />
</tokenfilter>
<striplinebreaks/>
</filterchain>
</loadfile>
<loadresource property="specversion">
<propertyresource name="versionstr"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replaceregex pattern="[.][0-9]*$" replace=""/>
</tokenfilter>
</filterchain>
</loadresource>
<echo message="specversion = ${specversion}" />
<echo message="versionstr = ${versionstr}" />
</target>
<target name="-version2" unless="version" >
<get src="https://api.github.com/repos/marc4j/marc4j/compare/${versionstr}...master" dest="${dist.dir}/tmp/git.commits.txt" />
<loadfile srcfile="${dist.dir}/tmp/git.commits.txt" property="versionsuffix" >
<filterchain>
<tokenfilter>
<replacestring from="," to=", ${line.separator}" />
</tokenfilter>
<linecontains>
<contains value="total_commits"/>
</linecontains>
<striplinebreaks/>
<tokenfilter>
<replaceregex pattern=".*"total_commits":[ ]*([1-9][0-9]*).*" replace="-\1-SNAPSHOT" />
<replaceregex pattern=".*"total_commits":[ ]*(0).*" replace="" />
</tokenfilter>
</filterchain>
</loadfile>
<echo message="versionsuffix = ${versionsuffix}" />
<property name="versionsuffix" value="" />
<echo message="versionsuffix = ${versionsuffix}" />
<!-- <delete dir="${dist.dir}/tmp" /> -->
</target>
<available file=".git" type="dir" property="git.present"/>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present" unless="version">
<property environment="env"/>
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="git.not.found">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--dirty=-SNAPSHOT"/>
<arg value="--always"/>
</exec>
<exec executable="git" outputproperty="git.major.revision" failifexecutionfails="false" errorproperty="git.not.found">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--abbrev=0"/>
</exec>
<condition property="version" value="${git.revision}">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<condition property="versionstr" value="${git.major.revision}">
<and>
<isset property="git.major.revision"/>
<length string="${git.major.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
<target name="version" depends="git.revision,-version1,-version2" description="Get the version number to use from github" >
<echo message="git.revision = ${git.revision}" />
<property name="version" value="${versionstr}${versionsuffix}" />
<echo message="version = ${version}" />
<condition property="is.snapshot">
<contains string="${version}" substring="SNAPSHOT" />
</condition>
<echo message="is.snapshot = ${is.snapshot}" />
<property name="jar.name" value="${project.name}-${version}.jar" />
<property name="jar.sources.name" value="${project.name}-${version}-sources.jar" />
<property name="jar.javadoc.name" value="${project.name}-${version}-javadoc.jar" />
<property name="test.jar.name" value="${project.name}_test-${version}.jar" />
</target>
</project>