给定一个gradle项目A依赖于项目B(没有共同的父项)
compile project('B'){
exclude group: 'org.slf4j'
}
how do we exclude transitive dependency group from a project we depend upon? (这段脚本将失败,因为 compile projet(..)
没有 exclude
)
更一般的问题: is there an elegant way to exclude a particular group from all dependancies except if its a first level dependency?
例如,我们可能有一堆库,每个库都可以声明其日志环境,但是通过排除所有已知的 slf4j
组,其实现和声明特定版本,我们将确保我们没有任何版本冲突并且将控制版本模块级别 .
1 回答
以下是Gradle文档中的一个示例,该文档介绍了如何在项目级别上排除传递依赖项(我猜这是“除了它是第一级依赖项”之外的意思):
见52.4.7 . 排除传递依赖性here
您可以直接使用所需版本指定依赖关系,也可以使用强制版本resolution strategy