0

I have the next build.gradle script:

plugins {
    id 'application'
    id 'org.openjfx.javafxplugin' version '0.0.8'
    id "org.beryx.jlink" version "2.17.5"
}

group 'com.alcoholics'
version '1.0-SNAPSHOT'

application {
    applicationDefaultJvmArgs =  [
            "--add-opens=javafx.base/com.sun.javafx.runtime=org.controlsfx.controls",
            "--add-opens=javafx.base/com.sun.javafx.collections=org.controlsfx.controls",
            "--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls",
            "--add-opens=javafx.graphics/com.sun.javafx.scene=org.controlsfx.controls",
            "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls",
            "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls",
            "--add-opens=javafx.controls/com.sun.javafx.scene.control=org.controlsfx.controls",
            "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls",
            "--add-opens=javafx.controls/javafx.scene.control.skin=org.controlsfx.controls"
    ]
}

javafx {
    version = '14'
    modules("javafx.controls", "javafx.fxml")
}

jlink {
    options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
    launcher {
        name = 'vodka'
    }
}

mainClassName = 'shitfaced/com.alcoholics.shitfaced.App'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.controlsfx:controlsfx:11.0.1'
    compile 'org.webjars:font-awesome:5.13.0'
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

When I run my app all is ok but on Tasks -> build -> jlink I get:

Error: Two versions of module javafx.base found in /Users/shitfaced/Projects/shitfaced/build/jlinkbase/jlinkjars (javafx-base-14-mac.jar and javafx-base-14-linux.jar)

How can I specify a variant for MacOS in my build.gradle or even to Gradle automatically chose a right library variant for current platform?

Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
  • It searches the specified folder; **remove** the linux one on your mac. Mac is not Linux. Simple as that. – Elliott Frisch Apr 12 '20 at 01:49
  • @ElliottFrisch, libraries are downloaded automatically on build, it's useless to delete linux library variant. – Denis Sologub Apr 12 '20 at 02:33
  • 1
    **That** sounds like a gradle bug. Make sure you have the latest version thereof. If so, it *might* be time to file a bug report. **Alternatively**, try using [Liberica 11.0.6](https://bell-sw.com/pages/java-11.0.6/) (or any other OpenJDK release that *includes* JavaFX in the release). I personally use [SDKMan](https://sdkman.io/) on my mac, and I would install that like `sdk install java 11.0.6.fx-librca` (wait, which version of Java are you targeting and which release are you using)? – Elliott Frisch Apr 12 '20 at 02:42
  • @ElliottFrisch, I use **JDK 14** and **OpenJFX 14** – Denis Sologub Apr 12 '20 at 02:46
  • @ElliottFrisch, thank you for that recommendation if I don't be able to resolve this conflict for my configuration, I'll switch to **Liberica 14**. – Denis Sologub Apr 12 '20 at 02:50
  • 1
    [Liberica 14](https://bell-sw.com/pages/java-14/) (but not the lite version) includes javafx modules. That would be `sdk install java 14.0.0.fx-librca` if using sdkman. Exactly which version did you start with? There are multiple JDK 14 releases. – Elliott Frisch Apr 12 '20 at 02:51
  • @ElliottFrisch, I've installed it using `brew cask install liberica-jdk14-full`. – Denis Sologub Apr 12 '20 at 03:22
  • @ElliottFrisch, thank you very much, it really much easier than my previous configuration – Denis Sologub Apr 12 '20 at 03:39

0 Answers0