Netbeans Java (JavaFX) Native Packaging with additional files and folders

痴心易碎 提交于 2019-12-31 01:46:29

问题


How to include additional files and folders (configuration files) when natively packaging Java applications?

When building the project, I have set the build file to create directories and copy additional files to the dist directory.

My normal builds (without native packaging) would result to this directory structure:

-> dist
   -> lib
   -> application.jar
   -> config folder //additional folder
   -> another additional folder //additional folder

Now, I would like to build my native installer (setup) having those addtional folders/files extracted together with my application and runtime.

Basically when my native installer is run, it will create these files:

-> app
   -> lib
   -> application.jar
   -> package.cfg
-> runtime
   -> jre
-> applcation.exe
-> application.ico
-> unins000.dat
-> unins000.exe

My additional files and folders are not included in my installer. I would like to have my installer with those additional files extracted, preferably like this

-> app
   -> lib
   -> config folder //additional folder
   -> another additional folder //additional folder
   -> application.jar
   -> package.cfg
-> runtime
   -> jre
-> applcation.exe
-> application.ico
-> unins000.dat
-> unins000.exe

By the way, I am using Ant Build tool and Inno for native packaging.


回答1:


I've only ever built native packages with Wix, so I'm basing my answer on the knowledge I have from that experience. Add a target to your Ant build script and create an fx:deploy task. Set the nativeBundles attribute to exe. You can specify additional files and folders by adding fx:filesets to the fx:application/fx:resources XPATH. It might looking something like this.

<target name="deploy">
  <fx:deploy verbose="true" nativeBundles="exe" ...>
    <fx:application name="${app.title}" mainClass="${main.class}" version="${version}">
      <fx:resources>
        <fx:fileset dir="${base.dir}" includes="config/*.*" />
        <fx:fileset dir="${base.dir}" includes="data/*.*" />
      </fx:resources>
    </fx:application>
  </fx:deploy>
</target>

There is a lot more you can specify in the fx:resources section. There's more detailed information in the Oracle tutorials, particularly Section 6.



来源:https://stackoverflow.com/questions/30073292/netbeans-java-javafx-native-packaging-with-additional-files-and-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!