JavaFX 8 - How to Create EXE with Maven & INNO

I have not been able to successfully find a working solution on how to configure Maven to generate EXE from JavaFX using Maven.

Projects built with E (fx) clip using build.fxbuild work great, however I would prefer to have a maven project and dependent modules are more ANT base builds.

I've seen some comments on ZENJAVA - but it looks like the plug-in has lost all traction and is almost dead.

Is there anything that can bundle EXE from Maven? My project is an enterprise project that will have multiple projects and many dependencies, so I was hoping for a simple and efficient way to manage it all.

thank

+3


source to share


2 answers


the plugin is NOT dead, only the official site was taken down due to the costs it incurred.

Just take a look at the git repository for more information: https://github.com/javafx-maven-plugin/javafx-maven-plugin

We have some sample configurations in our test folder: https://github.com/javafx-maven-plugin/javafx-maven-plugin/tree/master/src/it

To simply create an EXE installer, you can specify a specific compositor (starting from version 8.1.3 and higher).



To use a plugin, just put it in your build plugins:

        <plugin>
            <groupId>com.zenjava</groupId>
            <artifactId>javafx-maven-plugin</artifactId>
            <version>8.1.3-SNAPSHOT</version>
            <configuration>
                <mainClass>com.your.amazing.mavenized.javafxapplication</mainClass>
                <bundler>EXE</bundler>
            </configuration>
        </plugin>

      

disclaimer: I am one of the maintainers of this plugin;)

+6


source


I was able to do this using javafx-ant tasks.

http://maven.apache.org/maven-v4_0_0.xsd "> 4.0.0 com.myapp.application MYAPP YAS 1,0-SNAPSHOT MyApp    http://www.somecompany.com



<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <javafx.version>8.0</javafx.version>
</properties>


<repositories>
    <repository>
        <id>repo</id>
        <url>file://${project.basedir}/lib/repo</url>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
            </configuration>
        </plugin>

        <plugin>
            <!-- copy all dependencies of your app to target folder -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <configuration>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <Main-Class>com.myApp.MainClass</Main-Class>
                        <implementation-version>1.0</implementation-version>
                        <JavaFX-Application-Class>com.myApp.MainClass</JavaFX-Application-Class>
                    </manifestEntries>
                    <manifest>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

        <!-- copy the properties files to the root location -->
        <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>copy-resources-1</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${basedir}/target/properties</outputDirectory>
                        <resources>
                            <resource>
                                <directory>properties</directory>
                                <filtering>true</filtering>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>


        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <configuration>
                        <target>
                            <!-- define the deploy ANT task -->
                            <taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.DeployFXTask"
                                classpathref="maven.plugin.classpath" />

                            <!-- define the JarSing ANT task -->
                            <!-- taskdef name="jfxsignjar" classname="com.sun.javafx.tools.ant.FXSignJarTask" 
                                classpathref="maven.plugin.classpath" / -->
                            <jfxdeploy outdir="${project.build.directory}/deploy"
                                outfile="${build.finalName}" nativeBundles="all">
                                <info title="${project.name}" />
                                <!-- set the main class of your applcation -->
                                <application name="${project.name}"
                                    mainClass="com.myApp.MainClass" />
                                <resources>
                                    <fileset dir="${project.build.directory}" includes="*.jar" />
                                    <fileset dir="${project.build.directory}/dependency"
                                        includes="*.jar" />
                                    <fileset dir="${project.build.directory}/properties" includes="*.properties"/>
                                </resources>

                                <!-- set your jvm args -->
                                <platform>
                                    <jvmarg value="-Xms512m" />
                                    <jvmarg value="-Xmx1024m" />
                                </platform>
                            </jfxdeploy>
                            <!-- you need to generate a key yourself -->
                            <!--jfxsignjar destdir="${project.build.directory}/deploy" keyStore="path/to/your/keystore" 
                                storePass="yourPass" alias="yourAlias" keyPass="keyPass"> <fileset dir="${project.build.directory}/deploy" 
                                includes="*.jar" /> </jfxsignjar -->
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>

            <dependencies>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ant-javafx</artifactId>
                    <version>${javafx.version}</version>
                    <systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
                    <scope>system</scope>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
    <finalName>CashReceipts</finalName>
</build>

<dependencies>
    <dependency>
        <groupId>org.controlsfx</groupId>
        <artifactId>controlsfx</artifactId>
        <version>8.40.9</version>
    </dependency>

    <dependency>
        <groupId>customJar</groupId>
        <artifactId>custom</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>

      

+1


source







All Articles