【发布时间】:2016-02-28 20:24:48
【问题描述】:
这不是重复的,因为其他解决方案不起作用。
我有一个子项目:
: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("groupID:ModuleID")吗? -
或
transitive=false -
Re: transitive=false 如果您要随意排除所有内容,那么拥有子项目并尝试重用东西是没有意义的。我需要一些具体的东西。
-
@RaGe 我注意到 Maven 会执行 groupId:projectId 之类的操作,但如果您的子组件是 :something:somethingelse:yetevensomethingelse,那么您的 groupId:projectId 是什么?
标签: gradle dependencies