I am trying to make my JavaFX app compile into a WAR file for deployment on a Jetty server, using Maven. The problem, as I see it, is with the javascript in my webapp’s index.html:
<script>
javafx(
{
draggable: true,
width: 600,
height: 290,
code: "my.app.package.MyApp",
name: "MyApp",
id: "app"
}
);
</script>
Of course, JavaScript throws an error, because it’s missing the ‘archive’ parameter where I am supposed to put the name of the jar file I’m loading this from. But that’s the problem, there is no jar. This is a war with .class files in ‘WEB-INF/classes/’ and not in a jar. There doesn’t seem to be much documentation on how to do this.
My concern is that this is unsupported behavior. An annoying alternative is to change the build type to ‘jar’, build it, change the build type back to ‘war’, build it, and put the jar in the war by hand every time. I suppose that would be alright if I could find an automated way of doing that, but I wouldn’t know how to go all INCEPTION on the build process or if that’s even a good idea to try.
Thanks for any ideas!
The solution I came to was to build the JavaFX app using an ant task (as it was a NetBeans project anyway) and including the resulting jar in the war by using this configuration for the maven-war-plugin:
For those looking for a pure-maven solution, instead of an ant task, I was also able to use the maven-jar-plugin to specifically build a jar (the project packaging type still ‘war’) as well, which I then include with the method included above.