简体   繁体   English

定制蚂蚁构建和JavaFX

[英]custom ant build and JavaFX

with your regular netbeans javaFX project the developer is capable of doing the following -make a javaFX jar file -make a html with javaFX on browser on it -make a jnlp webstart 使用常规的netbeans javaFX项目,开发人员可以执行以下操作-制作一个javaFX jar文件-在浏览器上制作一个带有javaFX的html-制作一个jnlp webstart

i want to achieve the same output with ant build (inside netbeans IDE), but so far my success is limited to the javaFX jar file only, i'd want to make the html file and jnlp with ant as well 我想用ant build(在netbeans IDE内部)实现相同的输出,但是到目前为止,我的成功仅限于javaFX jar文件,我也想用ant制作html文件和jnlp

i am using netbeans 8.0.2, i have a standard java library (non-javaFX) project, this project contains a single backend and two frontends SWING and javaFX, with ant build script i am successful in producing two separate and self contained jar files which is dssSWING.jar and dssJavaFX.jar, each capable of self extracting the database inside of them and having the third party dependencies embedded on each of the as well, here is the ant code i use to produce both 我正在使用netbeans 8.0.2,我有一个标准的Java库(非javaFX)项目,该项目包含一个后端和两个前端SWING和javaFX,并带有ant build脚本,我成功地产生了两个独立的自包含jar文件分别是dssSWING.jar和dssJavaFX.jar,它们每个都能够自我提取其中的数据库,并且每个库中都嵌入了第三方依赖项,这是我用来生成两者的ant代码


<!--this build target is meant for building the AJAX SWING (web version) and the Desktop version-->    
<target name="_desktop_SWING_RedistributableSingleJarFile">
    <jar destfile="${basedir}/dss.jar">                    
        <zipgroupfileset dir="protected/lib" includes="h2-1.4.182.jar"/>               
        <zipgroupfileset dir="protected/lib" includes="commons-csv-1.0.jar"/>      
        <fileset dir="${basedir}/build/classes">
            <exclude name=".netbeans_automatic_build"/> 
            <exclude name=".netbeans_update_resources"/> 
            <exclude name="mobileView/**"/>
        </fileset>
        <fileset dir="protected/data" includes="dss.mv.db" />
        <fileset dir="img" >
            <exclude name="Thumbs.db"/>                  
        </fileset> 
        <manifest>
            <attribute name="Main-Class" value="desktopView.WelcomePage"/>
        </manifest>        
    </jar>
</target>

<!--this build target is meant for building the JavaFX version--> 
<target name="_desktop_javaFX_RedistributableSingleJarFile">
    <jar destfile="${basedir}/dss_javaFX.jar">        
        <zipgroupfileset dir="protected/lib" includes="h2-1.4.182.jar"/>             
        <zipgroupfileset dir="protected/lib" includes="commons-csv-1.0.jar"/>                        
        <zipgroupfileset dir="protected/lib" includes="jfxtras-labs-8.0-r4-20141129.090224-39.jar"/>          
        <fileset dir="${basedir}/build/classes">
            <exclude name=".netbeans_automatic_build"/> 
            <exclude name=".netbeans_update_resources"/> 
            <exclude name="desktopView/**"/>
        </fileset>        
        <fileset dir="protected/data" includes="dss.mv.db" />
        <fileset dir="img" >
            <exclude name="Thumbs.db"/>                  
        </fileset> 
        <manifest>
            <attribute name="Main-Class" value="mobileView.Main"/>
        </manifest>        
    </jar>
</target>

please don't tell to make it into javaFX project instead (easy way out), i would like to learn the exact ant script to generate the HTML file embedding on the javaFX jar file as well as the jnlp file 请不要告诉改成javaFX项目(简便方法),我想学习确切的ant脚本来生成嵌入在javaFX jar文件和jnlp文件中的HTML文件

