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
|
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 2 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://www.netbeans.org/cddl-gplv2.html
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License file at
nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
particular file as subject to the "Classpath" exception as provided
by Sun in the GPL Version 2 section of the License file that
accompanied this code. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
Contributor(s):
The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 2, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 2] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 2 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 2 code and therefore, elected the GPL
Version 2 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
-->
<project name="jnlp-impl" default="default" basedir="..">
<property name="jnlp.file.name.default" value="launch.jnlp"/>
<property name="jnlp.dest.dir" location="dist"/>
<!-- helper file to create list of arguments, etc. -->
<property name="helper.file" location="helper.txt"/>
<target name="default">
<echo message="Default target is not set, you must specify which target you want to run."/>
</target>
<!-- Main target -->
<target name="jnlp" depends="-init-filename,-test-jnlp-enabled" if="is.jnlp.enabled">
<delete file="dist/lib/javaws.jar" failonerror="false"/>
<antcall target="generate-jnlp"/>
<antcall target="generate-html-preview"/>
</target>
<!-- Init jnlp filename -->
<target name="-init-filename" depends="-check-filename-prop,-set-jnlp-filename-custom,-set-jnlp-filename-default"/>
<target name="-set-jnlp-filename-custom" if="jnlp.file.name.set">
<property name="jnlp.file" value="${jnlp.file.name}"/>
</target>
<target name="-set-jnlp-filename-default" unless="jnlp.file.name.set">
<property name="jnlp.file" value="${jnlp.file.name.default}"/>
</target>
<target name="-check-filename-prop">
<condition property="jnlp.file.name.set">
<and>
<isset property="jnlp.file.name"/>
<not>
<equals arg1="jnlp.file.name" arg2="" trim="true"/>
</not>
</and>
</condition>
</target>
<!-- Test JNLP enabled-->
<target name="-test-jnlp-enabled">
<condition property="is.jnlp.enabled">
<istrue value="${jnlp.enabled}"/>
</condition>
</target>
<!-- Generating JNLP file -->
<target name="generate-jnlp" depends="sign-jars,-test-generate-task-available,-unavailable-generate-task" if="generate.task.available">
<taskdef name="generate-jnlp" classname="org.netbeans.modules.javawebstart.anttasks.GenerateJnlpFileTask"
classpath="${libs.JWSAntTasks.classpath}"/>
<generate-jnlp destfile="${jnlp.dest.dir}/${jnlp.file}_" template="master-${jnlp.descriptor}.jnlp" destdir="dist"/>
<antcall target="-strip-empty-lines"/>
</target>
<target name="-strip-empty-lines">
<copy file="${jnlp.dest.dir}/${jnlp.file}_" tofile="${jnlp.dest.dir}/${jnlp.file}" overwrite="true" encoding="UTF-8">
<filterchain>
<linecontainsregexp>
<regexp pattern=".+"/>
</linecontainsregexp>
</filterchain>
</copy>
<delete file="${jnlp.dest.dir}/${jnlp.file}_" failonerror="false"/>
</target>
<target name="-test-generate-task-available">
<available property="generate.task.available" classname="org.netbeans.modules.javawebstart.anttasks.GenerateJnlpFileTask"
classpath="${libs.JWSAntTasks.classpath}"/>
</target>
<target name="-unavailable-generate-task" unless="generate.task.available">
<echo message="Task required to generate JNLP file is missing, probably the library 'JWS Ant Tasks' is missing either from shared folder or from IDE installation."/>
<fail/>
</target>
<!-- Codebase processing -->
<target name="-codebase-props-check">
<condition property="local.codebase">
<or>
<not>
<isset property="jnlp.codebase.type"/>
</not>
<equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
</or>
</condition>
<condition property="non.user.codebase">
<or>
<not>
<isset property="jnlp.codebase.type"/>
</not>
<equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
<equals arg1="${jnlp.codebase.type}" arg2="web" trim="true"/>
</or>
</condition>
<condition property="user.codebase">
<equals arg1="${jnlp.codebase.type}" arg2="user" trim="true"/>
</condition>
</target>
<target name="-init-non-user-codebase" if="non.user.codebase">
<property name="jnlp.codebase.value" value="${jnlp.codebase.url}"/>
</target>
<target name="-init-user-codebase" if="user.codebase">
<property name="jnlp.codebase.value" value="${jnlp.codebase.user}"/>
</target>
<!-- Security -->
<target name="-security-props-check">
<condition property="jnlp.signed.true">
<istrue value="${jnlp.signed}"/>
</condition>
</target>
<target name="-jnlp-init-keystore" depends="-jnlp-init-keystore-props,-check-keystore-exists" unless="jnlp.signjar.keystore.exists">
<echo message="${application.vendor}" file="${helper.file}"/>
<loadfile property="application.vendor.filtered" srcfile="${helper.file}">
<filterchain>
<deletecharacters chars=","/>
</filterchain>
</loadfile>
<delete file="${helper.file}"/>
<property name="jnlp.signjar.vendor" value="CN=${application.vendor.filtered}"/>
<echo message="Going to create default keystore in ${jnlp.signjar.keystore}"/>
<genkey dname="${jnlp.signjar.vendor}" alias="${jnlp.signjar.alias}" keystore="${jnlp.signjar.keystore}"
storepass="${jnlp.signjar.storepass}" keypass="${jnlp.signjar.keypass}"/>
</target>
<target name="-check-keystore-exists">
<available property="jnlp.signjar.keystore.exists" file="${jnlp.signjar.keystore}"/>
</target>
<target name="-jnlp-init-keystore-props">
<property name="jnlp.signjar.keystore" value="${basedir}/build/nb-jws.ks"/>
<property name="jnlp.signjar.storepass" value="storepass"/>
<property name="jnlp.signjar.keypass" value="keypass"/>
<property name="jnlp.signjar.alias" value="nb-jws"/>
</target>
<!-- Signing -->
<target name="-test-signjars-task-available">
<available property="signjars.task.available"
classname="org.netbeans.modules.javawebstart.anttasks.SignJarsTask"
classpath="${libs.JWSAntTasks.classpath}"/>
</target>
<target name="-check-signing-possible" depends="-security-props-check,-test-signjars-task-available,-unavailable-signjars-task">
<condition property="jnlp.signed.true+signjars.task.available">
<and>
<isset property="jnlp.signed.true"/>
<isset property="signjars.task.available"/>
</and>
</condition>
</target>
<target name="-unavailable-signjars-task" depends="-test-signjars-task-available" unless="signjars.task.available">
<echo message="Task required to sign JAR file is missing, probably the library 'JWS Ant Tasks' is missing either from shared folder or from IDE installation. JAR files will not be signed."/>
</target>
<target name="sign-jars" depends="-jnlp-init-keystore,-check-signing-possible" if="jnlp.signed.true+signjars.task.available">
<taskdef name="sign-jars" classname="org.netbeans.modules.javawebstart.anttasks.SignJarsTask"
classpath="${libs.JWSAntTasks.classpath}"/>
<sign-jars keystore="${jnlp.signjar.keystore}" storepass="${jnlp.signjar.storepass}"
keypass="${jnlp.signjar.keypass}" alias="${jnlp.signjar.alias}" mainjar="${dist.jar}" destdir="dist"
codebase="${jnlp.codebase.value}" signedjarsprop="jnlp.signed.jars"
componentsprop="jnlp.components">
<fileset dir="dist/lib">
<include name="*.jar"/>
</fileset>
</sign-jars>
</target>
<!-- Running/Debugging -->
<target name="jws-run" depends="jar,-verify-jnlp-enabled,-verify-codebase" description="Start javaws execution">
<exec executable="${java.home}/bin/javaws">
<arg file="${jnlp.dest.dir}/${jnlp.file}"/>
</exec>
</target>
<target name="jws-debug" if="netbeans.home" depends="jar,-verify-jnlp-enabled,-verify-codebase,-debug-start-debugger,-debug-javaws-debuggee"
description="Debug javaws project in IDE"/>
<target name="-init-debug-args">
<property name="version-output" value="java version "${ant.java.version}"/>
<condition property="have-jdk-older-than-1.4">
<or>
<contains string="${version-output}" substring="java version "1.0"/>
<contains string="${version-output}" substring="java version "1.1"/>
<contains string="${version-output}" substring="java version "1.2"/>
<contains string="${version-output}" substring="java version "1.3"/>
</or>
</condition>
<condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
<istrue value="${have-jdk-older-than-1.4}"/>
</condition>
<condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
<os family="windows"/>
</condition>
<condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
<isset property="debug.transport"/>
</condition>
</target>
<target name="-debug-javaws-debuggee" depends="-init-debug-args">
<exec executable="${java.home}/bin/javaws">
<env key="JAVAWS_VM_ARGS" value="${debug-args-line} -Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
<arg file="${jnlp.dest.dir}/${jnlp.file}"/>
</exec>
</target>
<target name="-verify-codebase" depends="-codebase-props-check" unless="local.codebase">
<fail message="Project cannot be run with non-local codebase. Open project properties dialog and set Web Start Codebase to Local Execution."/>
</target>
<target name="-verify-jnlp-enabled" depends="-test-jnlp-enabled" unless="is.jnlp.enabled">
<fail message="Project cannot be run with selected Run Configuration when Java Web Start is disabled."/>
</target>
<!-- Generate simple HTML preview page -->
<target name="-check-html-preview">
<condition property="generate.html.preview">
<or>
<equals arg1="${jnlp.descriptor}" arg2="application"/>
<equals arg1="${jnlp.descriptor}" arg2="applet"/>
</or>
</condition>
</target>
<target name="generate-html-preview" depends="-check-html-preview" if="generate.html.preview">
<copy file="preview-${jnlp.descriptor}.html" tofile="${jnlp.dest.dir}/launch.html" overwrite="true" encoding="UTF-8">
<filterchain>
<replacestring from="${JNLP.FILE}" to="${jnlp.file}"/>
<replacestring from="${JNLP.APPLET.WIDTH}" to="${jnlp.applet.width}"/>
<replacestring from="${JNLP.APPLET.HEIGHT}" to="${jnlp.applet.height}"/>
</filterchain>
</copy>
</target>
</project>
|