如何使用maven任务为ant排除ant构建中的传递依赖?

时间:2015-05-14 18:16:43

标签: maven ant maven-ant-tasks

如何在ant的maven任务中排除传递依赖。范围:运行时和提供的在这种情况下似乎没有任何帮助。 这是我的build.xml

<artifact:remoteRepository url="https://mynexus/" id="remote.repository"/>

<artifact:dependencies filesetId="dependency.fileset" useScope="runtime">
     <dependency version="1.7.0" artifactId="commons-beanutils" groupId="commons-beanutils"/>
</artifact:dependencies>

commons-beanutils具有我需要排除的依赖性commons-logging。

2 个答案:

答案 0 :(得分:1)

我不认为Maven任务支持此功能。您是否考虑过使用Apache ivy?以下2个示例演示了排除功能。

cachepath任务对于管理类路径非常有用:

<ivy:cachepath pathid="compile.path">
  <dependency org="commons-beanutils" name="commons-beanutils" rev="1.7.0" conf="default">
    <exclude module="commons-logging"/>
  </dependency>
</ivy:cachepath>

retrieve任务可用于在本地下载和保存文件:

<ivy:retrieve pattern="lib/[artifact]-[revision](-[classifier]).[ext]">
  <dependency org="commons-beanutils" name="commons-beanutils" rev="1.7.0" conf="default">
    <exclude module="commons-logging"/>
  </dependency>
</ivy:retrieve>

答案 1 :(得分:1)

maven-ant支持此排除,请RTFM https://maven.apache.org/ant-tasks/reference.html#exclusion

就像

一样
<artifact:dependencies filesetId="dependency.fileset" useScope="runtime">
  <artifact:dependency version="1.7.0" artifactId="commons-beanutils" groupId="commons-beanutils">
    <exclusion groupId="commons-logging" artifactId="commons-logging">
  </<artifact:dependency>
</artifact:dependencies>

但是我没有找到任何支持来排除由pom文件定义的一些依赖项