bardsoftware / ganttproject

Official GanttProject repository.
http://ganttproject.biz
GNU General Public License v3.0
862 stars 303 forks source link

Cannot choose between the available variants of org.openjfx:javafx-controls:11.0.2 #2523

Closed jiapei100 closed 1 month ago

jiapei100 commented 1 month ago
  1. Working environments:
    ➜  ~ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 24.04 LTS
    Release:    24.04
    Codename:   noble
➜  ~ java --version                     
openjdk 21.0.4 2024-07-16
OpenJDK Runtime Environment (build 21.0.4+7-Ubuntu-1ubuntu224.04)
OpenJDK 64-Bit Server VM (build 21.0.4+7-Ubuntu-1ubuntu224.04, mixed mode, sharing)
➜  ~ kotlin   
Welcome to Kotlin version 2.0.10 (JRE 21.0.4+7-Ubuntu-1ubuntu224.04)
Warning: REPL is not yet compatible with the Kotlin version 2.0.10, using '-language-version 1.9'.
Type :help for help, :quit for quit
>>> 
  1. Modified build.gradle:
import java.nio.file.Files
import java.nio.file.Paths

plugins {
    id "org.jetbrains.kotlin.jvm" version "2.0.10" apply false
}

ext.distBinDir = file('ganttproject-builder/dist-bin')
ext.pluginsDir = file("ganttproject-builder/dist-bin/plugins/base")

def readVersion() {
    return Files.readString(Paths.get(rootProject.projectDir.absolutePath, "ganttproject-builder", "VERSION")).trim()
}
version = System.getenv("VERSION") == null ? readVersion() : System.getenv("VERSION")

// Detect the operating system and architecture
def osDetectedJfxName = detectOs()

// Function to detect the OS and return the correct JavaFX classifier
def detectOs() {
    def osName = System.getProperty("os.name").toLowerCase()
    def arch = System.getProperty("os.arch").toLowerCase()

    if (osName.contains("win")) {
        return "win"
    } else if (osName.contains("mac")) {
        return arch.contains("aarch64") ? "mac-aarch64" : "mac"
    } else if (osName.contains("nux")) {
        return arch.contains("aarch64") ? "linux-aarch64" : "linux"
    } else {
        throw new GradleException("Unsupported OS: $osName")
    }
}

// Config for all projects: deps come from Maven repository,
// compile using Java 21, libs normally sit in lib
allprojects {
    configurations {
        direct
        providedCompile
    }
    repositories {
        mavenCentral()
        google()
        maven {
            url "https://sandec.jfrog.io/artifactory/repo"
        }
    }
    apply plugin: 'java'
    apply plugin: 'org.jetbrains.kotlin.jvm' // Apply Kotlin plugin

    ext {
        libDir = 'lib'
        mvnDir = 'lib/mvn'
        kotlin_version = "2.0.10"
        java_version = "21"
        javaExportOptions = [
            '--add-exports', 'javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED',
            '--add-exports', 'javafx.base/com.sun.javafx.event=ALL-UNNAMED',
            '--add-exports', 'javafx.base/com.sun.javafx=ALL-UNNAMED',
            '--add-exports', 'javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED',
            '--add-exports', 'javafx.controls/com.sun.javafx.scene.control.skin=ALL-UNNAMED',
            '--add-exports', 'javafx.controls/com.sun.javafx.scene.control.skin.resources=ALL-UNNAMED',
            '--add-exports', 'javafx.controls/com.sun.javafx.scene.control.inputmap=ALL-UNNAMED',
            '--add-exports', 'javafx.graphics/com.sun.javafx.scene.traversal=ALL-UNNAMED',
            '--add-exports', 'javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED',
            '--add-exports', 'javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED',
            '--add-exports', 'javafx.graphics/com.sun.javafx.util=ALL-UNNAMED',
            '--add-opens', 'java.desktop/sun.swing=ALL-UNNAMED',
            '--add-opens', 'java.desktop/sun.awt.X11=ALL-UNNAMED'
        ]
    }
    sourceCompatibility = java_version
    targetCompatibility = java_version

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

        // Explicitly specify linuxRuntime for Linux x86-64
        implementation "org.openjfx:javafx-base:11.0.2:linux"
        implementation "org.openjfx:javafx-controls:11.0.2:linux"
        implementation "org.openjfx:javafx-graphics:11.0.2:linux"
        implementation "org.openjfx:javafx-fxml:11.0.2:linux"
        implementation "org.openjfx:javafx-swing:11.0.2:linux"  // Added for SwingNode support
    }

    clean {
        delete += "dist-bin"
    }
}

