Gradle不会根据请求排除模块(Gradle won't exclude a module as requested)

编程入门 行业动态 更新时间:2024-10-27 10:30:09
Gradle不会根据请求排除模块(Gradle won't exclude a module as requested)

我无法使用“排除”排除build.gradle文件中的番石榴模块。

有了这个依赖块:

dependencies { ... compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.19.0') { exclude(group: 'com.google.guava', module: 'guava-jdk5') // !!! Doesn't work!!! ... } ... }

我得到下面的依赖关系树。 请注意,不排除guava-jdk5。

+--- com.google.api-client:google-api-client:1.19.0 | +--- com.google.oauth-client:google-oauth-client:1.19.0 | | +--- com.google.http-client:google-http-client:1.19.0 | | | ... | | \--- com.google.code.findbugs:jsr305:1.3.9 | ... | \--- com.google.guava:guava-jdk5:13.0

...

请注意,最后一行仍然包含番石榴模块,但它并未被排除。 为什么? 如何排除它?

I can't exclude a guava module in a build.gradle file using "exclude".

With this dependency block:

dependencies { ... compile(group: 'com.google.api-client', name: 'google-api-client', version: '1.19.0') { exclude(group: 'com.google.guava', module: 'guava-jdk5') // !!! Doesn't work!!! ... } ... }

I get the dependency tree below. Note that guava-jdk5 is not excluded.

+--- com.google.api-client:google-api-client:1.19.0 | +--- com.google.oauth-client:google-oauth-client:1.19.0 | | +--- com.google.http-client:google-http-client:1.19.0 | | | ... | | \--- com.google.code.findbugs:jsr305:1.3.9 | ... | \--- com.google.guava:guava-jdk5:13.0

...

Notice that the last line still includes the guava module, it has not been excluded. Why? How to exclude it?

最满意答案

问题在于另一个编译对象也依赖于具有guava-jdk5作为传递依赖项的第一级依赖项,所以这个其他对象引入了不需要的模块。

我终于可以看到这个使用

./gradlew -q :app:dependencyInsight --dependency guava --configuration compile

并可以使用排除它

configurations { compile.exclude module: 'guava-jdk5' }

The problem was that another compile object was also dependent on the first level dependency that had the guava-jdk5 as a transitive dependency, so this other object was bringing in the unwanted module.

I was able to finally see this using

./gradlew -q :app:dependencyInsight --dependency guava --configuration compile

and could exclude it using

configurations { compile.exclude module: 'guava-jdk5' }

更多推荐

本文发布于:2023-08-06 06:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1445267.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   Gradle   exclude   requested   module

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!