[英]Exclude specific directory/path in gradle dependency
我的依赖项中有一个implementation
依赖项。 该依赖项具有旧版本的 apache commons-lang 3 依赖项阴影。 它没有被列为依赖的传递依赖,它只是被加了阴影。 但是,我也需要 apache commons-lang 3 依赖项,并且我需要更新的版本。 我不认为我可以排除 commons-lang 3 依赖,因为它不是传递性的。 还有另一种方法可以过滤掉依赖吗?
使用 gradle 7.1
试试你的例子:
<dependency>
<groupId>xxxx</groupId>
<artifactId>xxxx</artifactId>
<version>1.0.9-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.commons-lang</groupId>
<artifactId>XXX</artifactId>
</exclusion>
</exclusions>
</dependency>
您可以使用mvn dependency:tree
检查 commons-lang 的来源来检查依赖关系树,然后您可以从父依赖关系中排除。
此外,请尝试将 commons-lang 的外部依赖项作为其父依赖项之上的较新版本提供。
例子:
<dependencies>
<dependency>
<groupId>or.apache.xxx</groupId>
<artifactId>commons-lang.xxx</artifactId>
<version>newer.version</version>
</dependency>
<dependency>
<groupId>parent.dependency.of.commons.lang</groupId>
<artifactId>parent.dependency.of.commons.lang</artifactId>
<version>specified.version</version>
</dependency>
</dependencies>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.