Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it easy to use JavaFX with java module system and automatic platform classifier #3189

Open
bjornregnell opened this issue Sep 19, 2024 · 3 comments
Labels
enhancement New feature or request javafx Issues tied with JavaFX and ScalaFX jvm Issues tied to the JVM platform

Comments

@bjornregnell
Copy link
Contributor

Is your feature request related to a problem? Please describe.
If you just naively depend on JavaFX lib like so:

//> using scala 3.5.0
//> using dep "org.openjfx:javafx-base:22.0.2"
//> using dep "org.openjfx:javafx-controls:22.0.2"
//> using dep "org.openjfx:javafx-fxml:22.0.2"
//> using dep "org.openjfx:javafx-graphics:22.0.2"
//> using dep "org.openjfx:javafx-media:22.0.2"
//> using dep "org.openjfx:javafx-swing:22.0.2"
//> using dep "org.openjfx:javafx-web:22.0.2"

then you will get this warning:
"Unsupported JavaFX configuration: classes were loaded from unnamed module ..."

It will also not be the platform dependent jars if you don't put the classifier in accordance with you platform, see platform-specific jars here:

https://repo1.maven.org/maven2/org/openjfx/javafx-controls/22.0.2/

The os classifier for javafx is one of linux, linux-aarch64, mac, mac-aarch64, win.

Describe the solution you'd like
A nice "magic" javafx command or option similar a for toolkit that just enable javafx in a platform-aware way, perhaps something like

//> using dep javafx

Describe alternatives you've considered
You could hard-code both the path and the classifyer but if you e.g. do this:

//> using scala 3.5.0
//> using dep "org.openjfx:javafx-base:22.0.2,classifier=win"
etc...

Then the directive will not work if the repo is cloned on another platform.

Additional context
See also #3188

@bjornregnell bjornregnell added the enhancement New feature or request label Sep 19, 2024
@Gedochao Gedochao added javafx Issues tied with JavaFX and ScalaFX jvm Issues tied to the JVM platform labels Sep 19, 2024
@lbialy
Copy link

lbialy commented Sep 19, 2024

is there any other package that uses the same platform classifier scheme as javafx? could this be a more generic feature than a javafx specific dependency hack?

@Gedochao
Copy link
Contributor

is there any other package that uses the same platform classifier scheme as javafx? could this be a more generic feature than a javafx specific dependency hack?

I only know of JavaFX and ScalaFX (which point to the same thing), might want to investigate separately.
Either way, it should be possible to make it work out of the box, similar to SBT.

Related:

@bjornregnell
Copy link
Contributor Author

bjornregnell commented Sep 19, 2024

In sbt I use this code to set the classifier on all the jars (modules):

// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
  case n if n.startsWith("Linux") => "linux"
  case n if n.startsWith("Mac") => "mac"
  case n if n.startsWith("Windows") => "win"
  case _ => throw new Exception("Unknown platform!")
}

lazy val fxVersion = "21.0.4"

// Add JavaFX dependencies
lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
libraryDependencies ++= javaFXModules.map( m => 
    "org.openjfx" % s"javafx-$m" % fxVersion classifier osName
)

as shown here https://github.com/bjornregnell/minimal-scala-with-javafx/blob/master/build.sbt

BUT that code does currently not take into accound aarch64 variants of mac/linux... so it wil not work on an ARM box

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javafx Issues tied with JavaFX and ScalaFX jvm Issues tied to the JVM platform
Projects
None yet
Development

No branches or pull requests

3 participants