Repository: com-lihaoyi/mill

Issue #767: Can't compile JavaFX projects (regression?)
Created: 2020-02-03T16:32:01Z
More precisely, since commit a124774, a simple JavaFX project cannot compile and log the following errors:
[info] Compiling 1 Java source to ./out/javafx/compile/dest/classes ...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by sbt.internal.inc.javac.DiagnosticsReporter$PositionImpl$ (file:/~/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/zinc-compile-core_2.12/1.2.5/zinc-compile-core_2.12-1.2.5.jar) to field com.sun.tools.javac.api.ClientCodeWrapper$DiagnosticSourceUnwrapper.d
WARNING: Please consider reporting this to the maintainers of sbt.internal.inc.javac.DiagnosticsReporter$PositionImpl$
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[error] ./javafx/src/ButtonApp.java:1:1: package javafx.application does not exist
[error] import javafx.application.Application;
[error] ./javafx/src/ButtonApp.java:2:1: package javafx.stage does not exist
[error] import javafx.stage.Stage;
…

Basically it cannot find the JavaFX packages.
Latest commit tested: 80eb7e0
Tested with java-11-graalvm and java-11-openjdk.
Was working as expected before a124774.
Sample code
cat build.sc
import mill._, scalalib._

val javaFXVersion = "13.0.2"

object javafx extends JavaModule {
  def mainClass = Some("Main")
  def ivyDeps = Agg(ivy"org.openjfx:javafx-controls:$javaFXVersion")
}
cat javafx/src/ButtonApp.java
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.control.Button;

public class ButtonApp extends Application {
  public static void main(String[] args) {
    launch(args);
  }

  @Override public void start(Stage stage) {
    var button = new Button("Please Click Me!");
    button.setOnAction(e -> stage.close());
    var box = new VBox();
    box.getChildren().add(button);
    var scene = new Scene(box);
    stage.setScene(scene);
    stage.setTitle("Just a button");
    stage.show();
  }
}
cat javafx/src/Main.java
public class Main {

  public static void main(String[] args) {
    ButtonApp.main(args);
  }
}

Duplicate issue #928: Failed to load source dependencies
Created: 2020-06-27T12:55:33Z
Following build.sbt works normally:
libraryDependencies += "org.scalafx" %% "scalafx" % "14-R19"

// 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
lazy val javaFXModules = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
libraryDependencies ++= javaFXModules.map( m =>
  "org.openjfx" % s"javafx-$m" % "15-ea+6" classifier osName
)


fork in run := true

I've ported it to mill :
import mill._, scalalib._

object kfview extends ScalaModule {
  def scalaVersion = "2.13.2"

  // 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!")
  }

  System.setProperty("javafx.platform", osName)

  val javaFxVersion = "15-ea+6"
  // val javaFxVersion = "14.0.1"

  // Add dependency on JavaFX libraries, OS dependent
  val javaFXModules = List("base", "controls", "fxml", "graphics", "media", "swing", "web")
    .map(m => ivy"org.openjfx:javafx-$m:$javaFxVersion;classifier=$osName")

  def ivyDeps = {
    Agg(
      ivy"org.scalafx::scalafx:14-R19", 
      ivy"org.openjfx:javafx:$javaFxVersion"
    ) ++ javaFXModules
  }
}

And got following error:
kfview.compileClasspath Failed to load source dependencies
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-base/15-ea+6/javafx-base-15-ea+6-${javafx.platform}.jar
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-controls/15-ea+6/javafx-controls-15-ea+6-${javafx.platform}.jar
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-fxml/15-ea+6/javafx-fxml-15-ea+6-${javafx.platform}.jar
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-graphics/15-ea+6/javafx-graphics-15-ea+6-${javafx.platform}.jar
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-media/15-ea+6/javafx-media-15-ea+6-${javafx.platform}.jar
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-swing/15-ea+6/javafx-swing-15-ea+6-${javafx.platform}.jar
  not found: https://repo1.maven.org/maven2/org/openjfx/javafx-web/15-ea+6/javafx-web-15-ea+6-${javafx.platform}.jar

Closing comment (2020-06-30T21:12:24Z): Related to #767