JavaFX plugin for SBT
Knut Arne Vedaa
knut.arne.vedaa at broadpark.no
Mon Nov 12 15:27:09 PST 2012
What I do in the SBT plugin is that I generate a build.xml file that
contains <fx:jar> and <fx:deploy> task definitions, and pass on
plugin-defined settings from the project's .sbt build file to these
tasks, then run Ant on it.
This means that I am at the mercy of the JavaFX packaging Ant tasks when
it comes to what can be configured and what can not. It also means that
the output will resemble quite closely the output from building in Netbeans.
I'm gonna rely on this simple approach unless very specific needs arise
that cannot be accomplished with it.
SBT uses src/ for input and target/ for output (by default, can be
customized). So src/main/scala will contain Scala sources, and
src/main/java will contains Java sources, you could easily have
src/main/javafx contain JavaFX specific stuff, src/main/native contain
native .dll's etc.
How I do it so far:
I'm not quite sure what you mean with "JNLP template". If you mean the
options that can be passed to the <fx:deploy> task, these are configured
in the .sbt build file.
The name and location of a possible HTML template can also be
configured, and is treated as relative to the project's base directory
if it is a relative path. It could make sense to treat this as relative
to src/main/html, src/main/template, src/main/javafx or something instead.
There are four types of output:
a) Standalone jar app, which consists of a jar-file and an optional lib/
folder with library jars.
b) JNLP app, which consists of a) PLUS a JNLP file.
c) Applet, which consists of b) PLUS an HTML file.
d) Native bundles.
The <fx:deploy> task, given correct configuration, can spit out all of
the above in a directory of your choosing. This behaviour is the same as
when building from Netbeans. I'm not sure if much can be gained by
trying to circumvent this.
The standard SBT output directory is target/, or target/<scala_version>
if you're cross-building (which is the default). As of now I direct the
packager to put its output in target/<artifactname>, where artifactname
is configurable in SBT and defaults roughly to <name-version>, e.g. if
you set name to "my-app" and version to "1.0", you will (if you turn off
cross-building) have a
directory with a my-app-1.0.jnlp file, a my-app-1.0.jar file, a HTML
file and possibly a lib/ directory, and possibly some native bundles as
well (haven't looked into this yet).
Much of this could be a matter of taste though.
(Is this thread relevant for the open-jfx list, or should we move it to
More information about the openjfx-dev