java/SuperPostak/nbproject/jnlp-impl.xml
author František Kučera <franta-hg@frantovo.cz>
Sun, 23 Nov 2008 22:19:20 +0100
changeset 0 e76872ad5226
permissions -rw-r--r--
Přidání SuperPošťáka do Mercurialu (původně byl v Subversionu)
Postak – základ, knihovna
SuperPostak – GUI nadstavba
SuperPostak2 – pokus o implementaci aplikace jako modulu pro Netbeans, POZOR: není přidán do Mercurialu, možná později (pravděpodobně se ale nebude používat)
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!--
     3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4 
     5 Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
     6 
     7 
     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]"
    25 
    26 Contributor(s):
    27 
    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.
    31 
    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 -->
    43 
    44 <project name="jnlp-impl" default="default" basedir="..">
    45 
    46     <property name="master.jnlp.file" location="master.jnlp"/>
    47     <property name="launch.jnlp.file" value="launch.jnlp"/>
    48     <property name="jnlp.dest.dir" location="dist"/>
    49     
    50     <!-- helper file to create list of arguments, etc. -->
    51     <property name="helper.file" location="helper.txt"/>
    52     
    53     <target name="default">
    54         <echo message="Default target is not set."/>
    55     </target>
    56     
    57     <!-- Main target -->
    58     
    59     <target name="jnlp" depends="-init-check,-test-jnlp-enabled" if="is.jnlp.enabled">
    60         <delete file="dist/lib/javaws.jar" failonerror="false"/>
    61         <antcall target="generate-jnlp"/>
    62     </target>
    63     
    64     <!-- Generate master -->
    65     
    66     <target name="-check-for-master.jnlp">
    67         <available file="${master.jnlp.file}" property="master.jnlp.exists"/>
    68     </target>
    69     <target name="jnlp-init-generate-master" depends="-check-for-master.jnlp" unless="master.jnlp.exists">
    70         <echo file="${master.jnlp.file}" encoding="UTF-8"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
    71 <jnlp spec="1.0+" codebase="$${jnlp.codebase}" href="launch.jnlp">
    72     <information>
    73         <title>$${APPLICATION.TITLE}</title>
    74         <vendor>$${APPLICATION.VENDOR}</vendor>
    75         <description>$${APPLICATION.DESC}</description>
    76         <description kind="short">$${APPLICATION.DESC.SHORT}</description>
    77         <homepage href="$${APPLICATION.HOMEPAGE}"/>
    78 <!--$${JNLP.ICONS}-->
    79 <!--$${JNLP.OFFLINE.ALLOWED}-->
    80     </information>
    81 <!--$${JNLP.SECURITY}-->
    82     <resources>
    83 <!--$${JNLP.RESOURCES.RUNTIME}-->
    84 <!--$${JNLP.RESOURCES.MAIN.JAR}-->
    85 <!--$${JNLP.RESOURCES.JARS}-->
    86     </resources>
    87     <application-desc main-class="$${jnlp.main.class}">
    88 <!--$${JNLP.APPLICATION.ARGS}-->
    89     </application-desc>
    90 </jnlp>
    91 ]]></echo>
    92     </target>
    93     
    94     <!-- Initial check -->
    95     
    96     <target name="-init-check">
    97         <fail unless="application.title" message="Must set application title."/>
    98         <fail unless="application.vendor" message="Must set application vendor."/>
    99     </target>
   100     
   101     <!-- Icons -->
   102     
   103     <target name="-init-icons" depends="-preinit-icons,-set-icon-elem,-set-splash-elem">
   104         <property name="jnlp.icon.elem" value=""/>
   105         <property name="application.splash.elem" value=""/>
   106         <property name="icon.separator" value=""/>
   107         <property name="jnlp.icons.value" value="${jnlp.icon.elem}${icon.separator}${application.splash.elem}"/>
   108     </target>
   109     <target name="-preinit-icons" depends="-copy-app-icon,-copy-app-splash"/>
   110     <target name="-copy-app-icon" if="jnlp.icon" depends="-get-app-icon-name">
   111         <copy file="${jnlp.icon}" todir="${jnlp.dest.dir}" failonerror="false"/>
   112         <available file="${jnlp.dest.dir}${file.separator}${jnlp.icon.name}" property="jnlp.icon.copied"/>
   113     </target>
   114     <target name="-copy-app-splash" if="application.splash" depends="-get-app-splash-name">
   115         <copy file="${application.splash}" todir="${jnlp.dest.dir}" failonerror="false"/>
   116         <available file="${jnlp.dest.dir}${file.separator}${application.splash.name}" property="application.splash.copied"/>
   117     </target>
   118     <target name="-get-app-icon-name" if="jnlp.icon">
   119         <dirname file="${jnlp.icon}" property="jnlp.icon.basedir"/>
   120         <pathconvert property="jnlp.icon.name" setonempty="false">
   121             <path location="${jnlp.icon}"/>
   122             <map from="${jnlp.icon.basedir}${file.separator}" to=""/>
   123         </pathconvert>
   124     </target>
   125     <target name="-get-app-splash-name" if="application.splash">
   126         <dirname file="${application.splash}" property="application.splash.basedir"/>
   127         <pathconvert property="application.splash.name" setonempty="false">
   128             <path location="${application.splash}"/>
   129             <map from="${application.splash.basedir}${file.separator}" to=""/>
   130         </pathconvert>
   131     </target>
   132     <target name="-set-icon-elem" if="jnlp.icon.copied">
   133         <property name="jnlp.icon.elem" value='        &lt;icon href="${jnlp.icon.name}" kind="default"/&gt;'/>
   134     </target>
   135     <target name="-set-splash-elem" if="application.splash.copied" depends="-set-icon-elem">
   136         <property name="application.splash.elem" value='        &lt;icon href="${application.splash.name}" kind="splash"/&gt;'/>
   137         <condition property="icon.separator" value="${line.separator}">
   138             <isset property="jnlp.icon.elem"/>
   139         </condition>
   140     </target>
   141     
   142     <!-- Offline-Allowed -->
   143     
   144     <target name="-init-offline" if="offline.allowed.set" depends="-preinit-offline">
   145         <property name="jnlp.offline.allowed.value" value="        &lt;offline-allowed/&gt;"/>
   146     </target>
   147     <target name="-preinit-offline">
   148         <condition property="offline.allowed.set">
   149             <equals arg1="${jnlp.offline-allowed}" arg2="true" trim="true"/>
   150         </condition>
   151     </target>
   152     
   153     <!-- Descriptions -->
   154     
   155     <target name="-init-descriptions" depends="-descriptions-props-check,-init-desc-value,-init-desc-value-short">
   156         <property name="application.desc.value" value="${application.title}"/>
   157         <property name="application.desc.short.value" value="${application.title}"/>
   158     </target>
   159     <target name="-descriptions-props-check">
   160         <condition property="application.desc.set">
   161             <and>
   162                 <isset property="application.desc"/>
   163                 <not>
   164                     <equals arg1="${application.desc}" arg2="" trim="true"/>
   165                 </not>
   166             </and>
   167         </condition>
   168         <condition property="application.desc.short.set">
   169             <and>
   170                 <isset property="application.desc.short"/>
   171                 <not>
   172                     <equals arg1="${application.desc.short}" arg2="" trim="true"/>
   173                 </not>
   174             </and>
   175         </condition>
   176     </target>
   177     <target name="-init-desc-value" if="application.desc.set">
   178         <property name="application.desc.value" value="${application.desc}"/>
   179     </target>
   180     <target name="-init-desc-value-short" if="application.desc.short.set">
   181         <property name="application.desc.short.value" value="${application.desc.short}"/>
   182     </target>
   183     
   184     <!-- Security -->
   185     
   186     <target name="-init-security" depends="-check-signing-possible" if="jnlp.signed.true+signjarstask.available">
   187         <property name="jnlp.security" value="    &lt;security&gt;${line.separator}        &lt;all-permissions/&gt;${line.separator}    &lt;/security&gt;"/>
   188     </target>
   189     <target name="-security-props-check">
   190         <condition property="jnlp.signed.true">
   191             <istrue value="${jnlp.signed}"/>
   192         </condition>
   193     </target>
   194     <target name="-jnlp-init-keystore" depends="-jnlp-init-keystore-props,-check-keystore-exists" unless="jnlp.signjar.keystore.exists">
   195         <echo message="${application.vendor}" file="${helper.file}"/>
   196         <loadfile property="application.vendor.filtered" srcfile="${helper.file}">
   197             <filterchain>
   198                 <deletecharacters chars=","/>
   199             </filterchain>
   200         </loadfile>
   201         <delete file="${helper.file}"/>
   202         <property name="jnlp.signjar.vendor" value="CN=${application.vendor.filtered}"/>
   203         <echo message="Going to create default keystore in ${jnlp.signjar.keystore}"/>
   204         <genkey dname="${jnlp.signjar.vendor}" alias="${jnlp.signjar.alias}" keystore="${jnlp.signjar.keystore}"
   205             storepass="${jnlp.signjar.storepass}" keypass="${jnlp.signjar.keypass}"/>
   206     </target>
   207     <target name="-check-keystore-exists">
   208         <available property="jnlp.signjar.keystore.exists" file="${jnlp.signjar.keystore}"/>
   209     </target>
   210     <target name="-jnlp-init-keystore-props">
   211         <property name="jnlp.signjar.keystore" value="${basedir}/build/nb-jws.ks"/>
   212         <property name="jnlp.signjar.storepass" value="storepass"/>
   213         <property name="jnlp.signjar.keypass" value="keypass"/>
   214         <property name="jnlp.signjar.alias" value="nb-jws"/>
   215     </target>    
   216     
   217     <!-- Generating JNLP file -->
   218     
   219     <target name="generate-jnlp" depends="jnlp-init-generate-master,-init-codebase,-init-resources-runtime,-init-security,-init-resources-jars,-init-application-args,-init-icons,-init-offline,-init-descriptions,jnlp-init-notinited">
   220         <copy file="${master.jnlp.file}" tofile="${jnlp.dest.dir}/${launch.jnlp.file}__" overwrite="true" encoding="UTF-8">
   221             <filterchain>
   222                 <replacestring from="$${jnlp.codebase}" to="${jnlp.codebase.value}"/>
   223                 <replacestring from="&lt;!--$${JNLP.ICONS}--&gt;" to="${jnlp.icons.value}"/>
   224                 <replacestring from="&lt;!--$${JNLP.SECURITY}--&gt;" to="${jnlp.security}"/>
   225                 <replacestring from="&lt;!--$${JNLP.OFFLINE.ALLOWED}--&gt;" to="${jnlp.offline.allowed.value}"/>
   226                 <replacestring from="&lt;!--$${JNLP.RESOURCES.RUNTIME}--&gt;" to="${jnlp.resources.runtime.value}"/>
   227                 <replacestring from="&lt;!--$${JNLP.RESOURCES.MAIN.JAR}--&gt;" to="${jnlp.resources.main.jar.value}"/>
   228                 <replacestring from="&lt;!--$${JNLP.RESOURCES.JARS}--&gt;" to="${jnlp.resources.jars.value}"/>
   229                 <replacestring from="&lt;!--$${JNLP.APPLICATION.ARGS}--&gt;" to="${jnlp.application.args.value}"/>
   230                 <replacestring from="$${APPLICATION.TITLE}" to="${application.title}"/>
   231                 <replacestring from="$${APPLICATION.VENDOR}" to="${application.vendor}"/>
   232                 <replacestring from="$${APPLICATION.DESC}" to="${application.desc.value}"/>
   233                 <replacestring from="$${APPLICATION.DESC.SHORT}" to="${application.desc.short.value}"/>
   234                 <replacestring from="$${APPLICATION.HOMEPAGE}" to="${application.homepage}"/>
   235                 <replacestring from="$${jnlp.main.class}" to="${main.class}"/>
   236             </filterchain>
   237         </copy>
   238         <antcall target="-strip-empty-lines"/>
   239         <antcall target="-generate-html-page"/>
   240     </target>
   241     <target name="jnlp-init-notinited">
   242         <property name="jnlp.security" value=""/>
   243         <property name="jnlp.offline.allowed.value" value=""/>
   244         <property name="application.homepage" value=""/>
   245         <property name="jnlp.application.args.value" value=""/>
   246     </target>
   247     <target name="-strip-empty-lines">
   248         <move file="${jnlp.dest.dir}/${launch.jnlp.file}__" tofile="${jnlp.dest.dir}/${launch.jnlp.file}" overwrite="true" encoding="UTF-8">
   249             <filterchain>
   250                 <linecontainsregexp>
   251                     <regexp pattern=".+"/>
   252                 </linecontainsregexp>
   253             </filterchain>
   254         </move>
   255     </target>
   256     
   257     <!-- Codebase processing -->
   258     
   259     <target name="-init-codebase" depends="-codebase-props-check,-init-non-user-codebase,-init-user-codebase"/>
   260     <target name="-codebase-props-check">
   261         <condition property="local.codebase">
   262             <or>
   263                 <not>
   264                     <isset property="jnlp.codebase.type"/>
   265                 </not>
   266                 <equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
   267             </or>
   268         </condition>
   269         <condition property="non.user.codebase">
   270             <or>
   271                 <not>
   272                     <isset property="jnlp.codebase.type"/>
   273                 </not>
   274                 <equals arg1="${jnlp.codebase.type}" arg2="local" trim="true"/>
   275                 <equals arg1="${jnlp.codebase.type}" arg2="web" trim="true"/>
   276             </or>
   277         </condition>
   278         <condition property="user.codebase">
   279             <equals arg1="${jnlp.codebase.type}" arg2="user" trim="true"/>
   280         </condition>
   281     </target>
   282     <target name="-init-non-user-codebase" if="non.user.codebase">
   283         <property name="jnlp.codebase.value" value="${jnlp.codebase.url}"/>
   284     </target>
   285     <target name="-init-user-codebase" if="user.codebase">
   286         <property name="jnlp.codebase.value" value="${jnlp.codebase.user}"/>
   287     </target>
   288     
   289     <!-- j2se resources -->
   290     
   291     <target name="-init-resources-runtime" depends="-init-runtime-props">
   292         <property name="run.jvmargs.value" value=""/>
   293         <property name="initial-heap-size.value" value=""/>
   294         <property name="max-heap-size.value" value=""/>
   295         <property name="jnlp.resources.runtime.value" 
   296             value='        &lt;j2se version="${javac.target}+"${initial-heap-size.value}${max-heap-size.value}${run.jvmargs.value}/&gt;'/>
   297     </target>
   298     <target name="-init-runtime-props" depends="-runtime-props-check,-init-run-jvmargs-value,-init-initial-heap-size-value,-init-max-heap-size-value"/>
   299     <target name="-runtime-props-check">
   300         <condition property="run.jvmargs.set">
   301             <and>
   302                 <isset property="run.jvmargs"/>
   303                 <not>
   304                     <equals arg1="${run.jvmargs}" arg2="" trim="true"/>
   305                 </not>
   306             </and>
   307         </condition>
   308         <condition property="jnlp.initial-heap-size.set">
   309             <and>
   310                 <isset property="jnlp.initial-heap-size"/>
   311                 <not>
   312                     <equals arg1="${jnlp.initial-heap-size}" arg2="" trim="true"/>
   313                 </not>
   314             </and>
   315         </condition>
   316         <condition property="jnlp.max-heap-size.set">
   317             <and>
   318                 <isset property="jnlp.max-heap-size"/>
   319                 <not>
   320                     <equals arg1="${jnlp.max-heap-size}" arg2="" trim="true"/>
   321                 </not>
   322             </and>
   323         </condition>
   324     </target>
   325     <target name="-init-run-jvmargs-value" if="run.jvmargs.set">
   326         <property name="run.jvmargs.value" value=' java-vm-args="${run.jvmargs}"'/>
   327     </target>
   328     <target name="-init-initial-heap-size-value" if="jnlp.initial-heap-size.set">
   329         <property name="initial-heap-size.value" value=' initial-heap-size="${jnlp.initial-heap-size}"'/>
   330     </target>
   331     <target name="-init-max-heap-size-value" if="jnlp.max-heap-size.set">
   332         <property name="max-heap-size.value" value=' max-heap-size="${jnlp.max-heap-size}"'/>
   333     </target>
   334     
   335     <!-- JAR resources -->
   336     
   337     <target name="-init-resources-jars" depends="-preinit-resources-unsigned-jars,-preinit-resources-signed-jars,-preinit-resources-main-jar"/>
   338     <target name="-preinit-resources-unsigned-jars" depends="-exclude-javaws-from-cp,-check-signing-possible" unless="jnlp.signed.true+signjarstask.available">
   339         <pathconvert pathsep="${line.separator}" property="jnlp.resources.jars.value">
   340             <path path="${run.classpath.without.javaws.jar}"/>
   341             <mapper type="regexp" from="^.*[/\\]([^/\\]+\.jar)"
   342                 to='        &lt;jar href="lib/\1" download="eager"/&gt;'/>
   343         </pathconvert>
   344     </target>
   345     <target name="-preinit-resources-main-jar">
   346         <pathconvert pathsep="${line.separator}" property="jnlp.resources.main.jar.value">
   347             <path location="${dist.jar}"/>
   348             <mapper type="regexp" from="^.*[/\\]([^/\\]+\.jar)"
   349                 to='        &lt;jar href="\1" main="true" download="eager"/&gt;'/>
   350         </pathconvert>
   351     </target>
   352     <target name="-exclude-javaws-from-cp">
   353         <pathconvert property="path.element.to.be.removed">
   354             <path path="${run.classpath}"/>
   355             <mapper type="regexp" from="(^.*[/\\]javaws.jar)" to="\1"/>
   356         </pathconvert>
   357         <pathconvert property="run.classpath.without.javaws.jar">
   358             <path path="${run.classpath}"/>
   359             <map from="${path.element.to.be.removed}" to=""/>
   360         </pathconvert>
   361     </target>
   362     <target name="-check-task-available">
   363         <condition property="signjarstask.available">
   364             <isset property="netbeans.home"/>
   365         </condition>
   366     </target>
   367     <target name="-check-signing-possible" depends="-security-props-check,-check-task-available">
   368         <condition property="jnlp.signed.true+signjarstask.available">
   369             <and>
   370                 <isset property="jnlp.signed.true"/>
   371                 <isset property="signjarstask.available"/>
   372             </and>
   373         </condition>
   374     </target>
   375     <target name="-unavailable-task-warning" depends="-check-task-available" unless="signjarstask.available">
   376         <echo message="Signtask is not available, jar files will not be signed. Task is available only when running inside NetBeans IDE."/>
   377     </target>
   378     <target name="-preinit-resources-signed-jars" depends="-unavailable-task-warning,-sign-jars" if="jnlp.signed.true+signjarstask.available">
   379         <property name="jnlp.resources.jars.value" value="${jnlp.signed.jars}${jnlp.components}"/>
   380     </target>
   381     <target name="-sign-jars" depends="-jnlp-init-keystore,-check-signing-possible" if="jnlp.signed.true+signjarstask.available">
   382         <jnlpsignjars keystore="${jnlp.signjar.keystore}" storepass="${jnlp.signjar.storepass}" 
   383                 keypass="${jnlp.signjar.keypass}" alias="${jnlp.signjar.alias}" mainjar="${dist.jar}" destdir="dist"
   384                 codebase="${jnlp.codebase.value}" signedjarsprop="jnlp.signed.jars"
   385                 componentsprop="jnlp.components">
   386             <fileset dir="dist/lib">
   387                 <include name="*.jar"/>
   388             </fileset>
   389         </jnlpsignjars>
   390     </target>
   391     
   392     <!-- Application arguments -->
   393     
   394     <target name="-init-application-args" if="application.args">
   395         <echo message="${application.args}" file="${helper.file}"/>
   396         <loadfile srcfile="${helper.file}" property="jnlp.application.args.value">
   397             <filterchain>
   398                 <tokenfilter delimoutput="\n">
   399                     <stringtokenizer/>
   400                     <replaceregex pattern="(.+)" replace="        &lt;argument&gt;\1&lt;/argument&gt;"/>
   401                 </tokenfilter>
   402             </filterchain>
   403         </loadfile>
   404         <delete file="${helper.file}"/>
   405     </target>
   406     
   407     <!-- Running/Debugging -->
   408     
   409     <target name="jws-run" depends="jar,-verify-jnlp-enabled,-verify-codebase" description="Start javaws execution">
   410         <exec executable="${java.home}/bin/javaws">
   411             <arg file="${jnlp.dest.dir}/${launch.jnlp.file}"/>
   412         </exec>
   413     </target>
   414     <target name="jws-debug" if="netbeans.home" depends="jar,-verify-jnlp-enabled,-verify-codebase,-debug-start-debugger,-debug-javaws-debuggee" 
   415         description="Debug javaws project in IDE"/>
   416     <target name="-debug-javaws-debuggee">
   417         <exec executable="${java.home}/bin/javaws">
   418             <env key="JAVAWS_VM_ARGS" value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
   419             <arg file="${jnlp.dest.dir}/${launch.jnlp.file}"/>
   420         </exec>
   421     </target>
   422     <target name="-verify-codebase" depends="-codebase-props-check" unless="local.codebase">
   423         <fail message="Project cannot be run with non-local codebase. Open project properties dialog and set Web Start Codebase to Local Execution."/>
   424     </target>
   425     <target name="-verify-jnlp-enabled" depends="-test-jnlp-enabled" unless="is.jnlp.enabled">
   426         <fail message="Project cannot be run with selected Run Configuration when Java Web Start is disabled."/>
   427     </target>
   428     
   429     <!-- Test JNLP enabled-->
   430     
   431     <target name="-test-jnlp-enabled">
   432         <condition property="is.jnlp.enabled">
   433             <equals arg1="${jnlp.enabled}" arg2="true" casesensitive="false" trim="true"/>
   434         </condition>
   435     </target>
   436     
   437     <!-- Generate simple HTML test page -->
   438     
   439     <target name="-generate-html-page">
   440         <echo file="${jnlp.dest.dir}/launch.html"><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
   441 <html>
   442     <head>
   443         <title>Test page for launching the application via JNLP</title>
   444     </head>
   445     <body>
   446         <h3>Test page for launching the application via JNLP</h3>
   447         <a href="launch.jnlp">Launch the application</a>
   448     </body>
   449 </html>
   450 ]]></echo>
   451     </target>
   452     
   453 </project>