如何解决Gradle:传递依赖排除非全局
我有一个使用 spring-ws-security
的项目。
这引入了 EH 缓存,它并不是真正需要的(所以我不确定为什么 spring-ws-security
将它声明为非可选,但这是另一回事)。
但 Apache WSS4J 也将其引入。
+--- org.springframework.ws:spring-ws-security -> 3.0.10.RELEASE
...
| +--- net.sf.ehcache:ehcache:2.10.5 -> 2.10.6 ...
...
| +--- org.apache.wss4j:wss4j-ws-security-dom:2.2.3 -> 2.2.2
...
| | \--- net.sf.ehcache:ehcache:2.10.5 -> 2.10.6
当我使用
从spring-ws-security
中排除它时
implementation("org.springframework.ws:spring-ws-security") {
exclude group: 'net.sf.ehcache',module: 'ehcache' // Not needed,contains a security vulnerability
}
,我希望它真正排除它。但既然我们在谈论 Gradle,it has a head of it's own。这意味着如果一个子部门带来它,它就会保留它。
所以我试图将它从子dep中排除:
// Because of Gradle's logic,sub-deps can bring the excluded dep back.
implementation("org.apache.wss4j:wss4j-ws-security-dom") {
exclude group: 'net.sf.ehcache',module: 'ehcache'
}
但这并没有帮助,我仍然可以在依赖树中看到它。
我可以在全局范围内排除它,但我不想这样做,因为这是一种不好的做法,并且以后当其他一些库非可选地需要 EH 缓存时可能会导致问题:
configurations.all {
exclude group:"some.group",module: "module-to-exclude"
}
有什么方法可以让 Gradle 从我要求它排除的整个子树中排除一个依赖项吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。