I don’t know if this applies to other libraries, but JavaFx went from being part of the JVM in Java 8 to an external platform specific library in Java 11+. At that point my build stopped working in Mill and I have just been using Sbt for running JavaFx.
However I’m now wondering if the Linux, Windows and Mac versions should be encoded as separate sub projects in Sbt. Presumably as the Jar artefacts need to be released separately for each platform. How would I convert the line below to platform specific?
Here is an SBT sample that detects current OS and generates sequence of needed JavaFX libraries
libraryDependencies ++= {
// Determine OS version of JavaFX binaries
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!")
}
Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
.map(m => "org.openjfx" % s"javafx-$m" % "15.0.1" classifier osName)
}
In Mill it will be similar:
// 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!")
}
// Add dependency on JavaFX libraries, OS dependent
val javaFXModules = List("base", "controls", "fxml", "graphics", "media", "swing", "web")
.map(m => ivy"org.openjfx:javafx-$m:15.0.1;classifier=$osName")