gradle 无法在以下变量之间进行选择

n9vozmp4  于 2023-10-19  发布在  其他
关注(0)|答案(1)|浏览(115)

我写的update4j基于应用程序。但是我在添加一些JavaFX依赖项后面临构建问题。

build.gradle.kts:

plugins {
    application
    kotlin("jvm") version "1.8.21"
    id("ua.tiras.update4j-plugin") version "0.1.21"
    // others
    id("org.openjfx.javafxplugin") version "0.1.0"
}

buildscript {
    repositories {
        maven {
            setUrl("https://plugins.gradle.org/m2/")
        }
    }
    dependencies {
        classpath("org.openjfx:javafx-plugin:0.1.0")
    }
}
apply(plugin = "org.openjfx.javafxplugin")

javafx {
    setPlatform("win")
    version = "17.0.2"
    modules("javafx.controls", "javafx.fxml", "javafx.web", "javafx.media")
}

dependencies {
    // others 
    implementation("org.openjfx:javafx-controls:17.0.2:win")
    implementation("org.openjfx:javafx-fxml:17.0.2:win")
    implementation("org.openjfx:javafx-web:17.0.2:win")
    implementation("org.openjfx:javafx-media:17.0.2:win")
}

// others configs

update4j {
    // name of the generated config xml. optional, default: update.xml
    configurationFileName = "update.xml"
    // directory in which to find the files. mandatory!
    remoteLocation = "https://update.exaple.com"
    // launcher class. mandatory!
    launcherClass = "aaa.proj.Launcher"
    // use maven links in the update.xml. optional, default: true
    // if false, it copies all dependencies into the output folder
    useMaven = false
    basePath = "\${user.home}/aaaProj"
    artifactsConfiguration = "default"
    extraFiles = listOf(
        file("lib/jai_imageio.jar"),
        file("lib/morena.jar"),
        file("lib/morena_license.jar"),
        file("lib/morena_windows.jar")
    )
}

运行gradlew generateBundle后:

Execution failed for task ':generateBundle'.
> Could not resolve all dependencies for configuration ':default'.
   > Could not resolve org.openjfx:javafx-controls:17.0.8.
     Required by:
         project :
      > Cannot choose between the following variants of org.openjfx:javafx-controls:17.0.8:
          - linux-aarch64Runtime
          - linuxRuntime
          - mac-aarch64Runtime
          - macRuntime
          - runtime
          - winRuntime
        All of them match the consumer attributes:
          - Variant 'linux-aarch64Runtime' capability org.openjfx:javafx-controls:17.0.8:
              - 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:17.0.8:
              - 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:17.0.8:
              - 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:17.0.8:
              - 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
6ljaweal

6ljaweal1#

所以想出了如何解决这个问题:
1.删除javafxplugin
1.保持依赖关系不变
1.将useMaven = false更改为useMaven = true

相关问题