log4j Quarkus在build.gradle.kts中强制执行平台BOM,从而破坏了添加的依赖性

nnsrf1az  于 2023-10-18  发布在  其他
关注(0)|答案(1)|浏览(104)

我为我的quarkus项目添加了一个dependecny implementation("com.netflix.conductor:conductor-client:3.13.8")。然而,enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")打破了传导者-客户端的传递依赖。我看了Gradle文档,他们建议使用排除,但排除在我的情况下不起作用

构建Gradle文件:

plugins {
    kotlin("jvm") version "1.8.22"
    kotlin("plugin.allopen") version "1.8.22"
    id("io.quarkus")
}
    
repositories {
    mavenCentral()
    mavenLocal()
}
    
val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project
val ktor_version: String by project
    
dependencies {
    implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
    implementation("io.quarkus:quarkus-picocli")
    implementation("io.quarkus:quarkus-kotlin")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("io.quarkus:quarkus-arc")
    implementation("io.ktor:ktor-client-cio-jvm:2.3.3")
    testImplementation("io.quarkus:quarkus-junit5")
    implementation("io.ktor:ktor-client-core:$ktor_version")
    implementation("io.ktor:ktor-client-cio:$ktor_version")
    // https://mvnrepository.com/artifact/com.netflix.conductor/conductor-client
    implementation("com.netflix.conductor:conductor-client:3.13.8")
}
    
group = "io.my1795"
version = "1.0.0-SNAPSHOT"
    
    
    
java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}
   
tasks.withType<Test> {
    systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
}
allOpen {
    annotation("jakarta.ws.rs.Path")
    annotation("jakarta.enterprise.context.ApplicationScoped")
    annotation("io.quarkus.test.junit.QuarkusTest")
}
    
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
    kotlinOptions.javaParameters = true
}

quarkusBuild后失效

11:29:08 AM: Executing 'quarkusBuild'...

> Task :processResources UP-TO-DATE
> Task :quarkusGenerateCode FAILED

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.

See https://docs.gradle.org/8.1.1/userguide/command_line_interface.html#sec:command_line_warnings
2 actionable tasks: 1 executed, 1 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusGenerateCode'.
> Could not resolve all files for configuration ':quarkusProdBaseRuntimeClasspathConfiguration'.
   > Could not resolve org.apache.logging.log4j:log4j-api:2.20.0.
     Required by:
         project : > io.quarkus.platform:quarkus-bom:3.2.3.Final
      > Cannot find a version of 'org.apache.logging.log4j:log4j-api' that satisfies the version constraints:
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'
           Constraint path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'io.quarkus.platform:quarkus-bom:3.2.3.Final' (enforced-platform-runtime) --> 'org.apache.logging.log4j:log4j-api:2.20.0'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-core:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-jul:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-web:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-common:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-common:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-annotations:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'

   > Could not resolve org.apache.logging.log4j:log4j-api:{strictly 2.17.2}.
     Required by:
         project : > com.netflix.conductor:conductor-client:3.13.8
         project : > com.netflix.conductor:conductor-client:3.13.8 > com.netflix.conductor:conductor-common:3.13.8
         project : > com.netflix.conductor:conductor-client:3.13.8 > com.netflix.conductor:conductor-common:3.13.8 > com.netflix.conductor:conductor-annotations:3.13.8
      > Cannot find a version of 'org.apache.logging.log4j:log4j-api' that satisfies the version constraints:
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'
           Constraint path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'io.quarkus.platform:quarkus-bom:3.2.3.Final' (enforced-platform-runtime) --> 'org.apache.logging.log4j:log4j-api:2.20.0'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-core:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-jul:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-web:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-common:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-common:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-annotations:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'

   > Could not resolve org.apache.logging.log4j:log4j-api:2.17.2.
     Required by:
         project : > com.netflix.conductor:conductor-client:3.13.8 > org.apache.logging.log4j:log4j-core:2.17.2
         project : > com.netflix.conductor:conductor-client:3.13.8 > org.apache.logging.log4j:log4j-slf4j-impl:2.17.2
         project : > com.netflix.conductor:conductor-client:3.13.8 > org.apache.logging.log4j:log4j-jul:2.17.2
         project : > com.netflix.conductor:conductor-client:3.13.8 > org.apache.logging.log4j:log4j-web:2.17.2
      > Cannot find a version of 'org.apache.logging.log4j:log4j-api' that satisfies the version constraints:
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'
           Constraint path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'io.quarkus.platform:quarkus-bom:3.2.3.Final' (enforced-platform-runtime) --> 'org.apache.logging.log4j:log4j-api:2.20.0'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-core:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-slf4j-impl:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-jul:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-web:2.17.2' (runtime) --> 'org.apache.logging.log4j:log4j-api:2.17.2'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-common:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'
           Dependency path 'io.my1795:conductor-commander:1.0.0-SNAPSHOT' --> 'com.netflix.conductor:conductor-client:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-common:3.13.8' (runtimeElements) --> 'com.netflix.conductor:conductor-annotations:3.13.8' (runtimeElements) --> 'org.apache.logging.log4j:log4j-api:{strictly 2.17.2}'

* Try:
> 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

BUILD FAILED in 370ms
11:29:08 AM: Execution finished 'quarkusBuild'.
lrpiutwd

lrpiutwd1#

我会说这是一个错误的指挥。
一个库通常不应该严格依赖于某个具体的版本,或者你会遇到这样的问题,即库严格要求一个版本,而某个构建或其他库严格依赖于某个其他版本,然后无法解决。
在您的例子中,您使用enforcedPlatform添加了第二个严格版本,它添加了严格的约束,通常也不应该使用。它更多地用于罕见的边缘情况,通常只使用platform
但除此之外,如果你看看https://github.com/Netflix/conductor/blob/v3.13.8/build.gradle#L108-L116,似乎严格的边界应该允许2.17.2和3.0之间的任何版本,但构建的其他部分似乎将其严格更改为2.17.2。
除此之外,整个区块除了log4j-core是非常值得怀疑的。它最有可能是为了防止Log4Shell,它只影响log4j-core,所以对其他log4j依赖项的所有论述都是毫无意义的,而且可能会减慢依赖项解析。
但实际上,排除应该可以临时解决您的问题。你说它不起作用,但没有说你在哪里和如何尝试。例如,您可以将其从conductor-client依赖项中排除,然后在没有其他部分依赖它而conductor-client需要它时手动依赖它。

相关问题