Initial temp support. (Thanks, Jack)
[desert.git] / nbproject / jnlp-impl.xml
blobd6f3b290b9d4b3b1ba136a6a13211dd928f98070
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
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]"
26 Contributor(s):
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.
42 -->
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"/>
48     
49     <!-- helper file to create list of arguments, etc. -->
50     <property name="helper.file" location="helper.txt"/>
51     
52     <target name="default">
53         <echo message="Default target is not set, you must specify which target you want to run."/>
54     </target>
56     <target name="-init-platform" unless="platform.home">
57         <property name="platform.home" value="${java.home}"/>
58     </target>
59     
60     <!-- Main target -->
61     
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"/>
67     </target>
68     
69     <!-- Init jnlp filename -->
70     
71     <target name="-init-filename" depends="-check-filename-prop,-set-jnlp-filename-custom,-set-jnlp-filename-default"/>
72     
73     <target name="-set-jnlp-filename-custom" if="jnlp.file.name.set">
74         <property name="jnlp.file" value="${jnlp.file.name}"/>
75     </target>
76     
77     <target name="-set-jnlp-filename-default" unless="jnlp.file.name.set">
78         <property name="jnlp.file" value="${jnlp.file.name.default}"/>
79     </target>
80     
81     <target name="-check-filename-prop">
82         <condition property="jnlp.file.name.set">
83             <and>
84                 <isset property="jnlp.file.name"/>
85                 <not>
86                     <equals arg1="jnlp.file.name" arg2="" trim="true"/>
87                 </not>
88             </and>
89         </condition>
90     </target>
91     
92     <!-- Test JNLP enabled-->
93     
94     <target name="-test-jnlp-enabled">
95         <condition property="is.jnlp.enabled">
96             <istrue value="${jnlp.enabled}"/>
97         </condition>
98     </target>
99     
100     <!-- Generating JNLP file -->
101     
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"/>
107     </target>
108     
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">
111             <filterchain>
112                 <linecontainsregexp>
113                     <regexp pattern=".+"/>
114                 </linecontainsregexp>
115             </filterchain>
116         </copy>
117         <delete file="${jnlp.dest.dir}/${jnlp.file}_" failonerror="false"/>
118     </target>
119     
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}"/>
123     </target>
124     
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."/>
127         <fail/>
128     </target>
129     
130     <!-- Codebase processing -->
131     
132     <target name="-codebase-props-check">
133         <condition property="local.codebase">
134             <or>
135                 <not>
136                     <isset property="jnlp.codebase.type"/>
137                 </not>
138                 <equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
139             </or>
140         </condition>
141         <condition property="non.user.codebase">
142             <or>
143                 <not>
144                     <isset property="jnlp.codebase.type"/>
145                 </not>
146                 <equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
147                 <equals arg1="${jnlp.codebase.type}" arg2="web" trim="true"/>
148             </or>
149         </condition>
150         <condition property="user.codebase">
151             <equals arg1="${jnlp.codebase.type}" arg2="user" trim="true"/>
152         </condition>
153     </target>
154     
155     <target name="-init-non-user-codebase" if="non.user.codebase">
156         <property name="jnlp.codebase.value" value="${jnlp.codebase.url}"/>
157     </target>
158     
159     <target name="-init-user-codebase" if="user.codebase">
160         <property name="jnlp.codebase.value" value="${jnlp.codebase.user}"/>
161     </target>
163     <!-- Security -->
164     
165     <target name="-security-props-check">
166         <condition property="jnlp.signed.true">
167             <istrue value="${jnlp.signed}"/>
168         </condition>
169     </target>
170     
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}">
174             <filterchain>
175                 <deletecharacters chars=","/>
176             </filterchain>
177         </loadfile>
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}"/>
183     </target>
184     
185     <target name="-check-keystore-exists">
186         <available property="jnlp.signjar.keystore.exists" file="${jnlp.signjar.keystore}"/>
187     </target>
188     
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"/>
194     </target>
196     <!-- Signing -->
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}"/>
202     </target>
203     
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">
206             <and>
207                 <isset property="jnlp.signed.true"/>
208                 <isset property="signjars.task.available"/>
209             </and>
210         </condition>
211     </target>
212     
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."/>
215     </target>
216     
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"/>
226             </fileset>
227         </sign-jars>
228     </target>
229     
230     <!-- Running/Debugging -->
231     
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}"/>
235         </exec>
236     </target>
237     
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"/>
240         
241     <target name="-init-debug-args">
242         <property name="version-output" value="java version &quot;${ant.java.version}"/>
243         <condition property="have-jdk-older-than-1.4">
244             <or>
245                 <contains string="${version-output}" substring="java version &quot;1.0"/>
246                 <contains string="${version-output}" substring="java version &quot;1.1"/>
247                 <contains string="${version-output}" substring="java version &quot;1.2"/>
248                 <contains string="${version-output}" substring="java version &quot;1.3"/>
249             </or>
250         </condition>
251         <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
252             <istrue value="${have-jdk-older-than-1.4}"/>
253         </condition>
254         <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
255             <os family="windows"/>
256         </condition>
257         <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
258             <isset property="debug.transport"/>
259         </condition>
260     </target>
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}"/>
266         </exec>
267     </target>
268     
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."/>
271     </target>
272     
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."/>
275     </target>
276     
277     <!-- Generate simple HTML preview page -->
279     <target name="-check-html-preview">
280          <condition property="generate.html.preview">
281              <or>
282                  <equals arg1="${jnlp.descriptor}" arg2="application"/>
283                  <equals arg1="${jnlp.descriptor}" arg2="applet"/>
284              </or>
285          </condition>
286      </target>
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">
290             <filterchain>
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}"/>
294             </filterchain>
295         </copy>
296     </target>
297     
298 </project>