【问题标题】:How to exclude transitive dependency in ant build using maven task for ant?如何使用 Maven 任务为 ant 排除 ant 构建中的传递依赖?
【发布时间】:2015-07-26 11:47:26
【问题描述】:

如何在 ant 的 maven 任务中排除传递依赖。 Scope: runtime 和 provided 在这种情况下似乎没有任何帮助。 这是我的 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。

【问题讨论】:

    标签: maven ant maven-ant-tasks


    【解决方案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>
    

    【讨论】:

    • 我正在尝试使用 maven-ant 任务
    • @user3199100 明白了。如前所述,我不知道 Maven ANT 任务是否支持您想要的功能。
    【解决方案2】:

    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 文件定义的某些依赖项

    【讨论】:

    • 您引用的链接声明元素名称是排除而不是排除(可能自从您发布链接后发生了变化)
    • @cproinger 谢谢你,我刚才弄错了,现在标签名称已更正
    猜你喜欢
    • 2012-10-25
    • 1970-01-01
    • 2018-07-06
    • 2019-10-29
    • 1970-01-01
    • 2014-12-27
    • 2011-10-29
    • 2011-02-22
    相关资源
    最近更新 更多