subprojects {
    group 'biz.ganttproject'
    version = new Date().format("yy.MM.dd") + "-SNAPSHOT"
}

def addPublishing(project) {
    project.publishing {
        repositories {
            maven {
                name "ganttproject-maven-repository-internal"
                url "gcs://ganttproject-maven-repository/internal"
            }
            maven {
                name = "GitHubPackages"
                url = uri("https://maven.pkg.github.com/bardsoftware/ganttproject")
                credentials {
                    username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
                    password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
                }
            }
        }
    }
}

def installLibs(jar, project) {
    def pluginDistDir = new File(rootProject.pluginsDir, project.name)
    copy {
        into(new File(pluginDistDir, "lib/"))
        from(configurations.direct) {
            include "*.jar"
        }
        from(jar.outputs.getFiles().getFiles().flatten())
        from(project.configurations.compileClasspath.minus(project.configurations.providedCompile.resolve())) {
            include "*.jar"
        }
        rename { filename -> filename + ".lib" }
    }
}

def install(task, jar, project) {
    def pluginDistDir = new File(rootProject.pluginsDir, project.name)
    task.doLast {
        println ">>> ------------ Installing $project.name into $pluginDistDir ------------"
        copy {
            into(pluginDistDir)
            from(fileTree(project.projectDir)) {
                include "plugin.xml"
            }
            from(fileTree("$project.projectDir/src/main/")) {
                include "resources/**"
            }
        }
        installLibs(jar, project)
        println "<<< $project.name"
    }
}

// Add this jar task configuration towards the end of your build.gradle
tasks.withType(Jar) {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE

    manifest {
        attributes(
            'Main-Class': 'biz.ganttproject.Main'  // Replace with the actual main class of GanttProject
        )
    }
    from {
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
    }
}
  1. Errors:
➜  ganttproject git:(master) ✗ gradle runapp                                                       

> Configure project :ganttproject-builder
===== Building GanttProject 3.3.3390 =====
===== Building generic binary distro =====

> Task :biz.ganttproject.app.libs:copyPlugin
>>> Installing biz.ganttproject.app.libs into ....../ganttproject/ganttproject-builder/dist-bin/plugins/base/biz.ganttproject.app.libs
<<< biz.ganttproject.app.libs

> Task :biz.ganttproject.app.localization:copyPlugin
>>> Installing biz.ganttproject.app.localization into ....../ganttproject/ganttproject-builder/dist-bin/plugins/base/biz.ganttproject.app.localization
<<< biz.ganttproject.app.localization

> Task :biz.ganttproject.core:copyPlugin
>>> ------------ Installing biz.ganttproject.core into ....../ganttproject/ganttproject-builder/dist-bin/plugins/base/biz.ganttproject.core ------------
<<< biz.ganttproject.core

> Task :ganttproject:generateJooq
02:02:49 WARNING Ambiguous key name       : The database object CONSTRAINT_66F generates an inbound key method name constraint_66f which conflicts with the previously generated outbound key method name. Use a custom generator strategy to disambiguate the types. More information here:
 - https://www.jooq.org/doc/latest/manual/code-generation/codegen-generatorstrategy/
 - https://www.jooq.org/doc/latest/manual/code-generation/codegen-matcherstrategy/
02:02:49 WARNING Ambiguous key name       : The database object CONSTRAINT_66 generates an inbound key method name constraint_66 which conflicts with the previously generated outbound key method name. Use a custom generator strategy to disambiguate the types. More information here:
 - https://www.jooq.org/doc/latest/manual/code-generation/codegen-generatorstrategy/
 - https://www.jooq.org/doc/latest/manual/code-generation/codegen-matcherstrategy/

> Task :biz.ganttproject.impex.ical:copyPlugin
>>> ------------ Installing biz.ganttproject.impex.ical into ....../ganttproject/ganttproject-builder/dist-bin/plugins/base/biz.ganttproject.impex.ical ------------
<<< biz.ganttproject.impex.ical

