forked from qzind/qz-print
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
444 lines (371 loc) · 17.6 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="qz" default="distribute" basedir=".">
<target name="distribute" depends="init,clean,sign-jar,include-assets">
<zip destfile="${zip.file}" basedir="${dist.applet.dir}"/>
<echo message="Process complete" />
</target>
<target name="init">
<property environment="env"/>
<property file="ant/project.properties"/>
<!-- Your custom code signing properties here. Feel free to change. -->
<!-- The project will default to qz.ks if it doesn't exist -->
<property file="${user.home}/Desktop/Code Signing/private.properties"/>
<!-- The default code signing properties which uses qz.ks. -->
<!-- Please leave this value the netbeans default as a fallback. -->
<property file="ant/private/private.properties"/>
<echo message="Building ${build.applet.name} / ${build.socket.name} using JDK ${ant.java.version}" />
</target>
<target name="clean" depends="init">
<delete dir="${out.dir}"/>
</target>
<target name="compile-applet" depends="init">
<mkdir dir="${build.applet.dir}"/>
<javac destdir="${build.applet.dir}" source="${javac.applet.source}" target="${javac.applet.target}" includeantruntime="false">
<src path="${src.dir}"/>
<classpath>
<path id="plugin.override">
<pathelement path="${lib.dir}/jre/plugin.jar" />
</path>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${java.home}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<compilerarg value="-Xlint:-options"/>
</javac>
<!-- Include non-class files from src in build directory -->
<copy todir="${build.applet.dir}">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="compile-socket" depends="init">
<mkdir dir="${build.socket.dir}"/>
<javac destdir="${build.socket.dir}" source="${javac.applet.source}" target="${javac.socket.target}" includeantruntime="false">
<src path="${src.dir}"/>
<classpath>
<path id="plugin.override">
<pathelement path="${lib.dir}/jre/plugin.jar" />
</path>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${java.home}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<compilerarg value="-Xlint:-options"/>
</javac>
<!-- Include non-class files from src in build directory -->
<copy todir="${build.socket.dir}">
<fileset dir="${src.dir}" excludes="**/*.java"/>
</copy>
</target>
<target name="build-jar" depends="build-applet-jar,build-socket-jar" />
<target name="build-applet-jar" depends="compile-applet">
<echo>Building Jar for Applet use</echo>
<copy todir="${dist.applet.dir}/${lib.dir}">
<fileset dir="${lib.dir}" includes="**/*.jar" excludes="ws/*.*,**/plugin.jar"/>
</copy>
<manifestclasspath property="manifest.main.applet.classpath" jarfile="${dist.applet.jar}">
<classpath>
<fileset dir="${dist.applet.dir}/${lib.dir}" includes="*.jar"/>
</classpath>
</manifestclasspath>
<jar compress="${jar.compress}" index="${jar.index}" destfile="${dist.applet.jar}" duplicate="preserve">
<fileset dir="${build.applet.dir}" excludes="org/joor/*.*,qz/ws/*.*"/>
<indexjars>
<fileset dir="${dist.applet.dir}/${lib.dir}" includes="*.jar"/>
</indexjars>
<manifest>
<attribute name="Application-Name" value="${manifest.application.name}"/>
<attribute name="Main-Class" value="${manifest.main.applet.class}"/>
<attribute name="Permissions" value="${manifest.permissions}"/>
<attribute name="Codebase" value="${manifest.codebase}"/>
<attribute name="Caller-Allowable-Codebase" value="${manifest.caller.allowable.codebase}"/>
<attribute name="Application-Library-Allowable-Codebase" value="${manifest.application.allowable.codebase}"/>
<attribute name="Class-Path" value="${manifest.main.applet.classpath}"/>
</manifest>
</jar>
</target>
<target name="build-socket-jar" depends="compile-socket">
<echo>Building Jar for Socket use</echo>
<jar compress="${jar.compress}" index="${jar.index}" destfile="${dist.socket.jar}" duplicate="preserve">
<fileset dir="${build.socket.dir}"/>
<zipgroupfileset dir="${lib.dir}" includes="**/*.jar" excludes="**/plugin.jar"/>
<manifest>
<attribute name="Application-Name" value="${manifest.application.name}"/>
<attribute name="Main-Class" value="${manifest.main.socket.class}"/>
<attribute name="Permissions" value="${manifest.permissions}"/>
<attribute name="Codebase" value="${manifest.codebase}"/>
<attribute name="Caller-Allowable-Codebase" value="${manifest.caller.allowable.codebase}"/>
<attribute name="Application-Library-Allowable-Codebase" value="${manifest.application.allowable.codebase}"/>
</manifest>
</jar>
</target>
<target name="sign-jar" depends="build-jar,sign-jar-self,sign-jar-tsa">
<path>
<fileset dir="${dist.dir}/${lib.dir}" includes="${lib.dir}/**/*.jar" />
</path>
</target>
<!-- tsaurl attribute cannot be empty, so separate methods are needed to sign both jars -->
<target name="sign-jar-self" unless="signing.tsaurl">
<echo>Self-signing Applet jar</echo>
<signjar jar="${dist.applet.jar}"
signedjar="${dist.applet.jar}"
alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}"
/>
<signjar alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}">
<path>
<fileset dir="${dist.applet.dir}/${lib.dir}" includes="**/*.jar" />
</path>
</signjar>
<echo>Self-signing Socket jar</echo>
<signjar jar="${dist.socket.jar}"
signedjar="${dist.socket.jar}"
alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}"
/>
</target>
<target name="sign-jar-tsa" if="signing.tsaurl">
<echo>Signing Applet jar with timestamp</echo>
<signjar jar="${dist.applet.jar}"
signedjar="${dist.applet.jar}"
alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}"
tsaurl="${signing.tsaurl}"
/>
<signjar alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}"
tsaurl="${signing.tsaurl}">
<path>
<fileset dir="${dist.applet.dir}/${lib.dir}" includes="**/*.jar" />
</path>
</signjar>
<echo>Signing Socket jar with timestamp</echo>
<signjar jar="${dist.socket.jar}"
signedjar="${dist.socket.jar}"
alias="${signing.alias}"
storepass="${signing.storepass}"
keystore="${signing.keystore}"
keypass="${signing.keypass}"
tsaurl="${signing.tsaurl}"
/>
</target>
<!-- Get version information from JAR -->
<target name="get-version" depends="build-jar">
<property file="ant/project.properties"/>
<java jar="${dist.applet.jar}" fork="true" outputproperty="build.version">
<arg value="--version"/>
</java>
<!-- Fallback to a bogus version number if the above command failed -->
<property name="build.version" value="0.0.0" />
<echo>Version ${build.version}</echo>
<!-- Calculate installation size -->
<length property="build.socket.bytes" mode="all">
<fileset dir="${dist.socket.dir}" includes="**/*"/>
</length>
<script language="javascript">
<![CDATA[
project.setNewProperty("build.socket.size", Math.round(project.getProperty("build.socket.bytes") / 1024));
]]>
</script>
<echo>Size: ${build.socket.size} KB</echo>
</target>
<target name="include-assets" depends="init,get-version" >
<echo>Copying resource files to output</echo>
<copy todir="${dist.applet.dir}/${demo.dir}/${asset.dir}">
<fileset dir="${asset.dir}">
<exclude name="**/*.properties"/>
<exclude name="**/branding/"/>
</fileset>
</copy>
<copy todir="${dist.socket.dir}/${demo.dir}/${asset.dir}">
<fileset dir="${asset.dir}">
<exclude name="**/*.properties"/>
<exclude name="**/branding/"/>
</fileset>
</copy>
<copy todir="${dist.applet.dir}/${demo.dir}/${js.dir}">
<fileset dir="${js.dir}"/>
</copy>
<copy todir="${dist.socket.dir}/${demo.dir}/${js.dir}">
<fileset dir="${js.dir}"/>
</copy>
<copy todir="${dist.applet.dir}/${demo.dir}">
<fileset file="sample.html"/>
</copy>
<copy todir="${dist.socket.dir}/${demo.dir}">
<fileset file="sample.html"/>
</copy>
<copy file="${jnlp.inf.dir}/APPLICATION.JNLP" tofile="${dist.applet.jnlp}" />
<!-- Distribute applet with README, CHANGELOG, LICENSE -->
<copy todir="${dist.applet.dir}">
<fileset file="${basedir}/*.txt"/>
</copy>
<!-- Distribute socket with LICENSE only -->
<copy todir="${dist.socket.dir}">
<fileset file="${basedir}/LICENSE.txt"/>
</copy>
</target>
<!--
################################################################
# Prepackage Steps - All Platforms #
################################################################
-->
<target name="prepackage">
<echo>Processing self-signing variables</echo>
<property file="ant/self-sign.properties"/>
<echo>Creating Firefox certificate config files</echo>
<copy file="${firefoxconfig.in}" tofile="${firefoxconfig.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${firefoxprefs.in}" tofile="${firefoxprefs.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${basedir}/CHANGELOG.txt" tofile="${build.socket.dir}/CHANGELOG.txt" />
</target>
<!--
################################################################
# Windows Installer #
################################################################
-->
<target name="nsis" depends="distribute,prepackage,nsisbin-1,nsisbin-2,nsisbin-3">
<echo>Creating installer using ${nsisbin}</echo>
<property file="ant/windows/windows.properties"/>
<copy file="${branding.dir}/${windows.icon}" tofile="${dist.socket.dir}/${windows.icon}" />
<delete file="${windows.packager.out}"/>
<copy file="${windows.packager.in}" tofile="${windows.packager.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${windows.keygen.in}" tofile="${windows.keygen.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<exec executable="${nsisbin}" failonerror="true" >
<arg value="${windows.packager.out}"/>
</exec>
<!-- Cleanup lingering icon (for other OS installers) -->
<delete file="${dist.socket.dir}/${windows.icon}" />
</target>
<!-- Linux makensis -->
<target name="nsisbin-1" depends="init" unless="env.windir">
<property name="nsisbin" value="makensis"/>
</target>
<!-- Win32 makensis -->
<target name="nsisbin-2" depends="init" unless="env.ProgramFiles(x86)">
<property name="nsisexe" value="${env.ProgramFiles}/NSIS/makensis.exe"/>
</target>
<!-- Win64 makensis -->
<target name="nsisbin-3" depends="init" if="env.ProgramFiles(x86)">
<property name="nsisbin" value="${env.ProgramFiles(x86)}/NSIS/makensis.exe"/>
</target>
<!--
################################################################
# Apple Installer #
################################################################
-->
<target name="pkgbuild" depends="distribute,prepackage">
<echo>Creating installer using pkgbuild</echo>
<property file="ant/apple/apple.properties"/>
<!--
###################################
# Build MacOS Bundle Structure #
###################################
-->
<!-- Contents/Resources/apple-icon.icns -->
<mkdir dir="${dist.socket.dir}/${apple.resources}"/>
<copy file="${branding.dir}/${apple.icon}" tofile="${dist.socket.dir}/${apple.resources}/${apple.icon}" />
<!-- Contents/MacOS/QZ\ Tray -->
<mkdir dir="${dist.socket.dir}/${apple.macos}"/>
<copy file="${apple.launcher.in}" tofile="${apple.launcher.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="+x" file="${apple.launcher.out}"/>
<!-- Info.plist -->
<copy file="${apple.plist.in}" tofile="${apple.plist.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${apple.packager.in}" tofile="${apple.packager.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${apple.packager.out}"/>
<mkdir dir="${apple.scripts}"/>
<copy file="${apple.keygen.in}" tofile="${apple.keygen.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${apple.keygen.out}"/>
<copy file="${apple.preinstall.in}" tofile="${apple.preinstall.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${apple.preinstall.out}"/>
<copy file="${apple.postinstall.in}" tofile="${apple.postinstall.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${apple.postinstall.out}"/>
<copy file="${apple.uninstall.in}" tofile="${apple.uninstall.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${apple.uninstall.out}"/>
<copy file="${firefoxcert.in}" tofile="${firefoxcert.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${firefoxcert.out}"/>
<copy file="${locator.in}" tofile="${locator.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${locator.out}"/>
<exec executable="${apple.packager.out}" failonerror="true" />
<!-- Cleanup lingering resources for other installer targets -->
<delete dir="${dist.socket.dir}/${apple.resources}" />
<delete dir="${dist.socket.dir}/${apple.macos}" />
<delete file="${dist.socket.dir}/${apple.plist.out}" />
</target>
<!--
################################################################
# Linux Installer #
################################################################
-->
<target name="makeself" depends="distribute,prepackage">
<echo>Creating installer using makeself</echo>
<property file="ant/linux/linux.properties"/>
<copy file="${branding.dir}/${linux.icon}" tofile="${dist.socket.dir}/${linux.icon}" />
<copy file="${linux.installer.in}" tofile="${linux.installer.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${linux.keygen.in}" tofile="${linux.keygen.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<copy file="${linux.packager.in}" tofile="${linux.packager.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" type="file">
<fileset dir="${build.dir}">
<include name="**/*.sh"/>
</fileset>
</chmod>
<copy file="${firefoxcert.in}" tofile="${firefoxcert.out}">
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${firefoxcert.out}"/>
<copy file="${locator.in}" tofile="${locator.out}" >
<filterchain><expandproperties/></filterchain>
</copy>
<chmod perm="u+x" file="${locator.out}"/>
<exec executable="${linux.packager.out}" failonerror="true" />
<!-- Cleanup lingering icon (for other OS installers) -->
<delete file="${dist.socket.dir}/${linux.icon}" />
</target>
</project>