Gradle - 排除嵌套的传递依赖
Posted
技术标签:
【中文标题】Gradle - 排除嵌套的传递依赖【英文标题】:Gradle - Exclude Nested Transitive Dependencies 【发布时间】:2017-05-17 22:58:57 【问题描述】:以下自定义启动依赖项具有许多传递依赖项。这些传递依赖项中很少有引用 org.hibernate 组。我在 build.gradle 文件中更新了以下内容以排除依赖项。但是,当我运行“gradle dependencies”并查看依赖树时,它似乎并没有被删除。是否应该修改某些内容以排除嵌套的传递依赖?
compile("com.comp.service:service-boot:3.0.+")
exclude group: 'org.hibernate'
【问题讨论】:
【参考方案1】:使用如下块,我希望它的工作-
compile("com.comp.service:service-boot:3.0.+")
exclude group: 'org.hibernate'
【讨论】:
对不起,这是一个错字。我用过组。我已经更正了原帖。这并不排除依赖。【参考方案2】:添加configurations
部分:
dependencies
....
configurations
all*.exclude group: 'org.hibernate'
您还可以使用module
来缩小排除范围(如果单独使用group
删除了太多传递依赖项)。
来源:
how to properly configure gradle build to avoid including log4j and slf4j from the resulting jar? https://docs.gradle.org/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies (#25.4.7) http://mrhaki.blogspot.ca/2012/10/gradle-goodness-exclude-transitive.html【讨论】:
以上是关于Gradle - 排除嵌套的传递依赖的主要内容,如果未能解决你的问题,请参考以下文章