Hi,

I have a javafx application published to a nexus server that I want to launch from a groovy script.

The application has javafx jar defined as compileOnly (provided in maven lingo) so javafx must be added to the classpath.

When i use a full jdk that includes javafx the applicaton works great but for some reason @Grab does not play well with javafx (i have no issues with other dependencies)

The script (called gade.groovy) looks like this:

@Grab('org.openjfx:javafx-controls:21.0.6')
@Grab('org.openjfx:javafx-web:21.0.6')
@Grab('org.openjfx:javafx-media:21.0.6')
@Grab('org.openjfx:javafx-swing:21.0.6')
@Grab('se.alipsa:gade:1.0.0-SNAPSHOT')

import se.alipsa.gade.Gade
import org.openjfx.application.Application

this.class.classLoader.URLs.each { url ->
  if (url.toExternalForm().contains("javafx")) {
    println "URL: $url"
  }
}
Application.launch(Gade.class, [] as String[])

Running it with `groovy gade.groovy` results in

unable to resolve class org.openjfx.application.Application
 @ line 21, column 1.
   import org.openjfx.application.Application

If i remove the Application import and Applicaton.launch lines the output is

URL: file:/home/username/.groovy/grapes/org.openjfx/javafx-swing/jars/javafx-swing-21.0.6.jar URL: file:/home/username/.groovy/grapes/org.openjfx/javafx-graphics/jars/javafx-graphics-21.0.6.jar URL: file:/home/username/.groovy/grapes/org.openjfx/javafx-base/jars/javafx-base-21.0.6.jar URL: file:/home/username/.groovy/grapes/org.openjfx/javafx-media/jars/javafx-media-21.0.6.jar URL: file:/home/username/.groovy/grapes/org.openjfx/javafx-web/jars/javafx-web-21.0.6.jar URL: file:/home/username/.groovy/grapes/org.openjfx/javafx-controls/jars/javafx-controls-21.0.6.jar

When examining the content of e.g. javafx-controls-21.0.6.jar in the grapes cache reveals an essentially empty file (just the META-INF dir) which leads me to believe that the transient classifier platform implementation jars was not fetched properly and added to the classpath.  Does anyone know if there a way to get @Grab to play nicely with javafx?


Regards,

Per

Reply via email to