How to set the install path on a self-contained app JavaFX .deb (Debian) package

浪子不回头ぞ 提交于 2021-01-28 09:36:10

问题


I'm trying to generate a .deb file, containing a self-contained copy of my JavaFX application, using the Oracle JavaFX Ant fx:deploy Task.

I've followed the samples on official documentation and my pom.xml configuration looks like this:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <phase>install</phase>
            <configuration>
                <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
                    <manifestclasspath property="manifest.classpath" jarfile="${application.dist}/${jar.name}.jar">
                        <classpath>
                            <path id="build.classpath">
                                <fileset dir="${application.dist}/lib">
                                    <include name="*.jar"/>
                                </fileset>
                            </path>
                        </classpath>
                    </manifestclasspath>


                    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
                             uri="javafx:com.sun.javafx.tools.ant"
                             classpath="${project.basedir}:${javafx.lib.ant-javafx.jar}"/>

                    <fx:preferences id="fxPreferences" shortcut="true" menu="true" install="true"/>

                    <fx:jar destfile="${application.dist}/${jar.name}.jar">
                        <fx:application name="${application.title}"
                                        mainClass="${application.main.class}"/>
                        <manifest>
                            <attribute name="Class-Path" value="${manifest.classpath}"/>
                        </manifest>
                        <!-- The target/classes folder which contains all resources and
                                    class files -->
                        <fileset dir="${project.build.outputDirectory}"/>
                    </fx:jar>

                    <fx:resources id="appRes">
                        <fx:fileset dir="${classes.dir}" includes="*.ico"/>
                        <fx:fileset dir="${classes.dir}" includes="*.bat"/>
                        <fx:fileset dir="${classes.dir}" includes="*.conf"/>
                        <fx:fileset dir="${application.dist}" includes="*.jar"/>
                        <fx:fileset dir="${application.dist}" includes="lib/*.jar"/>
                        <fx:fileset dir="${java.home}/lib/ext" includes="sunjce_provider.jar" type="data"/>
                        <fx:fileset dir="${java.home}/bin" includes="java.exe" type="data"/>
                        <fx:fileset dir="${java.home}/bin" includes="javaw.exe" type="data"/>
                        <fx:fileset dir="${extra.dir}" includes="**"/>
                    </fx:resources>


                    <!-- This same fx:deploy task MUST be able to generate a Windows .EXE bundle as well -->
                    <fx:deploy verbose="true" embedJNLP="false" extension="false" includeDT="false"
                               offlineAllowed="true" outdir="${application.dist}"
                               outfile="${bundle.name}" nativeBundles="all" updatemode="background">
                        <fx:application name="${application.name}" mainClass="${application.main.class}"/>
                        <fx:resources refid="appRes"/>
                        <fx:preferences refId="fxPreferences" shortcut="true" menu="true"/>
                        <fx:info title="${application.title}" vendor="${application.vendor}"/>


                        <fx:platform javafx="8.0+">
                            <fx:jvmarg value="-Djava.security.debug=sunpkcs11"/>
                        </fx:platform>
                    </fx:deploy>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

At the end of the build (mvn clean install), the .deb file is properly generated at /target/dist/bundles folder.

But when I install it with dpkg -i, my application will be installed at /opt/${bundle.name}.

The DEB packaging options documentation says the default installation location will be /opt, but it don't tell me how can I change it.

My question is: how may I set another installation path to override the default /opt value?

For example, it would be great if I could install it on /opt/company/apps/${bundle.name}.

I've read about the usage of fx:bundleArgument inside fx:deploy, which has fixed options. But none of the linux.* options it's related about installation path.

Environment information:

  • Debian 8.10 Jessie
  • JDK 1.8.0_171 64bits
  • dpkg-deb 1.17.27 (amd64)
  • Apache Maven 3.0.5

来源:https://stackoverflow.com/questions/50590738/how-to-set-the-install-path-on-a-self-contained-app-javafx-deb-debian-package

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