gpt4 book ai didi

java - 如何在 Gradle 中排除可传递的可选 Maven 系统?

转载 作者:搜寻专家 更新时间:2023-11-01 03:30:49 25 4
gpt4 key购买 nike

我需要在 Gradle 项目中使用 compile group: 'org.apache.yetus', name: 'audience-annotations', version: '0.10.0'。但是可以看出here ,它有一个 system 范围的 optional 依赖。

我在我的 build.gradle 文件中定义了以下内容:

allprojects {

configurations.all {
exclude group: 'jdk.tools', module 'jdk.tools'
}

}

我原以为这会负责从依赖关系树/图中删除依赖关系。

但是,它仍然在提示:

carlspring@carlspring:/java/opensource/gradle/possible-gradle-bug> gradle --no-daemon clean build

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not resolve org.apache.yetus:audience-annotations:0.10.0.
Required by:
project :
> Could not resolve org.apache.yetus:audience-annotations:0.10.0.
> Could not parse POM https://repo1.maven.org/maven2/org/apache/yetus/audience-annotations/0.10.0/audience-annotations-0.10.0.pom
> Unable to resolve version for dependency 'jdk.tools:jdk.tools:jar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
2 actionable tasks: 1 executed, 1 up-to-date

我还需要做些什么才能真正排除这种依赖性,因为我正在使用 JDK (1.8.0_144) 构建代码,所以实际上并不需要这种依赖性?

我正在使用 Gradle 4.2.1,(不确定是否可以升级,除非它是 4.x 版本)。

我有一个“你好,世界!”说明此的应用 here .

我觉得这是一个错误,我已经提交了 gradle/gradle#10058 ,但我可能是错的。请指教!

最佳答案

试试这个。它对我有用:

configurations {
all*.exclude module : 'jdk.tools'
}

关于java - 如何在 Gradle 中排除可传递的可选 Maven 系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57163627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com