我需要从 maven-dependency-plugin:copy-dependencies 中排除单个工件。
在文档上:https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependency-mojo.html https://maven.apache.org/plugins/maven-dependency-plugin/copy-dependencies-mojo.html我发现了两个有趣的选择:
排除ArtifactIds这将排除与给定的artifact-id匹配的所有artifacts(group-id上的通配符)
排除组ID这将排除与给定组 ID 匹配的所有工件(工件 ID 上的通配符)
如果给定工件的组 ID 或工件 ID 是唯一的,则这将起作用。是否可以在不使用通配符的情况下排除单个工件?
您可以通过使用两个来实现这一点execution
部分。
假设您有以下依赖项:
javax.mail:mailapi
javax.mail:mail
sun-javamail:mail
org.jdom:jdom2
你只想排除javax.mail:mail
它与其他工件共享 groupId 和 artifactId。
以下内容可以做到这一点:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<!--include all in group apart from one-->
<configuration>
<excludeArtifactIds>mail</excludeArtifactIds>
<includeGroupIds>javax.mail</includeGroupIds>
</configuration>
</execution>
<execution>
<id>copy-dependencies2</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<!--include all other dependencies-->
<configuration>
<excludeGroupIds>javax.mail</excludeGroupIds>
</configuration>
</execution>
</executions>
</plugin>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)