> Task :biz.ganttproject.impex.msproject2:copyPlugin
>>> ------------ Installing biz.ganttproject.impex.msproject2 into ....../ganttproject/ganttproject-builder/dist-bin/plugins/base/biz.ganttproject.impex.msproject2 ------------
<<< biz.ganttproject.impex.msproject2

> Task :ganttproject:copyPlugin FAILED
>>> ------------ Installing ganttproject into ....../ganttproject/ganttproject-builder/dist-bin/plugins/base/ganttproject ------------

FAILURE: Build failed with an exception.

* Where:
Build file '....../ganttproject/build.gradle' line: 124

* What went wrong:
Execution failed for task ':ganttproject:copyPlugin'.
> Could not resolve all files for configuration ':ganttproject:providedCompile'.
   > Could not resolve org.openjfx:javafx-graphics:11.0.2.
     Required by:
         project :ganttproject > project :biz.ganttproject.core > org.openjfx:javafx-controls:11.0.2
         project :ganttproject > project :biz.ganttproject.core > org.openjfx:javafx-swing:11.0.2
      > Cannot choose between the available variants of org.openjfx:javafx-graphics:11.0.2:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
        All of them match the consumer attributes:
          - Variant 'linux-aarch64Runtime' capability 'org.openjfx:javafx-graphics:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'linuxRuntime' capability 'org.openjfx:javafx-graphics:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'mac-aarch64Runtime' capability 'org.openjfx:javafx-graphics:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'macRuntime' capability 'org.openjfx:javafx-graphics:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'runtime' capability 'org.openjfx:javafx-graphics:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'winRuntime' capability 'org.openjfx:javafx-graphics:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'windows' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
   > Could not resolve org.openjfx:javafx-base:11.0.2.
     Required by:
         project :ganttproject > project :biz.ganttproject.core > org.openjfx:javafx-graphics:11.0.2
      > Cannot choose between the available variants of org.openjfx:javafx-base:11.0.2:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
        All of them match the consumer attributes:
          - Variant 'linux-aarch64Runtime' capability 'org.openjfx:javafx-base:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'linuxRuntime' capability 'org.openjfx:javafx-base:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'mac-aarch64Runtime' capability 'org.openjfx:javafx-base:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'macRuntime' capability 'org.openjfx:javafx-base:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'runtime' capability 'org.openjfx:javafx-base:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'winRuntime' capability 'org.openjfx:javafx-base:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'windows' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
   > Could not resolve org.openjfx:javafx-controls:11.0.2.
     Required by:
         project :ganttproject > project :biz.ganttproject.core > org.openjfx:javafx-fxml:11.0.2
      > Cannot choose between the available variants of org.openjfx:javafx-controls:11.0.2:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
        All of them match the consumer attributes:
          - Variant 'linux-aarch64Runtime' capability 'org.openjfx:javafx-controls:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'linuxRuntime' capability 'org.openjfx:javafx-controls:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'linux' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'mac-aarch64Runtime' capability 'org.openjfx:javafx-controls:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'aarch64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'macRuntime' capability 'org.openjfx:javafx-controls:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'macos' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'runtime' capability 'org.openjfx:javafx-controls:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
          - Variant 'winRuntime' capability 'org.openjfx:javafx-controls:11.0.2':
              - Unmatched attributes:
                  - Provides org.gradle.category 'library' but the consumer didn't ask for it
                  - Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
                  - Provides org.gradle.native.architecture 'x86-64' but the consumer didn't ask for it
                  - Provides org.gradle.native.operatingSystem 'windows' but the consumer didn't ask for it
                  - Provides org.gradle.status 'release' but the consumer didn't ask for it
                  - Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it

* Try:
> Ambiguity errors are explained in more detail at https://docs.gradle.org/8.10/userguide/variant_model.html#sub:variant-ambiguity.
> Review the variant matching algorithm at https://docs.gradle.org/8.10/userguide/variant_attributes.html#sec:abm_algorithm.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.10/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 2s
28 actionable tasks: 7 executed, 21 up-to-date
dbarashev commented 1 month ago

Please correct me if I am wrong, but as far as I can see, there are considerable changes in the build file without any obvious reason. I am not sure that I might be helpful in this case. I hope that the unmodified build file works fine in your setup.