[英]Gradle does not resolve transitive dependency inherited from parent pom
I was converting a maven project into a gradle project,but I encountered a problem.我正在将 maven 项目转换为 gradle 项目,但遇到了问题。
Here is all i have:这就是我所拥有的:
So, as expected, project A should have a direct dependency B, and a transitive dependency D因此,正如预期的那样,项目 A 应该有一个直接依赖 B 和一个传递依赖 D
it works fine in maven form that project A can access library D.But in gradle form, gradle does not treat D as a dependency of project A,it just ignores this transitive denpendency.它在 maven 形式中工作正常,项目 A 可以访问库 D。但是在 gradle 形式中,gradle 不将 D 视为项目 A 的依赖项。它只是忽略了这个传递 denpendency
`implementation 'group:B:version'`
How should it declear the depencency of B in gradle to get same result as in maven它应该如何消除 gradle 中 B 的依赖性以获得与 maven 相同的结果
I know it is not a regular way to access D from A without declearing dependency,but I just want to archive the same goal as maven with gradle.我知道在不清除依赖关系的情况下从 A 访问 D 不是常规方法,但我只想使用 gradle 归档与 maven 相同的目标。
Thanks for your answer,any help will be much appreciated.感谢您的回答,任何帮助将不胜感激。
Use compile
instead implementation
in a both modules (A and B) if need to access to project C from project A.如果需要从项目 A 访问项目 C,请在两个模块(A 和 B)中使用
compile
而不是implementation
。
PS This is not recommended and may indicate an incorrectly designed architecture. PS 不建议这样做,这可能表明架构设计不正确。 In particular, the violation of D from SOLID.
特别是违反 SOLID 中的 D。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.