4

I have a problem with packaging JavaFX application.
My final purpose is to generate self-contained application (*.jar, *.exe, *.dmg). Classes and other resources are OK, but the jar itself doesn't appear in the "target" folder. Maybe someone could provide me a hint, what I am doing wrong. Or maybe someone could provide simple step-by-step tutorial, how to reach my purpose (unfortunately, I didn't manage to do it following Oracle guides).
Thanks in advance!
Here is my pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>EmployeeReview</artifactId>
<version>1.0</version>

<name>EmployeeReview</name>

<properties>
    <commons-poi.version>3.8</commons-poi.version>
    <joda-time.version>2.1</joda-time.version>
    <simple-odf.version>0.6.6</simple-odf.version>

    <maven-compiler-plugin.version>2.5.1</maven-compiler-plugin.version>
    <maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
    <maven-assembly-plugin>2.3</maven-assembly-plugin>

    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>

    <exec.mainClass>by.issoft.employeereview.form.MainForm</exec.mainClass>

    <javafx.tools.ant.jar>${java.home}/lib/ant-javafx.jar</javafx.tools.ant.jar>
    <javafx.runtime.lib.jar>${java.home}/jre/lib/jfxrt.jar</javafx.runtime.lib.jar>

    <javafx.min.version>2.2</javafx.min.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${commons-poi.version}</version>
    </dependency>

    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>${joda-time.version}</version>
    </dependency>

    <dependency>
        <groupId>org.odftoolkit</groupId>
        <artifactId>simple-odf</artifactId>
        <version>${simple-odf.version}</version>
    </dependency>

    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>javafx</artifactId>
        <version>${javafx.min.version}</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

<build>
    <directory>target</directory>
    <finalName>EmployeeReview</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <source>${maven.compiler.source}</source>
                <target>${maven.compiler.target}</target>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>${maven-antrun-plugin.version}</version>
            <executions>
                <execution>
                    <id>create-launcher-jar</id>
                    <phase>package</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <target xmlns:fx="javafx:com.sun.javafx.tools.ant">
                            <taskdef
                                    uri="javafx:com.sun.javafx.tools.ant"
                                    resource="com/sun/javafx/tools/ant/antlib.xml"
                                    classpath="${javafx.tools.ant.jar}"/>
                            <fx:application id="fxApp"
                                            name="${project.name}"
                                            mainClass="${exec.mainClass}"/>
                            <fx:jar destfile="${project.build.directory}/${project.build.finalName}-launcher">
                                <fx:application refid="fxApp"/>
                                <fx:fileset dir="${project.build.directory}/classes"/>
                            </fx:jar>
                            <attachartifact
                                    file="${project.build.directory}/${project.build.finalName}-launcher.jar"
                                    classifier="launcher" />
                        </target>
                    </configuration>
                </execution>
            </executions>
        </plugin>


    </plugins>
</build>

messivanio
  • 2,263
  • 18
  • 24
  • 7
    I have been able to produce a single runnable jar for my own software EstiMate using the javafx-maven-plugin hosted on GitHub here: https://github.com/zonski/javafx-maven-plugin, I should have it finished and uploaded tonight at https://bitbucket.org/atill/estimate/src/c1a556f9e612aeffaffe0335e616127f8068db2c/pom.xml?at=master – Andy Till Dec 27 '12 at 13:20
  • The pom.xml and some build instructions are uploaded now. – Andy Till Dec 27 '12 at 16:16
  • @AndyTill Thanks a lot! This plugin really helped me to reach my puprose. The only one question: how can I build native installer for OS, different of mine, with its help? (i.e. I use Windows and want to build *.dmg) – Vyacheslav Sermyazhko Jan 08 '13 at 11:47
  • 1
    @VyacheslavSermyazhko this is not possible with the javafx ant tasks at the moment. You'd have to have all target systems (Mac,Win,Linux) and run the build on each of them (on win and linux even with 2 different java-versions 32/64 bit!) – tomsontom Jan 08 '13 at 12:07
  • I don't see how building native installers for different architectures/operating systems would ever be possible from one machine. – Andy Till Jan 08 '13 at 12:30
  • But it does suggest you can build a native installer using the plugin although you need to install WIX, check the wiki here https://github.com/zonski/javafx-maven-plugin/wiki/Building-native-bundles – Andy Till Jan 08 '13 at 12:31
  • @AndyTill - there are lots of examples and e.g. eclipse does export a native launcher for all OSes from one system. Build installers is not that hard as one might think. RPM/Deb is an open format, DMG is also not that hard and even MSI is to the most extend simply an compressed archive. IIRC InstallJammer was able to produce e.g. an Windows Setup.exe e.g. on Linux. – tomsontom Jan 09 '13 at 08:08
  • Interesting, I wasn't aware of that. I guess they are all just file formats at the end of the day. – Andy Till Jan 09 '13 at 12:18
  • I know you ask for Maven, but, if it's an option, I found the Gradle plugin quite easy to use out of the box. Here is [the config for one of my projects](https://github.com/paul-g/elflock/blob/master/build.gradle). You could give this a try :) – paul-g Oct 19 '14 at 23:42

0 Answers0