不能在变体productionRuntimeClasspath和runtimeElements之间进行选择



我正在尝试将这个项目从Spring Boot 2.2.4升级到2.4.3,但现在我遇到了Gradle问题:

Script 'C:Usersbertworkspaceyona-serverdbinitliquibase.gradle' line: 31
* What went wrong:
Execution failed for task ':dbinit:liquibasePathingJar'.
> Could not resolve all files for configuration ':dbinit:runtime'.
> Could not resolve project :core.
Required by:
project :dbinit
> Cannot choose between the following variants of project :core:
- productionRuntimeClasspath
- runtimeElements
All of them match the consumer attributes:
- Variant 'productionRuntimeClasspath' capability yonadev:core:0.0.8-SNAPSHOT:
- Unmatched attributes:
- Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
- Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
- Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it
- Variant 'runtimeElements' capability yonadev:core:0.0.8-SNAPSHOT:
- Unmatched attributes:
- Provides org.gradle.category 'library' but the consumer didn't ask for it
- Provides org.gradle.dependency.bundling 'external' but the consumer didn't ask for it
- Provides org.gradle.jvm.version '11' but the consumer didn't ask for it
- Provides org.gradle.libraryelements 'jar' but the consumer didn't ask for it
- Provides org.gradle.usage 'java-runtime' but the consumer didn't ask for it

上面提到的第31行是以"attributes"在下面的任务中:

task liquibasePathingJar(type: Jar) {
dependsOn configurations.liquibase
appendix = 'pathing'
doFirst {
manifest {
attributes "Class-Path": (configurations.runtime.files + configurations.liquibase.files).collect {
it.toURL().toString().replaceFirst(/file:/+/, '/')
}.join(' ')
}
}
}

在Gradle 6.8.2中出现。

我对Gradle的了解相当有限。我一直在谷歌搜索,但我不知道如何影响变体匹配来解决这个问题。非常感谢您的帮助!

问候,伯特

我找到了一个修复:如果我用configurations.productionRuntimeClasspath.files代替configurations.runtime.files,它可以工作。

最新更新