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

Gradle 如何排除从其他子项目引入的依赖项?,gradle,dependencies,Gradle,Dependencies,这不是重复,因为其他解决方案不起作用 我有一个子项目: :commons:widget gradle.build(子项目)类似于此: configurations {providedCompile} dependencies { compile project(":commons:other-widget") ...other dependencies... } 如果显示依赖项: +--- project :commons:some-other-project +--- proj

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

我有一个子项目:

: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,但在那里找不到我需要的东西

在该项目的依赖项部分:

结果:

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
因为依赖项有一点其他语法,所以请尝试提供模块名称,该名称等于
exclude me项目
名称,如:

compile(project(":commons:some-other-project")) {
    exclude module: "exclude-me-project"
}
或者,您可以排除
commons
项目的所有可传递依赖项,但它将删除
某个其他项目
项目的所有Dep,包括
排除me项目

compile(project(":commons:some-other-project")) {
    transitive = false
}

您是否尝试过
exclude(“groupID:ModuleID”)
?或
transitive=false
Re:transitive=false如果您打算毫无顾忌地排除所有内容,那么拥有子项目并尝试重复使用这些内容是毫无意义的。我需要一些特定的东西。@我注意到Maven做了groupId:projectId之类的事情,但如果您的子组件是:somethingelse:yestevensomethingelse,那么您的groupId:projectId是什么?已经尝试排除模块,但将再次检查以确定。这可能不是在正确的情况下发生的。transitive=false不是很具体。就像用核武器打蚊子一样。@user447607只是别忘了把一个
项目
放进
。不是
编译项目(“:commons:some other project”)
,而是
编译(project(“:commons:some other project”)
。我已经对它进行了测试,但是有了一点其他的项目结构,它可以有除标签之外的,除“newLib”项目之外的吗?这里需要帮助吗
compile(project(":commons:some-other-project")) {
    transitive = false
}