1 <?xml version="1.0" encoding="UTF-8"?>
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5 Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
8 The contents of this file are subject to the terms of either the GNU
9 General Public License Version 2 only ("GPL") or the Common
10 Development and Distribution License("CDDL") (collectively, the
11 "License"). You may not use this file except in compliance with the
12 License. You can obtain a copy of the License at
13 http://www.netbeans.org/cddl-gplv2.html
14 or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
15 specific language governing permissions and limitations under the
16 License. When distributing the software, include this License Header
17 Notice in each file and include the License file at
18 nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
19 particular file as subject to the "Classpath" exception as provided
20 by Sun in the GPL Version 2 section of the License file that
21 accompanied this code. If applicable, add the following below the
22 License Header, with the fields enclosed by brackets [] replaced by
23 your own identifying information:
24 "Portions Copyrighted [year] [name of copyright owner]"
28 The Original Software is NetBeans. The Initial Developer of the Original
29 Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30 Microsystems, Inc. All Rights Reserved.
32 If you wish your version of this file to be governed by only the CDDL
33 or only the GPL Version 2, indicate your decision by adding
34 "[Contributor] elects to include this software in this distribution
35 under the [CDDL or GPL Version 2] license." If you do not indicate a
36 single choice of license, a recipient has the option to distribute
37 your version of this file under either the CDDL, the GPL Version 2 or
38 to extend the choice of license to its licensees as provided above.
39 However, if you add GPL Version 2 code and therefore, elected the GPL
40 Version 2 license, then the option applies only if the new code is
41 made subject to such option by the copyright holder.
44 <project name="jnlp-impl" default="default" basedir="..">
46 <property name="jnlp.file.name.default" value="launch.jnlp"/>
47 <property name="jnlp.dest.dir" location="dist"/>
49 <!-- helper file to create list of arguments, etc. -->
50 <property name="helper.file" location="helper.txt"/>
52 <target name="default">
53 <echo message="Default target is not set, you must specify which target you want to run."/>
56 <target name="-init-platform" unless="platform.home">
57 <property name="platform.home" value="${java.home}"/>
62 <target name="jnlp" depends="-init-filename,-test-jnlp-enabled" if="is.jnlp.enabled">
63 <makeurl property="jnlp.local.codebase.url" file="${basedir}/dist" validate="false"/>
64 <delete file="dist/lib/javaws.jar" failonerror="false"/>
65 <antcall target="generate-jnlp"/>
66 <antcall target="generate-html-preview"/>
69 <!-- Init jnlp filename -->
71 <target name="-init-filename" depends="-check-filename-prop,-set-jnlp-filename-custom,-set-jnlp-filename-default"/>
73 <target name="-set-jnlp-filename-custom" if="jnlp.file.name.set">
74 <property name="jnlp.file" value="${jnlp.file.name}"/>
77 <target name="-set-jnlp-filename-default" unless="jnlp.file.name.set">
78 <property name="jnlp.file" value="${jnlp.file.name.default}"/>
81 <target name="-check-filename-prop">
82 <condition property="jnlp.file.name.set">
84 <isset property="jnlp.file.name"/>
86 <equals arg1="jnlp.file.name" arg2="" trim="true"/>
92 <!-- Test JNLP enabled-->
94 <target name="-test-jnlp-enabled">
95 <condition property="is.jnlp.enabled">
96 <istrue value="${jnlp.enabled}"/>
100 <!-- Generating JNLP file -->
102 <target name="generate-jnlp" depends="sign-jars,-test-generate-task-available,-unavailable-generate-task" if="generate.task.available">
103 <taskdef name="generate-jnlp" classname="org.netbeans.modules.javawebstart.anttasks.GenerateJnlpFileTask"
104 classpath="${libs.JWSAntTasks.classpath}"/>
105 <generate-jnlp destfile="${jnlp.dest.dir}/${jnlp.file}_" template="master-${jnlp.descriptor}.jnlp" destdir="dist"/>
106 <antcall target="-strip-empty-lines"/>
109 <target name="-strip-empty-lines">
110 <copy file="${jnlp.dest.dir}/${jnlp.file}_" tofile="${jnlp.dest.dir}/${jnlp.file}" overwrite="true" encoding="UTF-8">
113 <regexp pattern=".+"/>
114 </linecontainsregexp>
117 <delete file="${jnlp.dest.dir}/${jnlp.file}_" failonerror="false"/>
120 <target name="-test-generate-task-available">
121 <available property="generate.task.available" classname="org.netbeans.modules.javawebstart.anttasks.GenerateJnlpFileTask"
122 classpath="${libs.JWSAntTasks.classpath}"/>
125 <target name="-unavailable-generate-task" unless="generate.task.available">
126 <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."/>
130 <!-- Codebase processing -->
132 <target name="-codebase-props-check">
133 <condition property="local.codebase">
136 <isset property="jnlp.codebase.type"/>
138 <equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
141 <condition property="non.user.codebase">
144 <isset property="jnlp.codebase.type"/>
146 <equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
147 <equals arg1="${jnlp.codebase.type}" arg2="web" trim="true"/>
150 <condition property="user.codebase">
151 <equals arg1="${jnlp.codebase.type}" arg2="user" trim="true"/>
155 <target name="-init-non-user-codebase" if="non.user.codebase">
156 <property name="jnlp.codebase.value" value="${jnlp.codebase.url}"/>
159 <target name="-init-user-codebase" if="user.codebase">
160 <property name="jnlp.codebase.value" value="${jnlp.codebase.user}"/>
165 <target name="-security-props-check">
166 <condition property="jnlp.signed.true">
167 <istrue value="${jnlp.signed}"/>
171 <target name="-jnlp-init-keystore" depends="-jnlp-init-keystore-props,-check-keystore-exists" unless="jnlp.signjar.keystore.exists">
172 <echo message="${application.vendor}" file="${helper.file}"/>
173 <loadfile property="application.vendor.filtered" srcfile="${helper.file}">
175 <deletecharacters chars=","/>
178 <delete file="${helper.file}"/>
179 <property name="jnlp.signjar.vendor" value="CN=${application.vendor.filtered}"/>
180 <echo message="Going to create default keystore in ${jnlp.signjar.keystore}"/>
181 <genkey dname="${jnlp.signjar.vendor}" alias="${jnlp.signjar.alias}" keystore="${jnlp.signjar.keystore}"
182 storepass="${jnlp.signjar.storepass}" keypass="${jnlp.signjar.keypass}"/>
185 <target name="-check-keystore-exists">
186 <available property="jnlp.signjar.keystore.exists" file="${jnlp.signjar.keystore}"/>
189 <target name="-jnlp-init-keystore-props">
190 <property name="jnlp.signjar.keystore" value="${basedir}/build/nb-jws.ks"/>
191 <property name="jnlp.signjar.storepass" value="storepass"/>
192 <property name="jnlp.signjar.keypass" value="keypass"/>
193 <property name="jnlp.signjar.alias" value="nb-jws"/>
198 <target name="-test-signjars-task-available">
199 <available property="signjars.task.available"
200 classname="org.netbeans.modules.javawebstart.anttasks.SignJarsTask"
201 classpath="${libs.JWSAntTasks.classpath}"/>
204 <target name="-check-signing-possible" depends="-security-props-check,-test-signjars-task-available,-unavailable-signjars-task">
205 <condition property="jnlp.signed.true+signjars.task.available">
207 <isset property="jnlp.signed.true"/>
208 <isset property="signjars.task.available"/>
213 <target name="-unavailable-signjars-task" depends="-test-signjars-task-available" unless="signjars.task.available">
214 <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."/>
217 <target name="sign-jars" depends="-jnlp-init-keystore,-check-signing-possible" if="jnlp.signed.true+signjars.task.available">
218 <taskdef name="sign-jars" classname="org.netbeans.modules.javawebstart.anttasks.SignJarsTask"
219 classpath="${libs.JWSAntTasks.classpath}"/>
220 <sign-jars keystore="${jnlp.signjar.keystore}" storepass="${jnlp.signjar.storepass}"
221 keypass="${jnlp.signjar.keypass}" alias="${jnlp.signjar.alias}" mainjar="${dist.jar}" destdir="dist"
222 codebase="${jnlp.codebase.value}" signedjarsprop="jnlp.signed.jars"
223 componentsprop="jnlp.components">
224 <fileset dir="dist/lib">
225 <include name="*.jar"/>
230 <!-- Running/Debugging -->
232 <target name="jws-run" depends="jar,-verify-jnlp-enabled,-verify-codebase,-init-platform" description="Start javaws execution">
233 <exec executable="${platform.home}/bin/javaws">
234 <arg file="${jnlp.dest.dir}/${jnlp.file}"/>
238 <target name="jws-debug" if="netbeans.home" depends="jar,-verify-jnlp-enabled,-verify-codebase,-debug-start-debugger,-debug-javaws-debuggee"
239 description="Debug javaws project in IDE"/>
241 <target name="-init-debug-args">
242 <property name="version-output" value="java version "${ant.java.version}"/>
243 <condition property="have-jdk-older-than-1.4">
245 <contains string="${version-output}" substring="java version "1.0"/>
246 <contains string="${version-output}" substring="java version "1.1"/>
247 <contains string="${version-output}" substring="java version "1.2"/>
248 <contains string="${version-output}" substring="java version "1.3"/>
251 <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
252 <istrue value="${have-jdk-older-than-1.4}"/>
254 <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
255 <os family="windows"/>
257 <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
258 <isset property="debug.transport"/>
262 <target name="-debug-javaws-debuggee" depends="-init-debug-args">
263 <exec executable="${java.home}/bin/javaws">
264 <env key="JAVAWS_VM_ARGS" value="${debug-args-line} -Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
265 <arg file="${jnlp.dest.dir}/${jnlp.file}"/>
269 <target name="-verify-codebase" depends="-codebase-props-check" unless="local.codebase">
270 <fail message="Project cannot be run with non-local codebase. Open project properties dialog and set Web Start Codebase to Local Execution."/>
273 <target name="-verify-jnlp-enabled" depends="-test-jnlp-enabled" unless="is.jnlp.enabled">
274 <fail message="Project cannot be run with selected Run Configuration when Java Web Start is disabled."/>
277 <!-- Generate simple HTML preview page -->
279 <target name="-check-html-preview">
280 <condition property="generate.html.preview">
282 <equals arg1="${jnlp.descriptor}" arg2="application"/>
283 <equals arg1="${jnlp.descriptor}" arg2="applet"/>
288 <target name="generate-html-preview" depends="-check-html-preview" if="generate.html.preview">
289 <copy file="preview-${jnlp.descriptor}.html" tofile="${jnlp.dest.dir}/launch.html" overwrite="true" encoding="UTF-8">
291 <replacestring from="${JNLP.FILE}" to="${jnlp.file}"/>
292 <replacestring from="${JNLP.APPLET.WIDTH}" to="${jnlp.applet.width}"/>
293 <replacestring from="${JNLP.APPLET.HEIGHT}" to="${jnlp.applet.height}"/>