1

I am creating a sbt plugin. One of its features is to display a dependency graph of a given scala project (the one invoking this plugin). To do so, I use scalafx, which is still depending on a javafx jar. So I need to add in my plugin build.sbt the following command:

unmanagedJars in Compile += Attributed.blank(file(System.getenv("JAVA_ORACLE") + "/jre/lib/jfxrt.jar"))

It compiles and works well. But not when I use it as a plugin from another sbt project (with the addSbtPlugin command in the project/plugins.sbt). When I invoke the plugin, I get the following error:

java.lang.NoClassDefFoundError: javafx/event/EventTarget
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:787)

The javafx classes are not found in the classLoader. I tried the assembly plugin - but it is not packaged yet for scala 2.10 that I use.

Does anyone know how I can render my javafx jar available at runtime when it is invoked by my plugin ?

Thanks

Mathieu
  • 313
  • 1
  • 8

1 Answers1

0

I'm facing the same problem (with a different .jar file) and I found a workaround. I know it's not what we are looking for (A way for the plugin to automatically have that .jar file in its classpath when being used by another project), but it works. Add the line

unmanagedJars in Compile += {
    Attributed.blank(file(System.getenv("JAVA_ORACLE") + "/jre/lib/jfxrt.jar"))
}

to the file yourMainProject/project/plugin.sbt. The same file where you placed the line addSbtPlugin(...) with you plugin.

Hope it works. If you get to find a way to solve it in the nice way, let me know.

Also check this answer, it may be helpful How to generate sources in an sbt plugin?

Community
  • 1
  • 1
caeus
  • 3,084
  • 1
  • 22
  • 36