From 33d107936474bca94592e9e5e4d22d9356d02a25 Mon Sep 17 00:00:00 2001 From: hmf Date: Tue, 5 Apr 2022 19:10:59 +0100 Subject: [PATCH 01/25] Cleaning up README --- README.md | 168 ++++----------------------------------- docs/historical_notes.md | 101 +++++++++++++++++++++++ 2 files changed, 116 insertions(+), 153 deletions(-) create mode 100644 docs/historical_notes.md diff --git a/README.md b/README.md index af097ed..8cfc06c 100644 --- a/README.md +++ b/README.md @@ -5,32 +5,20 @@ ## Introduction -This project shows how to set up a Mill project that uses -[OpenJFX (JavaFx)](https://openjfx.io/) library. More specifically it shows how -one needs to configure the use of the module system for JDK1.9+. Unlike other -modules, the JavaFX cannot be used as regular JAR libraries. This means the JVM -parameters for the module path and module names must be used. +This project shows how to set up a Mill project that uses [OpenJFX (JavaFx)](https://openjfx.io/) library. More specifically it shows how one needs to configure the use of the module system for JDK1.9+. Unlike other modules, the JavaFX cannot be used as regular JAR libraries. This means the JVM parameters for the module path and module names must be used. -The project contains two examples of a very simple JavaFX application that -shows a button. In the first application, when pressed the message: +The project contains two examples of a very simple JavaFX application that shows a button. In the first application, when pressed the message: Hello World! -is written to console. One can exit the application when desired. The second -application starts up a very small dialogue box. Pressing the button terminates -the application. Each of these demonstrates alternate ways of starting up a -JavaFX/OpenFX application from Scala. +is written to console. One can exit the application when desired. The second application starts up a very small dialogue box. Pressing the button terminates the application. Each of these demonstrates alternate ways of starting up a JavaFX/OpenFX application from Scala. ## Getting started -The project has three modules: `javafx`, `managed`and `unmanaged` that you can -find in the build script `build.sc`. Both the `javafx` and `managed` module -shows how to set up the modules using Mill's support for managed libraries. In -these cases, you need only add the library to use, the dependent JavaFX modules -will be downloaded for you. +The project has three modules: `javafx`, `managed`and `unmanaged` that you can find in the build script `build.sc`. Both the `javafx` and `managed` module shows how to set up the modules using Mill's support for managed libraries. In these cases, you need only add the library to use, the dependent JavaFX modules will be downloaded for you. + +The `javafx` module is an example of the use of pure Java code. To execute the application use any of these command: -The `javafx` module is an example of the use of pure Java code. To execute the -application use any of these command: * `./mill -i javafx.run` * `./mill -i javafx.runMain helloworld.HelloWorld` * `./mill -i --watch javafx.run` @@ -38,25 +26,18 @@ application use any of these command: * `./mill -i --watch javafx.runMain button.Main` -The `managed` module has two applications, each exemplifying 2 different ways to -start Scala JavaFX (OpenFX) applications (*one cannot use the class instance -directly*). To execute the application use any of these command: +The `managed` module has two applications, each exemplifying 2 different ways to start Scala JavaFX (OpenFX) applications (*one cannot use the class instance directly*). To execute the application use any of these command: + * `./mill -i managed.run` * `./mill -i managed.runMain helloworld.HelloWorld` * `./mill -i --watch managed.run` * `./mill -i managed.runMain button.Main` * `./mill -i --watch managed.runMain button.Main` -To use the IDE: - `./mill mill.scalalib.GenIdea/idea` - -The `unmanaged` module requires that you list all the dependent JavaFX -libraries that are required. You can use both managed and unmanaged libraries -simultaneously, so you need list those libraries you wish to use. This module -has the exact same applications, so the command are the same save for the -module name. +The `unmanaged` module requires that you list all the dependent JavaFX libraries that are required. You can use both managed and unmanaged libraries simultaneously, so you need list those libraries you wish to use. This module has the exact same applications, so the command are the same save for the module name. To execute the application use any of these command: + * `./mill -i unmanaged.run` * `./mill -i unmanaged.runMain helloworld.HelloWorld` * `./mill -i --watch unmanaged.run` @@ -65,10 +46,7 @@ To execute the application use any of these command: ## Setting up the Modules -The `build.sc` tries to automate as much of the JVM module parameters as -possible. More concretely, it uses Mill's `runClasspath()` method to obtain the -list of libraries (contains bot managed and unmanaged archives). It then filters -these to obtain the JavaFX libraries. +The `build.sc` tries to automate as much of the JVM module parameters as possible. More concretely, it uses Mill's `runClasspath()` method to obtain the list of libraries (contains bot managed and unmanaged archives). It then filters these to obtain the JavaFX libraries. ```scala override def forkArgs: Target[Seq[String]] = T { @@ -83,134 +61,18 @@ these to obtain the JavaFX libraries. } ``` -However, it may be necessary to tweak those parameters according -to you use case. More concretely you may need to add module exports or -patches (a patch allows you to substitute a boot module with another drop-in -replacement, for example using [TestFX/Monocle](https://github.com/TestFX/Monocle)). -So tale a look at the `override def forkArgs: Target[Seq[String]]` method and -change that accordingly. +However, it may be necessary to tweak those parameters according to your use case. More concretely you may need to add module exports or patches (a patch allows you to substitute a boot module with another drop-in replacement, for example using [TestFX/Monocle](https://github.com/TestFX/Monocle)). So take a look at the `override def forkArgs: Target[Seq[String]]` method and change that accordingly. ## Using IntelliJ To use this project in IntelliJ execute the following command: - ./mill mill.scalalib.GenIdea/idea + + `./mill mill.scalalib.GenIdea/idea` Note that Mill has support for [Bloop](https://scalacenter.github.io/bloop/). However, this needs to be set up in IntelliJ first. ## Using VSCode -In VSCode one need only open and import the Mill build script. Because Mill -supports [Bloop](https://scalacenter.github.io/bloop/), this should -automatically work for you provided you have installed the [Metals extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview). -See also [metals-vscode in Github](https://github.com/scalameta/metals-vscode). - - -# Historical notes: Issue with using JavaFX libraries - -After version `0.5.3` attempting to run a JavaFX application breaks. -See: - -* Issue [767](https://github.com/lihaoyi/mill/issues/767) -* Issue [775](https://github.com/lihaoyi/mill/pull/775) -* Issue [759](https://github.com/lihaoyi/mill/issues/759) -* Issue [1947](https://github.com/coursier/coursier/issues/1947) -* Issue [1928](https://github.com/lihaoyi/mill/issues/928) - -Discussion on a workaround is [here](https://github.com/lihaoyi/mill/discussions/1105). -Unfortunately, this also did not work. It seems like it is not only the artifact downloads -that may be causing problems. More specifically in version `0.5.3` _we cannot run a -class that is **not** marked as a main class_. - -## Launching Mill with the OpenFX modules - -### Version 0.5.3 - -These execute correctly: - * `./mill -i javafx.run` - * `./mill -i javafx.runMain helloworld.HelloWorld` - * `./mill -i --watch javafx.run` - -This fails: - `` - -with the error: - -``` -Error: JavaFX runtime components are missing, and are required to run this application -``` - -Previous versions also work. - -###Version 0.9.4 - -Mill fails to resolve the dependencies: -``` -./mill -i javafx.run -[17/31] javafx.resolvedIvyDeps -1 targets failed -javafx.resolvedIvyDeps Failed to load source dependencies -not found: https://repo1.maven.org/maven2/org/openjfx/javafx-controls/13.0.2/javafx-controls-13.0.2-${javafx.platform}.jar -not found: https://repo1.maven.org/maven2/org/openjfx/javafx-graphics/13.0.2/javafx-graphics-13.0.2-${javafx.platform}.jar -not found: https://repo1.maven.org/maven2/org/openjfx/javafx-base/13.0.2/javafx-base-13.0.2-${javafx.platform}.jar -``` - -Mill fails to resolve the dependencies: -``` -./mill -i javafx.runMain helloworld.HelloWorld -[16/28] javafx.resolvedIvyDeps -1 targets failed -javafx.resolvedIvyDeps Failed to load source dependencies - not found: https://repo1.maven.org/maven2/org/openjfx/javafx-controls/13.0.2/javafx-controls-13.0.2-${javafx.platform}.jar - not found: https://repo1.maven.org/maven2/org/openjfx/javafx-graphics/13.0.2/javafx-graphics-13.0.2-${javafx.platform}.jar - not found: https://repo1.maven.org/maven2/org/openjfx/javafx-base/13.0.2/javafx-base-13.0.2-${javafx.platform}.jar - -``` - -## Adding the classifier - -We added a classifier automatically. In the working Mill versions we see that it makes -no difference to the downloaded artifacts. - -## Java Installation - -### JDK Installation - -Tested on JDK 11. because the JDK does not include the JavaFX run-time, this -has to be installed. For Ubuntu, we need to: - -* sudo apt install openjfx -* dpkg-query -L openjfx -* java --module-path /usr/share/openjfx/lib --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.web,javafx.swing -jar '/home/lotfi/Documents/MyAppfolder/my_application.jar' - -The `dpkg-query` provides us with the path to the OpenJFX run-time. This -path and the required modules must be added to the `java` comma nd line -arguments. - -### JavaFX Installation - -You can install and use the system wide JavaFX. But we need to use and indicate the -module path. - -# Note on configuring Java modules - -In Ubuntu linux - -``` -user@machine:~$ update-alternatives --list java -/usr/lib/jvm/java-11-openjdk-amd64/bin/java -/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -/usr/lib/jvm/java-8-oracle/jre/bin/java -``` - -The following gets us the current active path: - -``` -user@machine:~$readlink -f /usr/bin/java -/usr/lib/jvm/java-11-openjdk-amd64/bin/java -``` - -Look at [Gradle JavaFX plugin](https://github.com/openjfx/javafx-gradle-plugin) -It provides the module paths - +In VSCode one need only open and import the Mill build script. Because Mill supports [Bloop](https://scalacenter.github.io/bloop/), this should automatically work for you provided you have installed the [Metals extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=scalameta.metals#overview). See also [metals-vscode in Github](https://github.com/scalameta/metals-vscode). diff --git a/docs/historical_notes.md b/docs/historical_notes.md new file mode 100644 index 0000000..28efd93 --- /dev/null +++ b/docs/historical_notes.md @@ -0,0 +1,101 @@ + +# Historical notes: Issue with using JavaFX libraries + +After version `0.5.3` attempting to run a JavaFX application breaks. +See: + +* Issue [767](https://github.com/lihaoyi/mill/issues/767) +* Issue [775](https://github.com/lihaoyi/mill/pull/775) +* Issue [759](https://github.com/lihaoyi/mill/issues/759) +* Issue [1947](https://github.com/coursier/coursier/issues/1947) +* Issue [1928](https://github.com/lihaoyi/mill/issues/928) + +Discussion on a workaround is [here](https://github.com/lihaoyi/mill/discussions/1105). Unfortunately, this also did not work. It seems like it is not only the artifact downloads that may be causing problems. More specifically in version `0.5.3` _we cannot run a class that is **not** marked as a main class_. + +## Launching Mill with the OpenFX modules + +### Version 0.5.3 + +These execute correctly: + * `./mill -i javafx.run` + * `./mill -i javafx.runMain helloworld.HelloWorld` + * `./mill -i --watch javafx.run` + +This fails: + `` + +with the error: + +``` +Error: JavaFX runtime components are missing, and are required to run this application +``` + +Previous versions also work. + +###Version 0.9.4 + +Mill fails to resolve the dependencies: + +```bash +./mill -i javafx.run +[17/31] javafx.resolvedIvyDeps +1 targets failed +javafx.resolvedIvyDeps Failed to load source dependencies +not found: https://repo1.maven.org/maven2/org/openjfx/javafx-controls/13.0.2/javafx-controls-13.0.2-${javafx.platform}.jar +not found: https://repo1.maven.org/maven2/org/openjfx/javafx-graphics/13.0.2/javafx-graphics-13.0.2-${javafx.platform}.jar +not found: https://repo1.maven.org/maven2/org/openjfx/javafx-base/13.0.2/javafx-base-13.0.2-${javafx.platform}.jar +``` + +Mill fails to resolve the dependencies: + +```bash +./mill -i javafx.runMain helloworld.HelloWorld +[16/28] javafx.resolvedIvyDeps +1 targets failed +javafx.resolvedIvyDeps Failed to load source dependencies + not found: https://repo1.maven.org/maven2/org/openjfx/javafx-controls/13.0.2/javafx-controls-13.0.2-${javafx.platform}.jar + not found: https://repo1.maven.org/maven2/org/openjfx/javafx-graphics/13.0.2/javafx-graphics-13.0.2-${javafx.platform}.jar + not found: https://repo1.maven.org/maven2/org/openjfx/javafx-base/13.0.2/javafx-base-13.0.2-${javafx.platform}.jar + +``` + +## Adding the classifier + +We added a classifier automatically. In the working Mill versions we see that it makes no difference to the downloaded artifacts. + +## Java Installation + +### JDK Installation + +Tested on JDK 11. Because the JDK does not include the JavaFX run-time, this has to be installed. For Ubuntu, we need to: + +* sudo apt install openjfx +* dpkg-query -L openjfx +* java --module-path /usr/share/openjfx/lib --add-modules=javafx.controls,javafx.fxml,javafx.base,javafx.media,javafx.web,javafx.swing -jar '/home/lotfi/Documents/MyAppfolder/my_application.jar' + +The `dpkg-query` provides us with the path to the OpenJFX run-time. This path and the required modules must be added to the `java` comma nd line arguments. + +### JavaFX Installation + +You can install and use the system wide JavaFX. But we need to use and indicate the module path. + +# Note on configuring Java modules + +In Ubuntu linux + +```basch +user@machine:~$ update-alternatives --list java +/usr/lib/jvm/java-11-openjdk-amd64/bin/java +/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java +/usr/lib/jvm/java-8-oracle/jre/bin/java +``` + +The following gets us the current active path: + +```bash +user@machine:~$readlink -f /usr/bin/java +/usr/lib/jvm/java-11-openjdk-amd64/bin/java +``` + +Look at [Gradle JavaFX plugin](https://github.com/openjfx/javafx-gradle-plugin). It provides the module paths. + From 3c37a09f90426a22fd58133f8c5c9f71d66aec8c Mon Sep 17 00:00:00 2001 From: hmf Date: Thu, 7 Apr 2022 18:32:05 +0100 Subject: [PATCH 02/25] Corrected build so tests can run --- build.sc | 37 +++++++++++++++++++------------ managed/test/src/PlotSpec.scala | 4 ++-- unmanaged/test/src/PlotSpec.scala | 10 ++++----- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/build.sc b/build.sc index b169f41..7893e93 100644 --- a/build.sc +++ b/build.sc @@ -7,14 +7,14 @@ import mill.api.Loose import mill.define.{Target, Task} import scalalib._ -val ScalaVersion = "3.1.0" +val ScalaVersion = "3.1.1" //val javaFXVersion = "11.0.2" //val javaFXVersion = "12" //val javaFXVersion = "13.0.2" val javaFXVersion = "16" -val mUnitVersion = "0.7.27" +val mUnitVersion = "1.0.0-M3" //"0.7.27" val controlsFXVersion = "11.1.0" val hanSoloChartsVersion = "16.0.12" @@ -156,19 +156,20 @@ trait OpenJFX extends JavaModule { } - // TODO: after version 0.10.0 of Mill put test in the managed/unmanaged classes - object test extends Tests { + // // TODO: after version 0.10.0 of Mill put test in the managed/unmanaged classes + // object test extends Tests { - // TODO: after version 0.10.0 of Mill remove this - // sse https://github.com/com-lihaoyi/mill/issues/1406 - override def resolutionCustomizer: Task[Option[Resolution => Resolution]] = T.task { - Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) - } + // // // TODO: after version 0.10.0 of Mill remove this + // // // sse https://github.com/com-lihaoyi/mill/issues/1406 + // // override def resolutionCustomizer: Task[Option[Resolution => Resolution]] = T.task { + // // Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) + // // } - // https://github.com/com-lihaoyi/mill#097---2021-05-14 - //def testFrameworks = Seq(ivyMunitInterface) - def testFramework = ivyMunitInterface - } + // // https://github.com/com-lihaoyi/mill#097---2021-05-14 + // //def testFrameworks = Seq(ivyMunitInterface) + // def ivyDeps = Agg(ivyMunit) + // def testFramework = ivyMunitInterface + // } } @@ -201,7 +202,10 @@ object managed extends OpenJFX with ScalaModule { //ivy"${modules(CONTROLSFX_)}", ) - + object test extends Tests { + def ivyDeps = Agg(ivyMunit) + def testFramework = ivyMunitInterface + } } @@ -262,6 +266,11 @@ object unmanaged extends OpenJFX with ScalaModule { Agg(pathRefs : _*) } + object test extends Tests { + def ivyDeps = Agg(ivyMunit) + def testFramework = ivyMunitInterface + } + } diff --git a/managed/test/src/PlotSpec.scala b/managed/test/src/PlotSpec.scala index 03eaebd..5194531 100644 --- a/managed/test/src/PlotSpec.scala +++ b/managed/test/src/PlotSpec.scala @@ -8,8 +8,8 @@ package managed * * ./mill -i managed.test * ./mill -i managed.test.testLocal - * ./mill -i managed.test splotly.PlotSpec.* - * ./mill -i managed.test splotly.PlotSpec.test1 + * ./mill -i managed.test managed.PlotSpec.* + * ./mill -i managed.test managed.PlotSpec.test1 * * Extending `TestCase` to get access to `setUp` * diff --git a/unmanaged/test/src/PlotSpec.scala b/unmanaged/test/src/PlotSpec.scala index 03eaebd..95851e3 100644 --- a/unmanaged/test/src/PlotSpec.scala +++ b/unmanaged/test/src/PlotSpec.scala @@ -1,15 +1,15 @@ /* cspell: disable-next-line */ -package managed +package unmanaged // cSpell:ignore splotly, munit /** * ./mill mill.scalalib.GenIdea/idea * - * ./mill -i managed.test - * ./mill -i managed.test.testLocal - * ./mill -i managed.test splotly.PlotSpec.* - * ./mill -i managed.test splotly.PlotSpec.test1 + * ./mill -i unmanaged.test + * ./mill -i unmanaged.test.testLocal + * ./mill -i unmanaged.test unmanaged.PlotSpec.* + * ./mill -i unmanaged.test unmanaged.PlotSpec.test1 * * Extending `TestCase` to get access to `setUp` * From a681221e82d7272d84b2752f529a37fb09adb834 Mon Sep 17 00:00:00 2001 From: hmf Date: Thu, 14 Apr 2022 15:35:45 +0100 Subject: [PATCH 03/25] Minor updates for publishing --- .mill-version | 2 +- managed/test/src/PlotSpec.scala | 8 +++++++- unmanaged/test/src/PlotSpec.scala | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.mill-version b/.mill-version index 42624f3..56e9df1 100644 --- a/.mill-version +++ b/.mill-version @@ -1 +1 @@ -0.10.2 \ No newline at end of file +0.10.3 \ No newline at end of file diff --git a/managed/test/src/PlotSpec.scala b/managed/test/src/PlotSpec.scala index 5194531..bd0c809 100644 --- a/managed/test/src/PlotSpec.scala +++ b/managed/test/src/PlotSpec.scala @@ -20,7 +20,13 @@ package managed */ class PlotSpec extends munit.FunSuite { - test("hello") { + test("test_ok") { + val obtained = 42 + val expected = 42 + assertEquals(obtained, expected) + } + + test("test_fails") { val obtained = 42 val expected = 43 assertEquals(obtained, expected) diff --git a/unmanaged/test/src/PlotSpec.scala b/unmanaged/test/src/PlotSpec.scala index 95851e3..db74e81 100644 --- a/unmanaged/test/src/PlotSpec.scala +++ b/unmanaged/test/src/PlotSpec.scala @@ -20,7 +20,13 @@ package unmanaged */ class PlotSpec extends munit.FunSuite { - test("hello") { + test("test_ok") { + val obtained = 42 + val expected = 42 + assertEquals(obtained, expected) + } + + test("test_fails") { val obtained = 42 val expected = 43 assertEquals(obtained, expected) From c82bfa6f6240f25f1dd43168f5a30110ccbc9b03 Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 16 Apr 2022 11:54:31 +0100 Subject: [PATCH 04/25] Detected OS dependent bug. Added TODO --- build.sc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sc b/build.sc index 7893e93..7b04cb8 100644 --- a/build.sc +++ b/build.sc @@ -145,7 +145,7 @@ trait OpenJFX extends JavaModule { // Add to the modules list Seq( - "--module-path", s.iterator.mkString(":"), + "--module-path", s.iterator.mkString(":"), //TODO: BUG !!!! must be OS dependent "--add-modules", modulesNames.iterator.mkString(","), "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-exports=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", @@ -261,7 +261,7 @@ object unmanaged extends OpenJFX with ScalaModule { Seq(controlsFXModule) // Check if the libraries exist and download if they don't val files = Fetch().addDependencies(javaFXModules: _*).run() - // Return the list f libraries + // Return the list of libraries val pathRefs = files.map(f => PathRef(os.Path(f))) Agg(pathRefs : _*) } From 1db8e4eace8bbf005c53ff25c75891c291a783bf Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 16 Apr 2022 17:48:00 +0100 Subject: [PATCH 05/25] Corrected bug in build - support for Wndows. --- build.sc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sc b/build.sc index 7b04cb8..fd867e5 100644 --- a/build.sc +++ b/build.sc @@ -6,6 +6,7 @@ import mill._ import mill.api.Loose import mill.define.{Target, Task} import scalalib._ +import java.io.File val ScalaVersion = "3.1.1" @@ -107,6 +108,8 @@ trait OpenJFX extends JavaModule { Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) } + val pathSeparator= File.pathSeparator + /** * Here we setup the Java modules so that they can be loaded prior to * application boot. We can indicate which modules are visible and even opt @@ -145,7 +148,7 @@ trait OpenJFX extends JavaModule { // Add to the modules list Seq( - "--module-path", s.iterator.mkString(":"), //TODO: BUG !!!! must be OS dependent + "--module-path", s.iterator.mkString( pathSeparator ), "--add-modules", modulesNames.iterator.mkString(","), "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-exports=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", From 09758360beede14d78429a009fc96e9ffe474d40 Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 16 Apr 2022 18:03:17 +0100 Subject: [PATCH 06/25] TODO: artifact type for OS ? --- build.sc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sc b/build.sc index fd867e5..713db39 100644 --- a/build.sc +++ b/build.sc @@ -263,7 +263,10 @@ object unmanaged extends OpenJFX with ScalaModule { ) ++ Seq(controlsFXModule) // Check if the libraries exist and download if they don't - val files = Fetch().addDependencies(javaFXModules: _*).run() + val files = Fetch() + .addDependencies(javaFXModules: _*) + .addArtifactTypes(Type.pom, Type.testJar) + .run() // Return the list of libraries val pathRefs = files.map(f => PathRef(os.Path(f))) Agg(pathRefs : _*) From e29bc4e069e326e5a2634a5830178d8e6959833d Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 18 Apr 2022 09:04:24 +0100 Subject: [PATCH 07/25] Small corrections to build.sc --- build.sc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/build.sc b/build.sc index 713db39..d6bc71f 100644 --- a/build.sc +++ b/build.sc @@ -62,14 +62,14 @@ trait OpenJFX extends JavaModule { val controlsFXModule = "org.controlsfx.controls" // Module libraries - val BASE = s"org.openjfx:javafx-$BASE_:$javaFXVersion" - val CONTROLS = s"org.openjfx:javafx-$CONTROLS_:$javaFXVersion" - val FXML = s"org.openjfx:javafx-$FXML_:$javaFXVersion" - val GRAPHICS = s"org.openjfx:javafx-$GRAPHICS_:$javaFXVersion" - val MEDIA = s"org.openjfx:javafx-$MEDIA_:$javaFXVersion" - val SWING = s"org.openjfx:javafx-$SWING_:$javaFXVersion" - val WEB = s"org.openjfx:javafx-$WEB_:$javaFXVersion" - val CONTROLSFX = s"org.controlsfx:$CONTROLSFX_:$controlsFXVersion" + val BASE = s"org.openjfx:javafx-${BASE_}:$javaFXVersion" + val CONTROLS = s"org.openjfx:javafx-${CONTROLS_}:$javaFXVersion" + val FXML = s"org.openjfx:javafx-${FXML_}:$javaFXVersion" + val GRAPHICS = s"org.openjfx:javafx-${GRAPHICS_}:$javaFXVersion" + val MEDIA = s"org.openjfx:javafx-${MEDIA_}:$javaFXVersion" + val SWING = s"org.openjfx:javafx-${SWING_}:$javaFXVersion" + val WEB = s"org.openjfx:javafx-${WEB_}:$javaFXVersion" + val CONTROLSFX = s"org.controlsfx:${CONTROLSFX_}:$controlsFXVersion" // OpenFX/JavaFX libraries val javaFXModuleNames = Seq(BASE_, CONTROLS_, FXML_, GRAPHICS_, MEDIA_, SWING_, WEB_) @@ -206,8 +206,8 @@ object managed extends OpenJFX with ScalaModule { ) object test extends Tests { - def ivyDeps = Agg(ivyMunit) - def testFramework = ivyMunitInterface + override def ivyDeps = Agg(ivyMunit) + override def testFramework = ivyMunitInterface } } @@ -265,7 +265,7 @@ object unmanaged extends OpenJFX with ScalaModule { // Check if the libraries exist and download if they don't val files = Fetch() .addDependencies(javaFXModules: _*) - .addArtifactTypes(Type.pom, Type.testJar) + .addArtifactTypes(Type.all) .run() // Return the list of libraries val pathRefs = files.map(f => PathRef(os.Path(f))) @@ -273,8 +273,8 @@ object unmanaged extends OpenJFX with ScalaModule { } object test extends Tests { - def ivyDeps = Agg(ivyMunit) - def testFramework = ivyMunitInterface + override def ivyDeps = Agg(ivyMunit) + override def testFramework = ivyMunitInterface } } From a67f5407bc4526f71aec8e567c040d90bd55faf8 Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 18 Apr 2022 09:24:46 +0100 Subject: [PATCH 08/25] TODO: artifact type for OS? Added refs to questions --- build.sc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build.sc b/build.sc index d6bc71f..fa1b87c 100644 --- a/build.sc +++ b/build.sc @@ -247,6 +247,9 @@ object unmanaged extends OpenJFX with ScalaModule { * Managed libraries can also be used by overriding `ivyDeps` * * @return List of path references to the libraries + * + * @see https://github.com/coursier/coursier/discussions/2401 + * @see https://github.com/com-lihaoyi/mill/discussions/1842 */ override def unmanagedClasspath: Target[Loose.Agg[PathRef]] = T{ import coursier._ From 4053caae68839a5ed85073fa74f7fa89706aa34a Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 23 Apr 2022 13:57:57 +0100 Subject: [PATCH 09/25] Initial experiment with unmanaged all OS --- build.sc | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/build.sc b/build.sc index fa1b87c..f1773d3 100644 --- a/build.sc +++ b/build.sc @@ -10,6 +10,10 @@ import java.io.File val ScalaVersion = "3.1.1" +import $ivy.`org.scala-lang.modules::scala-async:0.10.0` +// libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.10.0" +// libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided + //val javaFXVersion = "11.0.2" //val javaFXVersion = "12" //val javaFXVersion = "13.0.2" @@ -234,6 +238,8 @@ object managed extends OpenJFX with ScalaModule { * @see https://github.com/com-lihaoyi/mill/pull/775#issuecomment-826091576 */ object unmanaged extends OpenJFX with ScalaModule { + + def scalaVersion = T{ ScalaVersion } override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") @@ -255,6 +261,55 @@ object unmanaged extends OpenJFX with ScalaModule { import coursier._ import coursier.parse.DependencyParser + import coursier.core.{Activation, Configuration, Extension, Reconciliation} + import coursier.error.ResolutionError + import coursier.ivy.IvyRepository + import coursier.params.{MavenMirror, Mirror, ResolutionParams, TreeMirror} + import coursier.util.ModuleMatchers + + + import scala.async.Async.{async, await} + import scala.collection.compat._ + + implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global + + async { + // TODO: testing + val resolve = Resolve() + //.noMirrors + //.withCache(cache) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + Activation.Os( + Some("x86_64"), + Set("mac", "unix"), + Some("mac os x"), + Some("10.15.1") + ) + } + //.withJdkVersion("1.8.0_121") + ) + + val deps = Seq( + dep"org.bytedeco:mkl-platform:2019.5-1.5.2", + dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" + ) + val res = await { + resolve + .addDependencies(deps: _*) + .future() + } + + //await(validateDependencies(res)) + + val urls = res.dependencyArtifacts().map(_._3.url).toSet + println("?????????????????????????????") + println(urls.mkString("\n,?")) + } + + + // Extra OpenFX library // Coursier: only a single String literal is allowed here, so cannot decouple version //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" From d7f4d001fe43de02211161ed74f4e5a794c4bfcb Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 23 Apr 2022 14:01:55 +0100 Subject: [PATCH 10/25] Experiment with unmanaged all OS - try to not use async? --- build.sc | 104 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 37 deletions(-) diff --git a/build.sc b/build.sc index f1773d3..4832e2b 100644 --- a/build.sc +++ b/build.sc @@ -271,44 +271,74 @@ object unmanaged extends OpenJFX with ScalaModule { import scala.async.Async.{async, await} import scala.collection.compat._ - implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global - - async { - // TODO: testing - val resolve = Resolve() - //.noMirrors - //.withCache(cache) - .withResolutionParams( - ResolutionParams() - .withOsInfo { - Activation.Os( - Some("x86_64"), - Set("mac", "unix"), - Some("mac os x"), - Some("10.15.1") - ) - } - //.withJdkVersion("1.8.0_121") - ) - - val deps = Seq( - dep"org.bytedeco:mkl-platform:2019.5-1.5.2", - dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" - ) - val res = await { - resolve - .addDependencies(deps: _*) - .future() - } - - //await(validateDependencies(res)) - - val urls = res.dependencyArtifacts().map(_._3.url).toSet - println("?????????????????????????????") - println(urls.mkString("\n,?")) + // implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global + + // async { + // // TODO: testing + // val resolve = Resolve() + // //.noMirrors + // //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + + // val deps = Seq( + // dep"org.bytedeco:mkl-platform:2019.5-1.5.2", + // dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" + // ) + // val res = await { + // resolve + // .addDependencies(deps: _*) + // .future() + // } + + // //await(validateDependencies(res)) + + // val urls = res.dependencyArtifacts().map(_._3.url).toSet + // println("?????????????????????????????") + // println(urls.mkString("\n,?")) + // } + + + // TODO: testing + val resolve = Resolve() + //.noMirrors + //.withCache(cache) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + Activation.Os( + Some("x86_64"), + Set("mac", "unix"), + Some("mac os x"), + Some("10.15.1") + ) + } + //.withJdkVersion("1.8.0_121") + ) + + val deps = Seq( + dep"org.bytedeco:mkl-platform:2019.5-1.5.2", + dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" + ) + val resFiles = await { + resolve + .addDependencies(deps: _*) + .run() } - - + val urls = resFiles.dependencyArtifacts().map(_._3.url).toSet + println("?????????????????????????????") + println(urls.mkString("\n,?")) + val pathRefsAll = files.map(f => PathRef(os.Path(f))) // Extra OpenFX library // Coursier: only a single String literal is allowed here, so cannot decouple version From 92af3557bfaff56fb0c5c01b087518d587e23adb Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 23 Apr 2022 14:54:32 +0100 Subject: [PATCH 11/25] Can only download one OS per fetch --- build.sc | 199 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 131 insertions(+), 68 deletions(-) diff --git a/build.sc b/build.sc index 4832e2b..2d17f82 100644 --- a/build.sc +++ b/build.sc @@ -271,74 +271,7 @@ object unmanaged extends OpenJFX with ScalaModule { import scala.async.Async.{async, await} import scala.collection.compat._ - // implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global - - // async { - // // TODO: testing - // val resolve = Resolve() - // //.noMirrors - // //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) - - // val deps = Seq( - // dep"org.bytedeco:mkl-platform:2019.5-1.5.2", - // dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" - // ) - // val res = await { - // resolve - // .addDependencies(deps: _*) - // .future() - // } - - // //await(validateDependencies(res)) - - // val urls = res.dependencyArtifacts().map(_._3.url).toSet - // println("?????????????????????????????") - // println(urls.mkString("\n,?")) - // } - - - // TODO: testing - val resolve = Resolve() - //.noMirrors - //.withCache(cache) - .withResolutionParams( - ResolutionParams() - .withOsInfo { - Activation.Os( - Some("x86_64"), - Set("mac", "unix"), - Some("mac os x"), - Some("10.15.1") - ) - } - //.withJdkVersion("1.8.0_121") - ) - - val deps = Seq( - dep"org.bytedeco:mkl-platform:2019.5-1.5.2", - dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" - ) - val resFiles = await { - resolve - .addDependencies(deps: _*) - .run() - } - val urls = resFiles.dependencyArtifacts().map(_._3.url).toSet - println("?????????????????????????????") - println(urls.mkString("\n,?")) - val pathRefsAll = files.map(f => PathRef(os.Path(f))) + implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global // Extra OpenFX library // Coursier: only a single String literal is allowed here, so cannot decouple version @@ -350,6 +283,136 @@ object unmanaged extends OpenJFX with ScalaModule { m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) ) ++ Seq(controlsFXModule) + + println(sys.props.toMap.mkString(" ,!\n")) + /* +sun.os.patch.level -> unknown ,! +os.arch -> amd64 ,! +os.version -> 5.13.0-40-generic ,! +jna.nosys -> true ,! +os.name -> Linux ,! +*/ + +/* + .withOsInfo(coursier.core.Activation.Os.fromProperties(Map( + "os.name" -> "Linux", + "os.arch" -> "amd64", + "os.version" -> "4.9.125", + "path.separator" -> ":" + )))) +*/ + +// https://github.com/coursier/coursier/blob/a213c20099dcf8df24af317479945c5f90ac5563/modules/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala +/* + + val windowsOs = core.Activation.Os.fromProperties(Map( + "os.name" -> "Windows 10", + "os.arch" -> "amd64", + "os.version" -> "10.0", + "path.separator" -> ";" + )) + +*/ + +// https://github.com/coursier/coursier/blob/a213c20099dcf8df24af317479945c5f90ac5563/modules/core/shared/src/main/scala/coursier/core/Activation.scala + +/* + arch: Option[String], + families: Set[String], + name: Option[String], + version: Option[String] + + private val standardFamilies = Set( + "windows", + "os/2", + "netware", + "mac", + "os/400", + "openvms" + ) + */ + + val macOSx64 =Activation.Os( + Some("x86_64"), // same as amd64 or x86-64 + Set("mac", "unix"), + Some("mac os x"), + None + ) + + val winX64 =Activation.Os( + Some("x86_64"), + Set("windows"), + None, + None + ) + + val linuxX64 =Activation.Os( + Some("x86_64"), + Set("unix"), + Some("linux"), + None + ) + + async { + // TODO: testing + val resolve = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + // macOSx64 + // linuxX64 + winX64 + } + .withOsInfo { + macOSx64 + // linuxX64 + // winX64 + } + //.withJdkVersion("1.8.0_121") + ) + + // val deps = Seq( + // dep"org.bytedeco:mkl-platform:2019.5-1.5.2", + // dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" + // ) + val deps = javaFXModules + val res = await { + resolve + .addDependencies(deps: _*) + .future() + } + + //await(validateDependencies(res)) + + val urls = res.dependencyArtifacts().map(_._3.url).toSet + println("?????????????????????????????") + println(urls.mkString("\n,?")) + } + + // // Extra OpenFX library + // // Coursier: only a single String literal is allowed here, so cannot decouple version + // //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" + // val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" + + // // Generate the dependencies + // val javaFXModules = javaFXModuleNames.map( + // m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) + // ) ++ + // Seq(controlsFXModule) // Check if the libraries exist and download if they don't val files = Fetch() .addDependencies(javaFXModules: _*) From 59f9fe5dc01db082a220717f6223bf96abcbf3f0 Mon Sep 17 00:00:00 2001 From: hmf Date: Sat, 23 Apr 2022 19:57:33 +0100 Subject: [PATCH 12/25] Starting example of downloading various OS native binaries. --- allOS/src/button/ButtonApp.scala | 27 +++++++ allOS/src/button/Main.scala | 17 +++++ allOS/src/helloworld/HelloWorld.scala | 44 +++++++++++ .../test/src/ExampleSpec.scala | 6 +- build.sc | 74 +++++++++++++++++++ .../test/src/ExampleSpec.scala | 12 +-- unmanaged/test/src/ExampleSpec.scala | 37 ++++++++++ 7 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 allOS/src/button/ButtonApp.scala create mode 100644 allOS/src/button/Main.scala create mode 100644 allOS/src/helloworld/HelloWorld.scala rename managed/test/src/PlotSpec.scala => allOS/test/src/ExampleSpec.scala (81%) rename unmanaged/test/src/PlotSpec.scala => managed/test/src/ExampleSpec.scala (70%) create mode 100644 unmanaged/test/src/ExampleSpec.scala diff --git a/allOS/src/button/ButtonApp.scala b/allOS/src/button/ButtonApp.scala new file mode 100644 index 0000000..9fac74c --- /dev/null +++ b/allOS/src/button/ButtonApp.scala @@ -0,0 +1,27 @@ +package button + +import javafx.application.Application +import javafx.stage.Stage +import javafx.scene.Scene +import javafx.scene.layout.VBox +import javafx.scene.control.Button + +class ButtonApp extends Application { + + override def start(stage: Stage) = { + System.out.println("STARTED un-managed Scala!") + var button = new Button("Please un-managed Scala 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 an un-managed Scala button") + stage.show() + } + + def launchIt():Unit={ + Application.launch() + } + +} \ No newline at end of file diff --git a/allOS/src/button/Main.scala b/allOS/src/button/Main.scala new file mode 100644 index 0000000..f153f13 --- /dev/null +++ b/allOS/src/button/Main.scala @@ -0,0 +1,17 @@ +package button + +/** + * + * ./mill mill.scalalib.GenIdea/idea + * + * ./mill -i unmanaged.runMain button.Main + * ./mill -i --watch unmanaged.runMain button.Main + * + * @see https://stackoverflow.com/questions/12124657/getting-started-on-scala-javafx-desktop-application-development + */ +object Main { + def main(args: Array[String]) = + val app = new ButtonApp + app.launchIt() + +} \ No newline at end of file diff --git a/allOS/src/helloworld/HelloWorld.scala b/allOS/src/helloworld/HelloWorld.scala new file mode 100644 index 0000000..353a665 --- /dev/null +++ b/allOS/src/helloworld/HelloWorld.scala @@ -0,0 +1,44 @@ +package helloworld + +// cSpell:ignore helloworld + +import javafx.application.Application +import javafx.event.ActionEvent +import javafx.event.EventHandler +import javafx.scene.Scene +import javafx.scene.control.Button +import javafx.scene.layout.StackPane +import javafx.stage.Stage + +/** + * + * ./mill mill.scalalib.GenIdea/idea + * + * ./mill -i unmanaged.run + * ./mill -i unmanaged.runMain helloworld.HelloWorld + * ./mill -i --watch unmanaged.run + * + * @see https://stackoverflow.com/questions/12124657/getting-started-on-scala-javafx-desktop-application-development + */ +class HelloWorld extends Application { + + override def start(primaryStage: Stage) = { + primaryStage.setTitle("Hello un-managed Scala World!") + val btn = new Button() + btn.setText("Say 'Hello un-managed Scala World'") + btn.setOnAction(new EventHandler[ActionEvent]() { + override def handle(event: ActionEvent) = { + System.out.println("Hello un-managed Scala World!") + } + }) + + val root = new StackPane() + root.getChildren().add(btn) + primaryStage.setScene(new Scene(root, 300, 250)) + primaryStage.show() + } +} + +object HelloWorld: + def main(args: Array[String]) = + Application.launch(classOf[HelloWorld], args: _*) diff --git a/managed/test/src/PlotSpec.scala b/allOS/test/src/ExampleSpec.scala similarity index 81% rename from managed/test/src/PlotSpec.scala rename to allOS/test/src/ExampleSpec.scala index bd0c809..486a7ca 100644 --- a/managed/test/src/PlotSpec.scala +++ b/allOS/test/src/ExampleSpec.scala @@ -8,8 +8,8 @@ package managed * * ./mill -i managed.test * ./mill -i managed.test.testLocal - * ./mill -i managed.test managed.PlotSpec.* - * ./mill -i managed.test managed.PlotSpec.test1 + * ./mill -i managed.test managed.ExampleSpec.* + * ./mill -i managed.test managed.ExampleSpec.test1 * * Extending `TestCase` to get access to `setUp` * @@ -18,7 +18,7 @@ package managed * * */ -class PlotSpec extends munit.FunSuite { +class ExampleSpec extends munit.FunSuite { test("test_ok") { val obtained = 42 diff --git a/build.sc b/build.sc index 2d17f82..977106c 100644 --- a/build.sc +++ b/build.sc @@ -240,6 +240,79 @@ object managed extends OpenJFX with ScalaModule { object unmanaged extends OpenJFX with ScalaModule { + def scalaVersion = T{ ScalaVersion } + + override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") + + /** + * Here we manually download the modules' jars. No need to install them + * separately in the OS. This allows us to determine the paths to the + * libraries so they can be used later in the JVM parameters. Note that this + * is a Mill command that is cached, so it can be called repeatedly. + * + * Managed libraries can also be used by overriding `ivyDeps` + * + * @return List of path references to the libraries + * + * @see https://github.com/coursier/coursier/discussions/2401 + * @see https://github.com/com-lihaoyi/mill/discussions/1842 + */ + override def unmanagedClasspath: Target[Loose.Agg[PathRef]] = T{ + import coursier._ + import coursier.parse.DependencyParser + + // Extra OpenFX library + // Coursier: only a single String literal is allowed here, so cannot decouple version + //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" + val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" + + // Generate the dependencies + val javaFXModules = javaFXModuleNames.map( + m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) + ) ++ + Seq(controlsFXModule) + + // Check if the libraries exist and download if they don't + val files = Fetch() + .addDependencies(javaFXModules: _*) + .addArtifactTypes(Type.all) + .run() + // Return the list of libraries + val pathRefs = files.map(f => PathRef(os.Path(f))) + Agg(pathRefs : _*) + } + + object test extends Tests { + override def ivyDeps = Agg(ivyMunit) + override def testFramework = ivyMunitInterface + } + +} + + + +/** + * When working with JavaFX/OpenFX in JDK 1.9 and later, the libraries are + * not included in the JDK. They may be installed manually in the OS or + * automatically via Mill. The latter method has the advantage of acquiring + * the paths of the libraries automatically and also setting up build the file + * automatically. The easiest way to do this is to to use Mill's automatic + * library dependency management (see #775# link below). Here we exemplify the + * use of Mill's unmanaged library dependency setup. Any other libraries + * may still be used via Mill's managed library setup. + * + * Note that in the case of the JavaFX libraries we must use/set the JVM's + * parameters to include the module path and module names. Other libraries, even + * though provided as module may not require this. Most of the JVM parameter + * set-up is automatic. It also allows to set-up module visibility and even + * overriding certain modules on boot-up. This allows for example the use the + * TestFX for use in headless UI testing. + * + * @see https://github.com/com-lihaoyi/mill/pull/775#issuecomment-826091576 + */ +object allOS extends OpenJFX with ScalaModule { + + def scalaVersion = T{ ScalaVersion } override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") @@ -431,6 +504,7 @@ os.name -> Linux ,! } + /** * Same as the `managed`target, but here we just use Java. */ diff --git a/unmanaged/test/src/PlotSpec.scala b/managed/test/src/ExampleSpec.scala similarity index 70% rename from unmanaged/test/src/PlotSpec.scala rename to managed/test/src/ExampleSpec.scala index db74e81..486a7ca 100644 --- a/unmanaged/test/src/PlotSpec.scala +++ b/managed/test/src/ExampleSpec.scala @@ -1,15 +1,15 @@ /* cspell: disable-next-line */ -package unmanaged +package managed // cSpell:ignore splotly, munit /** * ./mill mill.scalalib.GenIdea/idea * - * ./mill -i unmanaged.test - * ./mill -i unmanaged.test.testLocal - * ./mill -i unmanaged.test unmanaged.PlotSpec.* - * ./mill -i unmanaged.test unmanaged.PlotSpec.test1 + * ./mill -i managed.test + * ./mill -i managed.test.testLocal + * ./mill -i managed.test managed.ExampleSpec.* + * ./mill -i managed.test managed.ExampleSpec.test1 * * Extending `TestCase` to get access to `setUp` * @@ -18,7 +18,7 @@ package unmanaged * * */ -class PlotSpec extends munit.FunSuite { +class ExampleSpec extends munit.FunSuite { test("test_ok") { val obtained = 42 diff --git a/unmanaged/test/src/ExampleSpec.scala b/unmanaged/test/src/ExampleSpec.scala new file mode 100644 index 0000000..486a7ca --- /dev/null +++ b/unmanaged/test/src/ExampleSpec.scala @@ -0,0 +1,37 @@ +/* cspell: disable-next-line */ +package managed + +// cSpell:ignore splotly, munit + +/** + * ./mill mill.scalalib.GenIdea/idea + * + * ./mill -i managed.test + * ./mill -i managed.test.testLocal + * ./mill -i managed.test managed.ExampleSpec.* + * ./mill -i managed.test managed.ExampleSpec.test1 + * + * Extending `TestCase` to get access to `setUp` + * + * https://github.com/sbt/junit-interface#junit-interface + * ./mill -i managed.test --tests=test1 Only matches test names (not classes) + * + * + */ +class ExampleSpec extends munit.FunSuite { + + test("test_ok") { + val obtained = 42 + val expected = 42 + assertEquals(obtained, expected) + } + + test("test_fails") { + val obtained = 42 + val expected = 43 + assertEquals(obtained, expected) + } + +} + + From e74aff3d923aafe20ee385e6d1db72acbbc34bc4 Mon Sep 17 00:00:00 2001 From: hmf Date: Sun, 24 Apr 2022 11:27:13 +0100 Subject: [PATCH 13/25] Issue getting file URLs --- build.sc | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/build.sc b/build.sc index 977106c..1b9d1b4 100644 --- a/build.sc +++ b/build.sc @@ -108,9 +108,9 @@ trait OpenJFX extends JavaModule { * @see https://github.com/com-lihaoyi/mill/pull/775 (commit ab4d61a) * @return OS specific resolution mapping */ - override def resolutionCustomizer: Task[Option[Resolution => Resolution]] = T.task { - Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) - } + // override def resolutionCustomizer: Task[Option[Resolution => Resolution]] = T.task { + // Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) + // } val pathSeparator= File.pathSeparator @@ -428,7 +428,7 @@ os.name -> Linux ,! async { // TODO: testing - val resolve = Resolve() + val resolveWin = Resolve() //.noMirrors //.withCache(cache) // .withResolutionParams( @@ -446,34 +446,55 @@ os.name -> Linux ,! .withResolutionParams( ResolutionParams() .withOsInfo { - // macOSx64 - // linuxX64 winX64 } + //.withJdkVersion("1.8.0_121") + ) + + val resolveMAc = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() .withOsInfo { macOSx64 - // linuxX64 - // winX64 } //.withJdkVersion("1.8.0_121") ) - // val deps = Seq( - // dep"org.bytedeco:mkl-platform:2019.5-1.5.2", - // dep"org.bytedeco:mkl-platform-redist:2019.5-1.5.2" - // ) val deps = javaFXModules - val res = await { - resolve + val resWin: Resolution = await { + resolveWin .addDependencies(deps: _*) .future() } - //await(validateDependencies(res)) + val resMac: Resolution = await { + resolveWin + .addDependencies(deps: _*) + .future() + } + + + val urls1 = resWin.dependencyArtifacts().map(_._3.url).toSet + println("?????????????????????????????") + println(urls1.mkString("\n,?")) - val urls = res.dependencyArtifacts().map(_._3.url).toSet + val urls2 = resMac.dependencyArtifacts().map(_._3.url).toSet println("?????????????????????????????") - println(urls.mkString("\n,?")) + println(urls2.mkString("\n,?")) } // // Extra OpenFX library From 4a92952469f73b921d3474a2b9089727fcc16b70 Mon Sep 17 00:00:00 2001 From: hmf Date: Sun, 24 Apr 2022 12:35:35 +0100 Subject: [PATCH 14/25] build.sc target allOS can now fetch for Mac and Win --- .bloop/bloop.settings.json | 23 ------ build.sc | 149 ++++++++++++++++++++++++------------- 2 files changed, 97 insertions(+), 75 deletions(-) delete mode 100644 .bloop/bloop.settings.json diff --git a/.bloop/bloop.settings.json b/.bloop/bloop.settings.json deleted file mode 100644 index bd7b5a7..0000000 --- a/.bloop/bloop.settings.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "javaSemanticDBVersion": "0.7.4", - "semanticDBVersion": "4.5.0", - "supportedScalaVersions": [ - "2.13.8", - "2.12.15", - "2.12.14", - "2.12.13", - "2.12.12", - "2.12.11", - "2.13.5", - "2.13.6", - "2.13.7", - "2.11.12", - "2.12.8", - "2.12.9", - "2.12.10", - "2.13.1", - "2.13.2", - "2.13.3", - "2.13.4" - ] -} \ No newline at end of file diff --git a/build.sc b/build.sc index 1b9d1b4..d50a78c 100644 --- a/build.sc +++ b/build.sc @@ -6,11 +6,25 @@ import mill._ import mill.api.Loose import mill.define.{Target, Task} import scalalib._ + import java.io.File +import scala.concurrent.{Await, ExecutionContext} +import scala.concurrent.duration.Duration +import coursier.cache.{Cache, FileCache} +import coursier.core.Publication +import coursier.error.CoursierError +import coursier.internal.FetchCache +import coursier.params.{Mirror, ResolutionParams} +import coursier.util.{Artifact, Sync, Task => CTask} +import coursier.util.Monad.ops._ + +import scala.concurrent.duration.Duration +import scala.concurrent.{Await, ExecutionContext, Future} val ScalaVersion = "3.1.1" -import $ivy.`org.scala-lang.modules::scala-async:0.10.0` +import $ivy.`org.scala-lang.modules::scala-async:0.10.0` +//import $ivy.`org.scala-lang.modules:scala-async_2.12:1.0.1` // libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.10.0" // libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided @@ -108,9 +122,9 @@ trait OpenJFX extends JavaModule { * @see https://github.com/com-lihaoyi/mill/pull/775 (commit ab4d61a) * @return OS specific resolution mapping */ - // override def resolutionCustomizer: Task[Option[Resolution => Resolution]] = T.task { - // Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) - // } + override def resolutionCustomizer: Task[Option[Resolution => Resolution]] = T.task { + Some((_: coursier.core.Resolution).withOsInfo(coursier.core.Activation.Os.fromProperties(sys.props.toMap))) + } val pathSeparator= File.pathSeparator @@ -317,6 +331,9 @@ object allOS extends OpenJFX with ScalaModule { override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") + override def ivyDeps = Agg( ivy"org.scala-lang.modules:scala-async_2.12:1.0.1" ) + //override def ivyDeps = Agg( ivy"org.scala-lang.modules::scala-async:1.0.1" ) + /** * Here we manually download the modules' jars. No need to install them * separately in the OS. This allows us to determine the paths to the @@ -340,7 +357,6 @@ object allOS extends OpenJFX with ScalaModule { import coursier.params.{MavenMirror, Mirror, ResolutionParams, TreeMirror} import coursier.util.ModuleMatchers - import scala.async.Async.{async, await} import scala.collection.compat._ @@ -426,53 +442,59 @@ os.name -> Linux ,! None ) +// def run()(implicit ec: ExecutionContext = fetch.resolve.cache.ec): Seq[File] = { +// val f = fetch.io.future() +// Await.result(f, Duration.Inf) +// } + + // TODO: testing + val resolveWin = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + winX64 + } + //.withJdkVersion("1.8.0_121") + ) + + val resolveMac = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + macOSx64 + } + //.withJdkVersion("1.8.0_121") + ) + async { - // TODO: testing - val resolveWin = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) - .withResolutionParams( - ResolutionParams() - .withOsInfo { - winX64 - } - //.withJdkVersion("1.8.0_121") - ) - - val resolveMAc = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) - .withResolutionParams( - ResolutionParams() - .withOsInfo { - macOSx64 - } - //.withJdkVersion("1.8.0_121") - ) val deps = javaFXModules val resWin: Resolution = await { @@ -482,7 +504,7 @@ os.name -> Linux ,! } val resMac: Resolution = await { - resolveWin + resolveMac .addDependencies(deps: _*) .future() } @@ -497,6 +519,29 @@ os.name -> Linux ,! println(urls2.mkString("\n,?")) } +// val filesWin = Fetch() +// .addDependencies(javaFXModules: _*) +// .withResolve(resolveWin) +// .addArtifactTypes(Type.all) +// .run() +// .toSet + val filesWin = Fetch().addDependencies(javaFXModules: _*) + .withResolutionParams( ResolutionParams().withOsInfo{ winX64 }) + .addArtifactTypes(Type.all).run().toSet +// println(filesWin.mkString(", AA\n")) + + //val filesMac = Fetch().withResolve(resolveMac).addArtifactTypes(Type.all).run().toSet + val filesMac = Fetch() + .addDependencies(javaFXModules: _*) + .withResolutionParams( ResolutionParams().withOsInfo{ macOSx64 }) + .addArtifactTypes(Type.all) + .run() + .toSet + val allOS = filesWin ++ filesMac + println("1111111111111111111111111111111") + println(allOS.mkString(", VV\n")) + println("2222222222222222222222222222222 ") + // // Extra OpenFX library // // Coursier: only a single String literal is allowed here, so cannot decouple version // //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" From 2ef84e08abd586bac9ac1acb8bc94a65a07cded4 Mon Sep 17 00:00:00 2001 From: hmf Date: Sun, 24 Apr 2022 12:57:15 +0100 Subject: [PATCH 15/25] build.sc checks all OS and only adds missing ones --- build.sc | 75 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/build.sc b/build.sc index d50a78c..e7b7c5a 100644 --- a/build.sc +++ b/build.sc @@ -374,6 +374,8 @@ object allOS extends OpenJFX with ScalaModule { Seq(controlsFXModule) println(sys.props.toMap.mkString(" ,!\n")) + val props = sys.props.toMap + val osName = props("os.name") /* sun.os.patch.level -> unknown ,! os.arch -> amd64 ,! @@ -431,21 +433,17 @@ os.name -> Linux ,! val winX64 =Activation.Os( Some("x86_64"), Set("windows"), - None, + Some("windows"), None ) val linuxX64 =Activation.Os( Some("x86_64"), Set("unix"), - Some("linux"), + Some("Linux"), None ) -// def run()(implicit ec: ExecutionContext = fetch.resolve.cache.ec): Seq[File] = { -// val f = fetch.io.future() -// Await.result(f, Duration.Inf) -// } // TODO: testing val resolveWin = Resolve() @@ -510,34 +508,47 @@ os.name -> Linux ,! } - val urls1 = resWin.dependencyArtifacts().map(_._3.url).toSet - println("?????????????????????????????") - println(urls1.mkString("\n,?")) - - val urls2 = resMac.dependencyArtifacts().map(_._3.url).toSet - println("?????????????????????????????") - println(urls2.mkString("\n,?")) +// val urls1 = resWin.dependencyArtifacts().map(_._3.url).toSet +// println("?????????????????????????????") +// println(urls1.mkString("\n,?")) +// +// val urls2 = resMac.dependencyArtifacts().map(_._3.url).toSet +// println("?????????????????????????????") +// println(urls2.mkString("\n,?")) } -// val filesWin = Fetch() -// .addDependencies(javaFXModules: _*) -// .withResolve(resolveWin) -// .addArtifactTypes(Type.all) -// .run() -// .toSet - val filesWin = Fetch().addDependencies(javaFXModules: _*) - .withResolutionParams( ResolutionParams().withOsInfo{ winX64 }) - .addArtifactTypes(Type.all).run().toSet -// println(filesWin.mkString(", AA\n")) - - //val filesMac = Fetch().withResolve(resolveMac).addArtifactTypes(Type.all).run().toSet - val filesMac = Fetch() - .addDependencies(javaFXModules: _*) - .withResolutionParams( ResolutionParams().withOsInfo{ macOSx64 }) - .addArtifactTypes(Type.all) - .run() - .toSet - val allOS = filesWin ++ filesMac + val filesWin = + if (osName != winX64.name.get) { + Fetch() + .addDependencies(javaFXModules: _*) + .withResolutionParams( ResolutionParams().withOsInfo{ winX64 }) + .addArtifactTypes(Type.all) + .run() + .toSet + } else Set() + + val filesMac = + if (osName != macOSx64.name.get) { + Fetch() + .addDependencies(javaFXModules: _*) + .withResolutionParams(ResolutionParams().withOsInfo { macOSx64 }) + .addArtifactTypes(Type.all) + .run() + .toSet + } else Set() + + val filesLinux = + if (osName != linuxX64.name.get) { + println(s"OS NAME --------------------- $osName") + Fetch() + .addDependencies(javaFXModules: _*) + .withResolutionParams(ResolutionParams().withOsInfo { linuxX64 }) + .addArtifactTypes(Type.all) + .run() + .toSet + } else Set() + + val allOS = filesWin ++ filesMac ++ filesLinux println("1111111111111111111111111111111") println(allOS.mkString(", VV\n")) println("2222222222222222222222222222222 ") From da390ace3c82e77c7464f97d7f60d8ae4f7bdbfa Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 25 Apr 2022 11:23:40 +0100 Subject: [PATCH 16/25] build.sc osAll has task to show native paths for debugging --- build.sc | 376 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 199 insertions(+), 177 deletions(-) diff --git a/build.sc b/build.sc index e7b7c5a..4169cdc 100644 --- a/build.sc +++ b/build.sc @@ -1,7 +1,7 @@ // cSpell:ignore scalalib, helloworld, coursier, Deps, unmanaged, classpath // cSpell:ignore javafx, controlsfx, openjfx -import coursier.core.Resolution +import coursier.{Dependency, Module, ModuleName, Resolve} import mill._ import mill.api.Loose import mill.define.{Target, Task} @@ -11,7 +11,7 @@ import java.io.File import scala.concurrent.{Await, ExecutionContext} import scala.concurrent.duration.Duration import coursier.cache.{Cache, FileCache} -import coursier.core.Publication +import coursier.core.Resolution import coursier.error.CoursierError import coursier.internal.FetchCache import coursier.params.{Mirror, ResolutionParams} @@ -23,11 +23,6 @@ import scala.concurrent.{Await, ExecutionContext, Future} val ScalaVersion = "3.1.1" -import $ivy.`org.scala-lang.modules::scala-async:0.10.0` -//import $ivy.`org.scala-lang.modules:scala-async_2.12:1.0.1` -// libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.10.0" -// libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % Provided - //val javaFXVersion = "11.0.2" //val javaFXVersion = "12" //val javaFXVersion = "13.0.2" @@ -331,9 +326,130 @@ object allOS extends OpenJFX with ScalaModule { override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") - override def ivyDeps = Agg( ivy"org.scala-lang.modules:scala-async_2.12:1.0.1" ) + // TODO: remove + //override def ivyDeps = Agg( ivy"org.scala-lang.modules:scala-async_2.12:1.0.1" ) //override def ivyDeps = Agg( ivy"org.scala-lang.modules::scala-async:1.0.1" ) + import coursier._ + import coursier.parse.DependencyParser + import coursier.core.{Activation, Publication, Resolution} + + val macOSx64 =Activation.Os( + Some("x86_64"), // same as amd64 or x86-64 + Set("mac", "unix"), + Some("mac os x"), + None + ) + + /* + + val windowsOs = core.Activation.Os.fromProperties(Map( + "os.name" -> "Windows 10", + "os.arch" -> "amd64", + "os.version" -> "10.0", + "path.separator" -> ";" + )) + + */ + val winX64 =Activation.Os( + Some("x86_64"), + Set("windows"), + Some("windows"), + None + ) + + /* + .withOsInfo(coursier.core.Activation.Os.fromProperties(Map( + "os.name" -> "Linux", + "os.arch" -> "amd64", + "os.version" -> "4.9.125", + "path.separator" -> ":" + )))) + + OS( arch : scala.Option[_root_.scala.Predef.String], + families : _root_.scala.Predef.Set[_root_.scala.Predef.String], + name : scala.Option[_root_.scala.Predef.String], + version : scala.Option[_root_.scala.Predef.String]) : coursier.core.Activation.Os = + val current = coursier.core.Activation.Os.fromProperties(sys.props.toMap) + Os(Some(amd64), HashSet(unix), Some(linux), Some(5.13.0-40-generic)) + */ + val linuxX64 =Activation.Os( + Some("x86_64"), + Set("unix"), + Some("linux"), + None + ) + + // TODO: testing + val resolveWin = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + winX64 + } + //.withJdkVersion("1.8.0_121") + ) + + val resolveMac = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + macOSx64 + } + //.withJdkVersion("1.8.0_121") + ) + + val resolveLinux = Resolve() + //.noMirrors + //.withCache(cache) + // .withResolutionParams( + // ResolutionParams() + // .withOsInfo { + // Activation.Os( + // Some("x86_64"), + // Set("mac", "unix"), + // Some("mac os x"), + // Some("10.15.1") + // ) + // } + // //.withJdkVersion("1.8.0_121") + // ) + .withResolutionParams( + ResolutionParams() + .withOsInfo { + linuxX64 + } + //.withJdkVersion("1.8.0_121") + ) + /** * Here we manually download the modules' jars. No need to install them * separately in the OS. This allows us to determine the paths to the @@ -348,8 +464,6 @@ object allOS extends OpenJFX with ScalaModule { * @see https://github.com/com-lihaoyi/mill/discussions/1842 */ override def unmanagedClasspath: Target[Loose.Agg[PathRef]] = T{ - import coursier._ - import coursier.parse.DependencyParser import coursier.core.{Activation, Configuration, Extension, Reconciliation} import coursier.error.ResolutionError @@ -357,10 +471,11 @@ object allOS extends OpenJFX with ScalaModule { import coursier.params.{MavenMirror, Mirror, ResolutionParams, TreeMirror} import coursier.util.ModuleMatchers - import scala.async.Async.{async, await} - import scala.collection.compat._ + //implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global - implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global + // Get the name of the current (host) OS + val props = sys.props.toMap + val osName = props("os.name") // Extra OpenFX library // Coursier: only a single String literal is allowed here, so cannot decouple version @@ -373,150 +488,6 @@ object allOS extends OpenJFX with ScalaModule { ) ++ Seq(controlsFXModule) - println(sys.props.toMap.mkString(" ,!\n")) - val props = sys.props.toMap - val osName = props("os.name") - /* -sun.os.patch.level -> unknown ,! -os.arch -> amd64 ,! -os.version -> 5.13.0-40-generic ,! -jna.nosys -> true ,! -os.name -> Linux ,! -*/ - -/* - .withOsInfo(coursier.core.Activation.Os.fromProperties(Map( - "os.name" -> "Linux", - "os.arch" -> "amd64", - "os.version" -> "4.9.125", - "path.separator" -> ":" - )))) -*/ - -// https://github.com/coursier/coursier/blob/a213c20099dcf8df24af317479945c5f90ac5563/modules/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala -/* - - val windowsOs = core.Activation.Os.fromProperties(Map( - "os.name" -> "Windows 10", - "os.arch" -> "amd64", - "os.version" -> "10.0", - "path.separator" -> ";" - )) - -*/ - -// https://github.com/coursier/coursier/blob/a213c20099dcf8df24af317479945c5f90ac5563/modules/core/shared/src/main/scala/coursier/core/Activation.scala - -/* - arch: Option[String], - families: Set[String], - name: Option[String], - version: Option[String] - - private val standardFamilies = Set( - "windows", - "os/2", - "netware", - "mac", - "os/400", - "openvms" - ) - */ - - val macOSx64 =Activation.Os( - Some("x86_64"), // same as amd64 or x86-64 - Set("mac", "unix"), - Some("mac os x"), - None - ) - - val winX64 =Activation.Os( - Some("x86_64"), - Set("windows"), - Some("windows"), - None - ) - - val linuxX64 =Activation.Os( - Some("x86_64"), - Set("unix"), - Some("Linux"), - None - ) - - - // TODO: testing - val resolveWin = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) - .withResolutionParams( - ResolutionParams() - .withOsInfo { - winX64 - } - //.withJdkVersion("1.8.0_121") - ) - - val resolveMac = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) - .withResolutionParams( - ResolutionParams() - .withOsInfo { - macOSx64 - } - //.withJdkVersion("1.8.0_121") - ) - - async { - - val deps = javaFXModules - val resWin: Resolution = await { - resolveWin - .addDependencies(deps: _*) - .future() - } - - val resMac: Resolution = await { - resolveMac - .addDependencies(deps: _*) - .future() - } - - -// val urls1 = resWin.dependencyArtifacts().map(_._3.url).toSet -// println("?????????????????????????????") -// println(urls1.mkString("\n,?")) -// -// val urls2 = resMac.dependencyArtifacts().map(_._3.url).toSet -// println("?????????????????????????????") -// println(urls2.mkString("\n,?")) - } - val filesWin = if (osName != winX64.name.get) { Fetch() @@ -539,7 +510,6 @@ os.name -> Linux ,! val filesLinux = if (osName != linuxX64.name.get) { - println(s"OS NAME --------------------- $osName") Fetch() .addDependencies(javaFXModules: _*) .withResolutionParams(ResolutionParams().withOsInfo { linuxX64 }) @@ -549,21 +519,7 @@ os.name -> Linux ,! } else Set() val allOS = filesWin ++ filesMac ++ filesLinux - println("1111111111111111111111111111111") - println(allOS.mkString(", VV\n")) - println("2222222222222222222222222222222 ") - - // // Extra OpenFX library - // // Coursier: only a single String literal is allowed here, so cannot decouple version - // //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" - // val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" - - // // Generate the dependencies - // val javaFXModules = javaFXModuleNames.map( - // m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) - // ) ++ - // Seq(controlsFXModule) - // Check if the libraries exist and download if they don't + val files = Fetch() .addDependencies(javaFXModules: _*) .addArtifactTypes(Type.all) @@ -573,10 +529,76 @@ os.name -> Linux ,! Agg(pathRefs : _*) } - object test extends Tests { - override def ivyDeps = Agg(ivyMunit) - override def testFramework = ivyMunitInterface - } + def osClasspath/*: Target[Loose.Agg[PathRef]]*/ = T{ + implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global + + import scala.async.Async.{async, await} + import scala.collection.compat._ + + // Extra OpenFX library + // Coursier: only a single String literal is allowed here, so cannot decouple version + //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" + val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" + + val current = coursier.core.Activation.Os.fromProperties(sys.props.toMap) + println(s"Curremt ---------------> $current") + + // Generate the dependencies + val javaFXModules = javaFXModuleNames.map( + m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) + ) ++ + Seq(controlsFXModule) + + val deps = javaFXModules + val resWin: Future[Resolution] = + resolveWin + .addDependencies(deps: _*) + .future() + val resMac: Future[Resolution] = + resolveMac + .addDependencies(deps: _*) + .future() + val resLinux: Future[Resolution] = + resolveLinux + .addDependencies(deps: _*) + .future() + val res = Future.sequence( List(resWin, resMac, resLinux) ) + val result = Await.result(res, Duration.Inf) + val urls = result.map(_.dependencyArtifacts().map(_._3.url).toSet).reduceLeft((acc,s) => acc ++ s) +// println("?????????????????????????????") +// println(urls.mkString("\n,?")) + +// val t = async { +// val deps = javaFXModules +// val resWin: Resolution = await { +// resolveWin +// .addDependencies(deps: _*) +// .future() +// } +// val resMac: Resolution = await { +// resolveMac +// .addDependencies(deps: _*) +// .future() +// } +// +// val urls1 = resWin.dependencyArtifacts().map(_._3.url).toSet +// println("?????????????????????????????") +// println(urls1.mkString("\n,?")) +// +// val urls2 = resMac.dependencyArtifacts().map(_._3.url).toSet +// println("?????????????????????????????") +// println(urls2.mkString("\n,?")) +// +// urls1 ++ urls2 +// } + + urls + } + + object test extends Tests { + override def ivyDeps = Agg(ivyMunit) + override def testFramework = ivyMunitInterface + } } From 79d6f20af5390d2dd85afbb3d1d5d59536adad3b Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 25 Apr 2022 12:16:40 +0100 Subject: [PATCH 17/25] build.sc osAll has task does no automatically inckude the managed libraries --- build.sc | 247 +++++++++++++++++++++++-------------------------------- 1 file changed, 104 insertions(+), 143 deletions(-) diff --git a/build.sc b/build.sc index 4169cdc..47fd0b3 100644 --- a/build.sc +++ b/build.sc @@ -301,23 +301,14 @@ object unmanaged extends OpenJFX with ScalaModule { /** - * When working with JavaFX/OpenFX in JDK 1.9 and later, the libraries are - * not included in the JDK. They may be installed manually in the OS or - * automatically via Mill. The latter method has the advantage of acquiring - * the paths of the libraries automatically and also setting up build the file - * automatically. The easiest way to do this is to to use Mill's automatic - * library dependency management (see #775# link below). Here we exemplify the - * use of Mill's unmanaged library dependency setup. Any other libraries - * may still be used via Mill's managed library setup. - * - * Note that in the case of the JavaFX libraries we must use/set the JVM's - * parameters to include the module path and module names. Other libraries, even - * though provided as module may not require this. Most of the JVM parameter - * set-up is automatic. It also allows to set-up module visibility and even - * overriding certain modules on boot-up. This allows for example the use the - * TestFX for use in headless UI testing. + * This module show how one can download the native OS binaries for multiple + * operating systems. This allows one to create "fat" Jars so that the resulting + * application is cross platform. In other words it supports multple plartforms. + * Be aware that this signficiantly increases the applicaton's size. + * Alterantivelly use something like Coursier to make your application available. * - * @see https://github.com/com-lihaoyi/mill/pull/775#issuecomment-826091576 + * @see https://get-coursier.io/ + * https://github.com/coursier/coursier */ object allOS extends OpenJFX with ScalaModule { @@ -326,14 +317,14 @@ object allOS extends OpenJFX with ScalaModule { override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") - // TODO: remove - //override def ivyDeps = Agg( ivy"org.scala-lang.modules:scala-async_2.12:1.0.1" ) - //override def ivyDeps = Agg( ivy"org.scala-lang.modules::scala-async:1.0.1" ) + override def ivyDeps = Agg( ivy"$CONTROLSFX" ) import coursier._ - import coursier.parse.DependencyParser - import coursier.core.{Activation, Publication, Resolution} + import coursier.core.{Activation, Resolution} + /** + * Resolution parameter for macOS operating system + */ val macOSx64 =Activation.Os( Some("x86_64"), // same as amd64 or x86-64 Set("mac", "unix"), @@ -341,16 +332,20 @@ object allOS extends OpenJFX with ScalaModule { None ) - /* - - val windowsOs = core.Activation.Os.fromProperties(Map( - "os.name" -> "Windows 10", - "os.arch" -> "amd64", - "os.version" -> "10.0", - "path.separator" -> ";" - )) - - */ + /** + * Resolution parameter for Windows operating system. + * Alternate form of defining this parameter: + * + * {{ + * val windowsOs = core.Activation.Os.fromProperties(Map( + * "os.name" -> "Windows 10", + * "os.arch" -> "amd64", + * "os.version" -> "10.0", + * "path.separator" -> ";" + * )) + * }} + * + */ val winX64 =Activation.Os( Some("x86_64"), Set("windows"), @@ -358,21 +353,34 @@ object allOS extends OpenJFX with ScalaModule { None ) - /* - .withOsInfo(coursier.core.Activation.Os.fromProperties(Map( - "os.name" -> "Linux", - "os.arch" -> "amd64", - "os.version" -> "4.9.125", - "path.separator" -> ":" - )))) - - OS( arch : scala.Option[_root_.scala.Predef.String], - families : _root_.scala.Predef.Set[_root_.scala.Predef.String], - name : scala.Option[_root_.scala.Predef.String], - version : scala.Option[_root_.scala.Predef.String]) : coursier.core.Activation.Os = - val current = coursier.core.Activation.Os.fromProperties(sys.props.toMap) - Os(Some(amd64), HashSet(unix), Some(linux), Some(5.13.0-40-generic)) - */ + /** + * Resolution parameter for Windows operating system. + * Alternate form of defining this parameter: + * + * {{ + * val windowsOs = coursier.core.Activation.Os.fromProperties(Map( + * "os.name" -> "Linux", + * "os.arch" -> "amd64", + * "os.version" -> "4.9.125", + * "path.separator" -> ":" + * )) + * }} + * + * [[coursier.core.Activation.Os]] defintion: + * OS( arch : Option[String], + * families : Set[String], + * name : Option[String], + * version : Option[String]) : + * + * Determining the full OS member values: + * + * {{ + * val current = coursier.core.Activation.Os.fromProperties(sys.props.toMap) + * }} + * + * Output example: + * Os(Some(amd64), HashSet(unix), Some(linux), Some(5.13.0-40-generic)) + */ val linuxX64 =Activation.Os( Some("x86_64"), Set("unix"), @@ -380,74 +388,58 @@ object allOS extends OpenJFX with ScalaModule { None ) - // TODO: testing + /** + * Setup the Ivy resolution for the Maven artifacts for windows. + * Here is an example for MacOS: + * + * {{ + * val resolveMac = Resolve() + * .noMirrors + * .withCache(cache) + * .withResolutionParams( + * ResolutionParams() + * .withOsInfo { + * Activation.Os( + * Some("x86_64"), + * Set("mac", "unix"), + * Some("mac os x"), + * Some("10.15.1") + * ) + * } + * .withJdkVersion("1.8.0_121") + * ) + * }} + * + * + */ val resolveWin = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) .withResolutionParams( ResolutionParams() .withOsInfo { winX64 } - //.withJdkVersion("1.8.0_121") ) + /** + * Setup the Ivy resolution for the Maven artifacts for MacOS. + */ val resolveMac = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) .withResolutionParams( ResolutionParams() .withOsInfo { macOSx64 } - //.withJdkVersion("1.8.0_121") ) + /** + * Setup the Ivy resolution for the Maven artifacts for Linux. + */ val resolveLinux = Resolve() - //.noMirrors - //.withCache(cache) - // .withResolutionParams( - // ResolutionParams() - // .withOsInfo { - // Activation.Os( - // Some("x86_64"), - // Set("mac", "unix"), - // Some("mac os x"), - // Some("10.15.1") - // ) - // } - // //.withJdkVersion("1.8.0_121") - // ) .withResolutionParams( ResolutionParams() .withOsInfo { linuxX64 } - //.withJdkVersion("1.8.0_121") ) /** @@ -465,17 +457,12 @@ object allOS extends OpenJFX with ScalaModule { */ override def unmanagedClasspath: Target[Loose.Agg[PathRef]] = T{ - import coursier.core.{Activation, Configuration, Extension, Reconciliation} - import coursier.error.ResolutionError - import coursier.ivy.IvyRepository - import coursier.params.{MavenMirror, Mirror, ResolutionParams, TreeMirror} - import coursier.util.ModuleMatchers - - //implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global + import coursier.params.ResolutionParams // Get the name of the current (host) OS - val props = sys.props.toMap - val osName = props("os.name") + //val props = sys.props.toMap + //val osName = props("os.name") + val osName = coursier.core.Activation.Os.fromProperties(sys.props.toMap).name.get // Extra OpenFX library // Coursier: only a single String literal is allowed here, so cannot decouple version @@ -488,6 +475,7 @@ object allOS extends OpenJFX with ScalaModule { ) ++ Seq(controlsFXModule) + // Setup resolution Windows downloads (if not current OS) val filesWin = if (osName != winX64.name.get) { Fetch() @@ -496,8 +484,9 @@ object allOS extends OpenJFX with ScalaModule { .addArtifactTypes(Type.all) .run() .toSet - } else Set() + } else Set[File]() + // Setup resolution MacOS downloads (if not current OS) val filesMac = if (osName != macOSx64.name.get) { Fetch() @@ -506,21 +495,24 @@ object allOS extends OpenJFX with ScalaModule { .addArtifactTypes(Type.all) .run() .toSet - } else Set() + } else Set[File]() + // Setup resolution Linux downloads (if not current OS) val filesLinux = if (osName != linuxX64.name.get) { + println(s"?????????????????????????????????????? $osName == ${linuxX64.name.get} !!!!!!!!!!!!!!!!!!!!!!!!") Fetch() .addDependencies(javaFXModules: _*) .withResolutionParams(ResolutionParams().withOsInfo { linuxX64 }) .addArtifactTypes(Type.all) .run() .toSet - } else Set() + } else Set[File]() val allOS = filesWin ++ filesMac ++ filesLinux + val files = allOS.toSeq - val files = Fetch() + val filesx = Fetch() .addDependencies(javaFXModules: _*) .addArtifactTypes(Type.all) .run() @@ -529,20 +521,15 @@ object allOS extends OpenJFX with ScalaModule { Agg(pathRefs : _*) } - def osClasspath/*: Target[Loose.Agg[PathRef]]*/ = T{ + def osClasspath: Target[Seq[String]] = T{ implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global - import scala.async.Async.{async, await} - import scala.collection.compat._ - // Extra OpenFX library // Coursier: only a single String literal is allowed here, so cannot decouple version //val controlsFXModuleName = s"org.controlsfx:controlsfx:$controlsFXVersion" val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" val current = coursier.core.Activation.Os.fromProperties(sys.props.toMap) - println(s"Curremt ---------------> $current") - // Generate the dependencies val javaFXModules = javaFXModuleNames.map( m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) @@ -558,41 +545,15 @@ object allOS extends OpenJFX with ScalaModule { resolveMac .addDependencies(deps: _*) .future() - val resLinux: Future[Resolution] = + val resLinux: Future[Resolution] = resolveLinux .addDependencies(deps: _*) .future() - val res = Future.sequence( List(resWin, resMac, resLinux) ) - val result = Await.result(res, Duration.Inf) - val urls = result.map(_.dependencyArtifacts().map(_._3.url).toSet).reduceLeft((acc,s) => acc ++ s) -// println("?????????????????????????????") -// println(urls.mkString("\n,?")) - -// val t = async { -// val deps = javaFXModules -// val resWin: Resolution = await { -// resolveWin -// .addDependencies(deps: _*) -// .future() -// } -// val resMac: Resolution = await { -// resolveMac -// .addDependencies(deps: _*) -// .future() -// } -// -// val urls1 = resWin.dependencyArtifacts().map(_._3.url).toSet -// println("?????????????????????????????") -// println(urls1.mkString("\n,?")) -// -// val urls2 = resMac.dependencyArtifacts().map(_._3.url).toSet -// println("?????????????????????????????") -// println(urls2.mkString("\n,?")) -// -// urls1 ++ urls2 -// } - - urls + val res = Future.sequence( List(resWin, resMac, resLinux) ) + val result = Await.result(res, Duration.Inf) + val urls = result.map(_.dependencyArtifacts().map(_._3.url).toSet).reduceLeft((acc,s) => acc ++ s) + + s"Current = $current" :: urls.toList } object test extends Tests { From f3522e9b560e221dc703d002b78e0c5b06969644 Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 25 Apr 2022 12:20:05 +0100 Subject: [PATCH 18/25] build.sc osAll has task now automatically inckudes the managed libraries --- build.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sc b/build.sc index 47fd0b3..b4a26bc 100644 --- a/build.sc +++ b/build.sc @@ -317,7 +317,7 @@ object allOS extends OpenJFX with ScalaModule { override def mainClass: T[Option[String]] = Some("helloworld.HelloWorld") - override def ivyDeps = Agg( ivy"$CONTROLSFX" ) + override def ivyDeps = Agg( ivy"$CONTROLS", ivy"$CONTROLSFX" ) import coursier._ import coursier.core.{Activation, Resolution} From 50fbe8c112c9d3977a3788d2856234cd0d800162 Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 25 Apr 2022 16:13:04 +0100 Subject: [PATCH 19/25] build.sc osAll task correted - forkArgs renoves unused native OS. --- allOS/src/button/ButtonApp.scala | 4 +-- allOS/src/button/Main.scala | 6 ++-- allOS/src/helloworld/HelloWorld.scala | 6 ++-- build.sc | 46 ++++++++++++++++++++------- 4 files changed, 43 insertions(+), 19 deletions(-) diff --git a/allOS/src/button/ButtonApp.scala b/allOS/src/button/ButtonApp.scala index 9fac74c..680ff32 100644 --- a/allOS/src/button/ButtonApp.scala +++ b/allOS/src/button/ButtonApp.scala @@ -20,8 +20,8 @@ class ButtonApp extends Application { stage.show() } - def launchIt():Unit={ - Application.launch() + def launchIt(args: Array[String]):Unit={ + Application.launch(args:_*) } } \ No newline at end of file diff --git a/allOS/src/button/Main.scala b/allOS/src/button/Main.scala index f153f13..0b79b22 100644 --- a/allOS/src/button/Main.scala +++ b/allOS/src/button/Main.scala @@ -4,14 +4,14 @@ package button * * ./mill mill.scalalib.GenIdea/idea * - * ./mill -i unmanaged.runMain button.Main - * ./mill -i --watch unmanaged.runMain button.Main + * ./mill -i allOS.runMain button.Main + * ./mill -i --watch allOS.runMain button.Main * * @see https://stackoverflow.com/questions/12124657/getting-started-on-scala-javafx-desktop-application-development */ object Main { def main(args: Array[String]) = val app = new ButtonApp - app.launchIt() + app.launchIt(args) } \ No newline at end of file diff --git a/allOS/src/helloworld/HelloWorld.scala b/allOS/src/helloworld/HelloWorld.scala index 353a665..df87521 100644 --- a/allOS/src/helloworld/HelloWorld.scala +++ b/allOS/src/helloworld/HelloWorld.scala @@ -14,9 +14,9 @@ import javafx.stage.Stage * * ./mill mill.scalalib.GenIdea/idea * - * ./mill -i unmanaged.run - * ./mill -i unmanaged.runMain helloworld.HelloWorld - * ./mill -i --watch unmanaged.run + * ./mill -i allOS.run + * ./mill -i allOS.runMain helloworld.HelloWorld + * ./mill -i --watch allOS.run * * @see https://stackoverflow.com/questions/12124657/getting-started-on-scala-javafx-desktop-application-development */ diff --git a/build.sc b/build.sc index b4a26bc..1c22e7b 100644 --- a/build.sc +++ b/build.sc @@ -32,6 +32,8 @@ val mUnitVersion = "1.0.0-M3" //"0.7.27" val controlsFXVersion = "11.1.0" val hanSoloChartsVersion = "16.0.12" +val ivyMunit = ivy"org.scalameta::munit::$mUnitVersion" +val ivyMunitInterface = "munit.Framework" /** * When working with JavaFX/OpenFX in JDK 1.9 and later, the libraries are @@ -105,9 +107,32 @@ trait OpenJFX extends JavaModule { println(modules) */ - // TODO: after version 0.10.0 iof Mill put test in the managed/unmanaged classes - val ivyMunit = ivy"org.scalameta::munit::$mUnitVersion" - val ivyMunitInterface = "munit.Framework" + // The osAll module downloads these OS native versons of the libraries + val supported = Set("mac", "linux", "win") + // Get the name of the current (host) OS + val osName = coursier.core.Activation.Os.fromProperties(sys.props.toMap).name.get.toLowerCase + // Filter for removing incompatible native OS libraries + // If we have several narive libraries for diffremt OS, JavaFX cannot select the correct one + val tag = osName match { + case "linux" => "linux" + case "mac os x" => "mac" + case "windows" => "win" + } + val remove = supported - tag + + def validOS(artifact: String): Boolean = { + if (supported.exists(s => artifact.contains(s))) { + // Not a native OS Jar for this OS + println(s"?????????????????? => $artifact") + //val t = remove.exists(s => artifact.contains(s)) + val t = artifact.contains( tag ) + println(t) + t + } else { + // Not a native OS Jar + true + } + } /** * In order to use OS specific libraries (such as JavaFX or OpenJFX), we @@ -160,15 +185,17 @@ trait OpenJFX extends JavaModule { Seq(controlsFXModule) // no standard convention, so add it manually // Add to the modules list - Seq( - "--module-path", s.iterator.mkString( pathSeparator ), - "--add-modules", modulesNames.iterator.mkString(","), + val t = Seq( + "--module-path", s.filter( validOS ).iterator.mkString( pathSeparator ), + "--add-modules", modulesNames.iterator.mkString(","), // "javafx.controls,javafx.graphics,javafx.base,org.controlsfx.controls", "--add-exports=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-exports=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", "--add-exports=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls" ) ++ // add standard parameters Seq("-Dprism.verbose = true", "-ea") + println(t.mkString(";\n")) + t } @@ -276,6 +303,7 @@ object unmanaged extends OpenJFX with ScalaModule { val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" // Generate the dependencies + val javaFXModuleNames = Seq( CONTROLS_ ) val javaFXModules = javaFXModuleNames.map( m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) ) ++ @@ -470,6 +498,7 @@ object allOS extends OpenJFX with ScalaModule { val controlsFXModule = dep"org.controlsfx:controlsfx:11.1.0" // Generate the dependencies + val javaFXModuleNames = Seq( CONTROLS_ ) val javaFXModules = javaFXModuleNames.map( m => Dependency(Module(org"org.openjfx", ModuleName(s"javafx-$m")), javaFXVersion) ) ++ @@ -500,7 +529,6 @@ object allOS extends OpenJFX with ScalaModule { // Setup resolution Linux downloads (if not current OS) val filesLinux = if (osName != linuxX64.name.get) { - println(s"?????????????????????????????????????? $osName == ${linuxX64.name.get} !!!!!!!!!!!!!!!!!!!!!!!!") Fetch() .addDependencies(javaFXModules: _*) .withResolutionParams(ResolutionParams().withOsInfo { linuxX64 }) @@ -512,10 +540,6 @@ object allOS extends OpenJFX with ScalaModule { val allOS = filesWin ++ filesMac ++ filesLinux val files = allOS.toSeq - val filesx = Fetch() - .addDependencies(javaFXModules: _*) - .addArtifactTypes(Type.all) - .run() // Return the list of libraries val pathRefs = files.map(f => PathRef(os.Path(f))) Agg(pathRefs : _*) From 6f419f818607548899001bf9b5ba614d41f6ea3b Mon Sep 17 00:00:00 2001 From: hmf Date: Mon, 25 Apr 2022 16:16:35 +0100 Subject: [PATCH 20/25] build.sc osAll task correted - forkArgs renoves unused native OS. --- build.sc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sc b/build.sc index 1c22e7b..937d54c 100644 --- a/build.sc +++ b/build.sc @@ -107,12 +107,12 @@ trait OpenJFX extends JavaModule { println(modules) */ - // The osAll module downloads these OS native versons of the libraries + // The osAll module downloads these OS native versions of the libraries val supported = Set("mac", "linux", "win") // Get the name of the current (host) OS val osName = coursier.core.Activation.Os.fromProperties(sys.props.toMap).name.get.toLowerCase // Filter for removing incompatible native OS libraries - // If we have several narive libraries for diffremt OS, JavaFX cannot select the correct one + // If we have several native libraries for different OS, JavaFX cannot select the correct one val tag = osName match { case "linux" => "linux" case "mac os x" => "mac" From f47351708ef9d8ff28a02480e86a23b72d396140 Mon Sep 17 00:00:00 2001 From: hmf Date: Tue, 26 Apr 2022 13:26:28 +0100 Subject: [PATCH 21/25] Corrceted some typos. --- build.sc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/build.sc b/build.sc index 937d54c..0ed77bd 100644 --- a/build.sc +++ b/build.sc @@ -331,9 +331,9 @@ object unmanaged extends OpenJFX with ScalaModule { /** * This module show how one can download the native OS binaries for multiple * operating systems. This allows one to create "fat" Jars so that the resulting - * application is cross platform. In other words it supports multple plartforms. - * Be aware that this signficiantly increases the applicaton's size. - * Alterantivelly use something like Coursier to make your application available. + * application is cross platform. In other words it supports multiple platforms. + * Be aware that this significantly increases the application's size. + * Alternatively use something like Coursier to make your application available. * * @see https://get-coursier.io/ * https://github.com/coursier/coursier @@ -394,7 +394,7 @@ object allOS extends OpenJFX with ScalaModule { * )) * }} * - * [[coursier.core.Activation.Os]] defintion: + * [[coursier.core.Activation.Os]] definition: * OS( arch : Option[String], * families : Set[String], * name : Option[String], @@ -570,9 +570,9 @@ object allOS extends OpenJFX with ScalaModule { .addDependencies(deps: _*) .future() val resLinux: Future[Resolution] = - resolveLinux - .addDependencies(deps: _*) - .future() + resolveLinux + .addDependencies(deps: _*) + .future() val res = Future.sequence( List(resWin, resMac, resLinux) ) val result = Await.result(res, Duration.Inf) val urls = result.map(_.dependencyArtifacts().map(_._3.url).toSet).reduceLeft((acc,s) => acc ++ s) From dccbcb401f44a08db450c32a1036694f234c6ebd Mon Sep 17 00:00:00 2001 From: hmf Date: Tue, 26 Apr 2022 13:31:55 +0100 Subject: [PATCH 22/25] build.sc osAll.unmanagedClassPath now filters out duplicates. --- build.sc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sc b/build.sc index 0ed77bd..e7ae747 100644 --- a/build.sc +++ b/build.sc @@ -537,7 +537,8 @@ object allOS extends OpenJFX with ScalaModule { .toSet } else Set[File]() - val allOS = filesWin ++ filesMac ++ filesLinux + val deps = resolvedIvyDeps().map(_.path.toIO).iterator.toSet + val allOS = filesWin ++ filesMac ++ filesLinux -- deps val files = allOS.toSeq // Return the list of libraries From 2393c910ae46c5f70da06f712a5d86af181efd2d Mon Sep 17 00:00:00 2001 From: hmf Date: Tue, 26 Apr 2022 13:52:26 +0100 Subject: [PATCH 23/25] build.sc osAll removed debug prints. --- build.sc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build.sc b/build.sc index e7ae747..8fd54cc 100644 --- a/build.sc +++ b/build.sc @@ -123,11 +123,7 @@ trait OpenJFX extends JavaModule { def validOS(artifact: String): Boolean = { if (supported.exists(s => artifact.contains(s))) { // Not a native OS Jar for this OS - println(s"?????????????????? => $artifact") - //val t = remove.exists(s => artifact.contains(s)) - val t = artifact.contains( tag ) - println(t) - t + artifact.contains( tag ) } else { // Not a native OS Jar true @@ -194,7 +190,6 @@ trait OpenJFX extends JavaModule { ) ++ // add standard parameters Seq("-Dprism.verbose = true", "-ea") - println(t.mkString(";\n")) t } From e37a04336a3b8884b220ab9b561edc26feb346e3 Mon Sep 17 00:00:00 2001 From: hmf Date: Tue, 26 Apr 2022 14:34:22 +0100 Subject: [PATCH 24/25] Corrceted some mill `run` comands for allOS. Added headers and some usefull markdown to ideias files. --- allOS/src/button/ButtonApp.scala | 4 ++-- allOS/src/helloworld/HelloWorld.scala | 6 +++--- build.sc | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/allOS/src/button/ButtonApp.scala b/allOS/src/button/ButtonApp.scala index 680ff32..66fe9ad 100644 --- a/allOS/src/button/ButtonApp.scala +++ b/allOS/src/button/ButtonApp.scala @@ -10,13 +10,13 @@ class ButtonApp extends Application { override def start(stage: Stage) = { System.out.println("STARTED un-managed Scala!") - var button = new Button("Please un-managed Scala Click Me!") + var button = new Button("Please allOS Scala 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 an un-managed Scala button") + stage.setTitle("Just an allOS Scala button") stage.show() } diff --git a/allOS/src/helloworld/HelloWorld.scala b/allOS/src/helloworld/HelloWorld.scala index df87521..78457e4 100644 --- a/allOS/src/helloworld/HelloWorld.scala +++ b/allOS/src/helloworld/HelloWorld.scala @@ -23,12 +23,12 @@ import javafx.stage.Stage class HelloWorld extends Application { override def start(primaryStage: Stage) = { - primaryStage.setTitle("Hello un-managed Scala World!") + primaryStage.setTitle("Hello allOS Scala World!") val btn = new Button() - btn.setText("Say 'Hello un-managed Scala World'") + btn.setText("Say 'Hello allOS Scala World'") btn.setOnAction(new EventHandler[ActionEvent]() { override def handle(event: ActionEvent) = { - System.out.println("Hello un-managed Scala World!") + System.out.println("Hello allOS Scala World!") } }) diff --git a/build.sc b/build.sc index 8fd54cc..96a7722 100644 --- a/build.sc +++ b/build.sc @@ -1,5 +1,5 @@ // cSpell:ignore scalalib, helloworld, coursier, Deps, unmanaged, classpath -// cSpell:ignore javafx, controlsfx, openjfx +// cSpell:ignore javafx, controlsfx, openjfx, Dprism import coursier.{Dependency, Module, ModuleName, Resolve} import mill._ From 266bbe1ecc7559ef405ea5eb5e2431d635532afd Mon Sep 17 00:00:00 2001 From: hmf Date: Fri, 29 Apr 2022 16:14:00 +0100 Subject: [PATCH 25/25] Use runIvyDeps --- build.sc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sc b/build.sc index 96a7722..8f6da6c 100644 --- a/build.sc +++ b/build.sc @@ -532,7 +532,7 @@ object allOS extends OpenJFX with ScalaModule { .toSet } else Set[File]() - val deps = resolvedIvyDeps().map(_.path.toIO).iterator.toSet + val deps = resolvedRunIvyDeps().map(_.path.toIO).iterator.toSet val allOS = filesWin ++ filesMac ++ filesLinux -- deps val files = allOS.toSeq