forked from intoolswetrust/jsignpdf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
493 lines (434 loc) · 17 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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<?xml version="1.0" encoding="UTF-8"?>
<project name="JSignPdf" default="all" basedir=".">
<description>Builds JSignPdf project</description>
<!-- import properties -->
<import file="properties.xml"/>
<taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler">
<classpath>
<pathelement location="${jarbundler.jar}"/>
</classpath>
</taskdef>
<filterset id="jsignpdf.filterset">
<filter token="JSIGNPDF_VERSION" value="${jsignpdf.version}"/>
<filter token="JSIGNPDF_FILENAME" value="${jsignpdf.filename}"/>
</filterset>
<path id="project.classpath">
<path refid="ooo.classpath"/>
<fileset dir="${dist.dir}/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="_check_sf_ready_file">
<condition property="sfProjectReady">
<available file="${sfProjectArchive}"/>
</condition>
</target>
<target name="_get_sf_archive" depends="_check_sf_ready_file" unless="sfProjectReady">
<get src="http://mesh.dl.sourceforge.net/sourceforge/${sfProject}/${sfProjectArchive}"
dest="${sfProjectArchive}"/>
</target>
<!-- Clean build - removes directories created during build (except checkout) -->
<target name="clean">
<echo message="Cleaning build" />
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${output.dir}"/>
<ant antfile="jsignpdf-itxt/src/build.xml" useNativeBasedir="true" target="clean" />
</target>
<target name="jsignpdf-itxt" depends="prepare">
<echo message="Creating JSignPdf-itxt"/>
<property name="releasenumber" value="${jsignpdf.version}"/>
<property name="product.name" value="${jsignpdf.product.name}"/>
<tstamp>
<format property="releasedate" pattern="yyyy-MM-dd"/>
</tstamp>
<ant antfile="jsignpdf-itxt/src/build.xml" useNativeBasedir="true" target="release-1.4" />
<copy todir="${bin.plugin.dir}/lib" file="jsignpdf-itxt/build/release/dist/jsignpdf-itxt-${jsignpdf.version}.jar"/>
<copy todir="${dist.dir}/lib" file="jsignpdf-itxt/build/release/dist/jsignpdf-itxt-${jsignpdf.version}.jar"/>
<copy todir="${output.dir}" file="jsignpdf-itxt/build/release/dist/jsignpdf-itxt-${jsignpdf.version}-sources.jar"/>
</target>
<!-- Prepare directory structure for the build -->
<target name="prepare" depends="clean">
<echo message="Preparing directory structure for the build" />
<mkdir dir="${bin.dir}"/>
<mkdir dir="${src.filtered.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${dist.doc.dir}"/>
<mkdir dir="${output.dir}"/>
<echo message="Copying sources and resources with filter" />
<copy todir="${src.filtered.dir}">
<fileset dir="${src.dir}">
<include name="**"/>
</fileset>
<filterset refid="jsignpdf.filterset"/>
</copy>
<copy todir="${bin.plugin.dir}">
<fileset dir="${plugin.dir}">
<include name="**"/>
</fileset>
<filterset refid="jsignpdf.filterset"/>
</copy>
<copy todir="${dist.dir}">
<fileset dir=".">
<include name="conf/**"/>
</fileset>
</copy>
<copy todir="${bin.plugin.dir}">
<fileset dir=".">
<include name="images/**"/>
<include name="lib/*.jar"/>
<include name="licenses/**"/>
<include name="conf/**"/>
</fileset>
</copy>
<copy todir="${bin.dir}">
<fileset dir="${res.dir}">
<include name="**"/>
</fileset>
</copy>
<copy todir="${dist.dir}">
<fileset dir="${bin.plugin.dir}">
<include name="lib/*.jar"/>
</fileset>
</copy>
<!-- SF.net handles README automatically (replacement for the old Release Notes) -->
<copy file="doc/ReleaseNotes.txt" tofile="${output.dir}/README.txt"/>
<copy todir="${dist.doc.dir}">
<fileset dir="licenses">
<include name="**"/>
</fileset>
<fileset dir="doc">
<include name="*.txt"/>
</fileset>
</copy>
</target>
<!-- Compile sources -->
<target name="compile" depends="prepare,jsignpdf-itxt">
<echo message="Compiling sources" />
<javac srcdir="${src.filtered.dir}" nowarn="${compile.nowarn}"
destdir="${bin.dir}" debug="${compile.debug}"
deprecation="${compile.deprecation}" optimize="${compile.optimize}"
source="${compile.source}" target="${compile.target}"
classpathref="project.classpath">
</javac>
</target>
<target name="unpack-jre" depends="prepare">
<echo message="Unpacking JRE" />
<unzip src="${jre.zip}" dest="${dist.dir}"/>
</target>
<!-- Create jar for the project -->
<target name="jar" depends="compile">
<echo message="Creating JAR file" />
<!-- create Class-Path attribute value for MANIFEST.MF -->
<pathconvert property="manifest.classpath" pathsep=" ">
<path>
<fileset dir="${dist.dir}/lib">
<include name="*.jar" />
</fileset>
</path>
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
</pathconvert>
<pathconvert property="instcert.manifest.classpath" pathsep=" ">
<path>
<fileset dir="${dist.dir}/lib">
<include name="commons-io*.jar" />
<include name="commons-lang*.jar" />
</fileset>
</path>
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
</pathconvert>
<jar destfile="${dist.dir}/${jsignpdf.filename}.jar">
<manifest>
<attribute name="Main-Class" value="net.sf.jsignpdf.Signer"/>
<attribute name="Class-Path" value="${manifest.classpath}" />
<attribute name="RegistrationClassName" value="net.sf.jsignpdf.ooo.CentralRegistrationClass" />
<attribute name="Implementation-Vendor" value="Josef Cacek"/>
<attribute name="Implementation-Title" value="JSignPdf"/>
<attribute name="Implementation-Version" value="${jsignpdf.version} ${build.timestamp}"/>
<section name="net/sf/jsignpdf/ooo/CentralRegistrationClass.class">
<attribute name="RegistrationClasses" value="net.sf.jsignpdf.ooo.JSignPdf" />
</section>
</manifest>
<fileset dir="${bin.dir}"/>
</jar>
<jar destfile="${dist.dir}/${verifier.filename}.jar">
<manifest>
<attribute name="Main-Class" value="net.sf.jsignpdf.verify.Verifier"/>
<attribute name="Class-Path" value="${jsignpdf.filename}.jar" />
<attribute name="Implementation-Vendor" value="Josef Cacek"/>
<attribute name="Implementation-Title" value="JSignPdf Verifier"/>
<attribute name="Implementation-Version" value="${jsignpdf.version} ${build.timestamp}"/>
</manifest>
</jar>
<jar destfile="${dist.dir}/${installcert.filename}.jar">
<manifest>
<attribute name="Main-Class" value="net.sf.jsignpdf.InstallCert"/>
<attribute name="Class-Path" value="${instcert.manifest.classpath}" />
<attribute name="Implementation-Vendor" value="Josef Cacek"/>
<attribute name="Implementation-Title" value="JSignPdf - InstallCert"/>
<attribute name="Implementation-Version" value="${jsignpdf.version} ${build.timestamp}"/>
</manifest>
<fileset dir="${bin.dir}">
<include name="**/InstallCert*.class"/>
</fileset>
<fileset dir="${src.filtered.dir}">
<include name="**/InstallCert.java"/>
</fileset>
</jar>
<jar destfile="${dist.dir}/${sigcounter.filename}.jar">
<manifest>
<attribute name="Main-Class" value="net.sf.jsignpdf.verify.SignatureCounter"/>
<attribute name="Implementation-Vendor" value="Josef Cacek"/>
<attribute name="Implementation-Title" value="JSignPdf - Signature Counter"/>
<attribute name="Implementation-Version" value="${jsignpdf.version} ${build.timestamp}"/>
<attribute name="Class-Path" value="${manifest.classpath}" />
</manifest>
<fileset dir="${bin.dir}">
<include name="**/PdfUtils*.class"/>
<include name="**/SignatureCounter*.class"/>
</fileset>
</jar>
</target>
<target name="oxt" depends="jar">
<echo message="Creating OpenOffice.org plugin (oxt)" />
<zip destfile="${output.dir}/${jsignpdf.filename}-${jsignpdf.version}.oxt">
<fileset dir="${bin.plugin.dir}"/>
<fileset dir="${dist.dir}" includes="${jsignpdf.filename}.jar"/>
</zip>
</target>
<target name="launcher" depends="jar">
<echo message="Creating windows launcher (EXE)" />
<untar compression="gzip" src="lib-build/${launch4j.zip}" dest="${build.dir}"/>
<chmod file="${build.dir}/${launch4j.dir}/bin/windres" perm="+x"/>
<chmod file="${build.dir}/${launch4j.dir}/bin/ld" perm="+x"/>
<taskdef name="launch4j"
classname="net.sf.launch4j.ant.Launch4jTask"
classpath="${build.dir}/${launch4j.dir}/launch4j.jar
:${build.dir}/${launch4j.dir}/lib/xstream.jar" />
<launch4j>
<config headerType="gui" outfile="${dist.dir}/JSignPdf.exe"
dontWrapJar="true" jarPath="${jsignpdf.filename}.jar"
icon="doc/icon/icons.ico">
<jre path="jre"/>
<splash file="${jsignpdf.splashimage.path}"/>
<versionInfo fileVersion="${jsignpdf.version}.0"
txtFileVersion="JSignPdf launcher v. ${jsignpdf.version}"
fileDescription="Adds digital signatures to PDF files"
copyright="Josef Cacek"
productVersion="${jsignpdf.version}.0"
txtProductVersion="Adds digital signatures to PDF files"
productName="JSignPdf"
internalName="JSignPdf"
originalFilename="JSignPdf.exe" />
</config>
</launch4j>
<copy file="unsorted/template.l4j.ini" tofile="${dist.dir}/JSignPdf.l4j.ini"/>
<launch4j>
<config headerType="console" outfile="${dist.dir}/JSignPdfC.exe"
dontWrapJar="true" jarPath="${jsignpdf.filename}.jar"
icon="doc/icon/icons.ico">
<jre path="jre"/>
<versionInfo fileVersion="${jsignpdf.version}.0"
txtFileVersion="JSignPdf console launcher v. ${jsignpdf.version}"
fileDescription="Console launcher for JSignPdf"
copyright="Josef Cacek"
productVersion="${jsignpdf.version}.0"
txtProductVersion="Adds digital signatures to PDF files"
productName="JSignPdf"
internalName="JSignPdf"
originalFilename="JSignPdfC.exe" />
</config>
</launch4j>
<copy file="unsorted/template.l4j.ini" tofile="${dist.dir}/JSignPdfC.l4j.ini"/>
<launch4j>
<config headerType="console" outfile="${dist.dir}/Verifier.exe"
dontWrapJar="true" jarPath="${verifier.filename}.jar"
icon="doc/icon/icons.ico">
<jre path="jre"/>
<versionInfo fileVersion="${jsignpdf.version}.0"
txtFileVersion="JSignPdf signature verifier v. ${jsignpdf.version}"
fileDescription="Launcher for JSignPdf verifier"
copyright="Josef Cacek"
productVersion="${jsignpdf.version}.0"
txtProductVersion="Verifies digital signatures in PDF files"
productName="JSignPdf verifier"
internalName="JSignPdf verifier"
originalFilename="Verifier.exe" />
</config>
</launch4j>
<copy file="unsorted/template.l4j.ini" tofile="${dist.dir}/Verifier.l4j.ini"/>
<launch4j>
<config headerType="console" outfile="${dist.dir}/InstallCert.exe"
dontWrapJar="true" jarPath="${installcert.filename}.jar"
icon="doc/icon/Certificate.ico">
<jre path="jre"/>
<versionInfo fileVersion="${jsignpdf.version}.0"
txtFileVersion="InstallCert launcher v. ${jsignpdf.version}"
fileDescription="Installs host SSL certificates to Java keystore"
copyright="Josef Cacek"
productVersion="${jsignpdf.version}.0"
txtProductVersion="Installs host SSL certificates to Java keystore"
productName="InstallCert"
internalName="InstallCert"
originalFilename="InstallCert.exe" />
</config>
</launch4j>
<copy file="unsorted/template.l4j.ini" tofile="${dist.dir}/InstallCert.l4j.ini"/>
<echo message="Adding batch files to application folder"/>
<copy todir="${dist.dir}">
<fileset dir="unsorted/batch">
<include name="*.*"/>
</fileset>
</copy>
</target>
<target name="uncompresspdf" depends="launcher">
<!-- uncompresser -->
<jar destfile="${build.dir}/UncompressPdf.jar">
<fileset dir="${bin.dir}" includes="**/UncompressPdf*"/>
<zipfileset src="${dist.dir}/lib/jsignpdf-itxt-${jsignpdf.version}.jar"/>
<manifest>
<attribute name="Main-Class" value="net.sf.jsignpdf.UncompressPdf"/>
<attribute name="Implementation-Vendor" value="Josef Cacek"/>
<attribute name="Implementation-Title" value="JSignPdf - UncompressPdf"/>
<attribute name="Implementation-Version" value="${jsignpdf.version} ${build.timestamp}"/>
</manifest>
</jar>
<launch4j>
<config headerType="console" outfile="${build.dir}/UncompressPdf.exe"
jarPath="${build.dir}/UncompressPdf.jar"
icon="doc/icon/misc.ico">
<jre path="jre"/>
<versionInfo fileVersion="${jsignpdf.version}.0"
txtFileVersion="UncompressPdf v. ${jsignpdf.version}"
fileDescription="Uncompresses PDF"
copyright="Josef Cacek"
productVersion="${jsignpdf.version}.0"
txtProductVersion="Uncompresses PDF"
productName="UncompressPdf"
internalName="UncompressPdf"
originalFilename="UncompressPdf.exe" />
</config>
</launch4j>
</target>
<target name="doc" depends="jar">
<echo message="Converting documentation (odt->pdf)" />
<exec executable="${ooo.exec}" failonerror="true">
<arg line="--headless"/>
<arg line="--convert-to pdf:writer_pdf_Export --outdir"/>
<arg value="${dist.doc.dir}"/>
<arg value="doc/JSignPdf.odt"/>
</exec>
<echo message="Signing the documentation with a sample certificate" />
<java jar="${dist.dir}/${jsignpdf.filename}.jar" fork="true" failonerror="true" jvmargs="-Duser.language=en">
<arg value="-kst"/>
<arg value="JKS"/>
<arg value="-ksf"/>
<arg value="unsorted/demokeystore.jks"/>
<arg value="-ksp"/>
<arg value="jsignpdfdemo"/>
<arg value="-ka"/>
<arg value="JSignPdfDemo"/>
<arg value="-d"/>
<arg value="${dist.doc.dir}"/>
<arg value="${dist.doc.dir}/JSignPdf.pdf"/>
</java>
<!-- guide also as a download -->
<copy file="${dist.doc.dir}/JSignPdf.pdf" tofile="${output.dir}/JSignPdf guide ${jsignpdf.version}.pdf"/>
</target>
<target name="installer" depends="jar,unpack-jre,launcher,doc">
<echo message="Creating a windows setup" />
<exec failonerror="false"
executable="unsorted/iscc">
<arg line="${dist.dir}"/>
<arg line="${output.dir}"/>
<arg line="/dMyAppName=JSignPdf"/>
<arg line="/dMyAppVersion=${jsignpdf.version}"/>
<arg line="/dMyAppVersionWin=${jsignpdf.version}.0"/>
<arg line="/dMyAppId=JSignPdf"/>
<arg line="/dMyAppFilename=${jsignpdf.filename}"/>
</exec>
</target>
<target name="setMacPreconditions">
<condition property="macBulildPossible">
<and>
<os family="unix"/>
<available file="${dist.dir}/${jsignpdf.filename}.jar" type="file" property="isJarAvailable"/>
</and>
</condition>
</target>
<target name="checkMacBuildPreconditions" depends="setMacPreconditions" unless="macBulildPossible">
<fail message="Not possible to run Mac build check OS and if the app is already build."/>
</target>
<target name="macosx" depends="checkMacBuildPreconditions">
<delete dir="${macosx.dir}"/>
<mkdir dir="${macosx.dir}"/>
<jarbundler dir="${macosx.dir}"
name="${jsignpdf.product.name}"
icon="doc\icon\iconverticons.com\signedpdf.icns"
version="${jsignpdf.version}"
jvmversion="1.6+"
vmoptions="-Xms32m -Xmx512m"
mainclass="net.sf.jsignpdf.Signer">
<jarfileset dir="${dist.dir}">
<include name="${jsignpdf.filename}.jar" />
<include name="lib/*.jar" />
</jarfileset>
<resourcefileset dir="${dist.dir}">
<include name="docs/**/*"/>
<include name="conf/**/*"/>
<exclude name="**/*.jar"/>
</resourcefileset>
</jarbundler>
<!-- Delete the JavaApplicationStub and replace it with a symbolic link -->
<!-- which should work on older and future versions of OS X -->
<delete file="${output.dir}/${jsignpdf.product.name}.app/Contents/MacOS/JavaApplicationStub"/>
<symlink link="${macosx.dir}/${jsignpdf.product.name}.app/Contents/MacOS/JavaApplicationStub" resource="/System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub"/>
<!-- add symlink to /Applications -->
<symlink link="${macosx.dir}/Applications" resource="/Applications"/>
<!-- Create dmg -->
<exec executable="genisoimage" failonerror="true">
<arg value="-D"/>
<arg value="-V"/>
<arg value="${jsignpdf.product.name}"/>
<arg value="-no-pad"/>
<arg value="-r"/>
<arg value="-apple"/>
<arg value="-o"/>
<arg value="${output.dir}/${jsignpdf.filename}-${jsignpdf.version}.dmg"/>
<arg value="${macosx.dir}"/>
</exec>
</target>
<target name="zip" depends="jar,doc">
<echo message="Creating a zip release" />
<zip destfile="${output.dir}/JSignPdf-${jsignpdf.version}.zip">
<fileset dir="${build.dir}" includes="${app.dir}/**"/>
</zip>
</target>
<target name="all" depends="zip,oxt,installer,src,macosx"/>
<target name="src" depends="prepare">
<echo message="Creating package from 'live' sources" />
<zip destfile="${output.dir}/JSignPdf-${jsignpdf.version}.src.zip">
<fileset dir="." includes="src/**"/>
<fileset dir="." includes="res/**"/>
<fileset dir="." includes="doc/**"/>
<fileset dir="." includes="conf/**"/>
<fileset dir="." includes="images/**"/>
<fileset dir="." includes="licenses/**"/>
<fileset dir="." includes="plugin/**"/>
</zip>
</target>
</project>