This website should tell you everything you need to know as far as what's happening under the hood in the ant deployment task, and as such, it also includes links to all the ant tasks and settings you'll need in order to create things like jnlp, etc, etc. 该网站应该告诉您有关ant部署任务的幕后工作的一切信息,因此,它还包含指向所有您需要的ant任务和设置的链接,以便创建jnlp之类的东西。等等

TL;DR, you interact with the ant-javafx.jar, you 'overload' (or whatever you call it in ant world) the fx:deploy task, set some properties, and then magic happens. TL; DR,您与ant-javafx.jar进行交互,您“超载”(或在ant world中称为它的任何东西)fx:deploy任务,设置一些属性,然后发生魔术。

If you want to see the nitty gritty of how netbeans handles a .jnlp creation, I uploaded the (most) relevant (3000 line).xml file to pastebin at http://pastebin.com/hRBpMuUG 如果您想了解netbeans如何处理.jnlp创建的细节,我将相关的(最重要的)(3000行).xml文件上传到了http://pastebin.com/hRBpMuUG的 pastebin上。

Hope that helps.. good luck! 希望有帮助..祝你好运!

TL;DR; TL; DR; indeed, i have success producing jnlp and html file, the exact code that does it is, this code outputs java_DSS.jnlp, java_DSS.html and finally to make it work the original javaFX jar file must be on the same directory 的确,我已经成功生成了jnlp和html文件,确切的代码是,此代码输出java_DSS.jnlp,java_DSS.html,最后使其工作,原始javaFX jar文件必须位于同一目录中


<fx:deploy width="100%" height="100%"
        outdir="web-dist" outfile="java_DSS" 
        offlineAllowed="true">
    <fx:info title="java DSS"/>
    <fx:application refid="java DSS"/>
    <fx:resources>
        <fx:fileset dir="${basedir}">
           <include name="dss_javaFX.jar"/>
        </fx:fileset>
    </fx:resources>
</fx:deploy>  

end of line my efforts became waste, javaFX webstart or HTML embed needs to be signed in order to be able to run with write/read access to a database, there i available ant code to do the signing but i have no valid 'keyStore' file in order to get it signed, the signing process also does not accept jar files built with <target> , it must be built with <fx:jar> in order to work, unfortunately <fx:jar> does not support embedding of external lib files, you'd have to unzip the libs before you can add them, TLDR 最后,我的工作变得浪费,需要对javaFX webstart或HTML embed进行签名,以便能够对数据库进行写/读访问,在那里我可以使用ant代码进行签名,但是我没有有效的'keyStore'为了对其进行签名,签名过程也不接受使用<target>构建的jar文件,必须使用<fx:jar>进行构建才能正常工作,不幸的是<fx:jar>不支持外部嵌入lib文件,您必须先解压缩这些库,然后才能添加它们,TLDR

if you want custom ant built javaFX jar,jnlp,html file don't even bother you'd be wasting a lot of time. 如果您想要自定义的ant构建的javaFX jar,jnlp,html文件,甚至都不会打扰您,那会浪费很多时间。 i wasted 6 hours trying to do that ending with an unsigned output which cannot run on webstart or html embed mode 我浪费了6个小时尝试这样做,以无法在webstart或html嵌入模式下运行的未签名输出结尾

SOLUTION

what i did was build the ant javaFX jar file, created a new javaFX project and added the javaFX jar file there making the main class of that project a 'launcher' my javaFX jar file, within 5 minutes i have a signed jar,jnlp, and html without having to convert my 'main' project into javaFX project, in a nutshell just make a javaFX 'launcher' project instead of making you own, netbeans will handle all the signing and complicated stuff 我所做的是构建了一个ant javaFX jar文件,创建了一个新的javaFX jar项目,并在那里添加了javaFX jar文件,使该项目的主类成为了我的javaFX jar文件的“启动器”,在5分钟内,我有一个签名的jar,jnlp,和html,而不必将我的“主”项目转换为javaFX项目,简而言之,只需创建一个javaFX“启动器”项目而不是自己创建,netbeans将处理所有签名和复杂的工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM