gpt4 book ai didi

gradle - 如何排除从其他子项目引入的依赖项?

转载 作者:行者123 更新时间:2023-12-03 12:07:45 24 4
gpt4 key购买 nike

这不是重复的,因为其他解决方案不起作用。

我有一个子项目:

:commons:widget

gradle.build(子项目)类似于:

configurations {providedCompile}

dependencies {
compile project(":commons:other-widget")
...other dependencies...
}

如果显示依赖项:
+--- project :commons:some-other-project
+--- project :commons:exclude-me-project (*)
\--- org.apache.cxf:cxf-rt-frontend-jaxrs: -> 3.0.3 (*)

什么不起作用:

任何常用语法。我已经尝试了所有我能想到的变化。甚至去寻找 API 但无法在那里找到我需要的东西。

在这个项目的依赖部分:
...
compile project(":commons:some-other-project") {
exclude (":commons:exclude-me-project")
}

结果:
Could not find method exclude() for arguments [:commons:some-other-project] on project 

我也试过:
compile ( project (':commons:some-other-project') ) {
transitive = false
}

结果:它没有删除“:commons:some-other-project”的依赖关系,而是删除了“:commons:some-other-project”。

我有一个大而复杂的项目要转换。我有很多这样的工作摆在我面前。给定一个项目作为依赖项,我如何从中排除一些东西?

最佳答案

exclude for dependencies 有一点不同的语法,所以尝试提供模块名称,它等于 exclude-me-project名称,例如:

compile(project(":commons:some-other-project")) {
exclude module: "exclude-me-project"
}

或者,您可以排除 commons 的所有传递依赖项。项目,但它会删除 some-other-project 的所有部门项目,包括 exclude-me-project :
compile(project(":commons:some-other-project")) {
transitive = false
}

关于gradle - 如何排除从其他子项目引入的依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33926800/

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