【问题标题】:Keeping only the latest dependency snapshot using Ant and Ivy使用 Ant 和 Ivy 仅保留最新的依赖关系快照
【发布时间】:2014-06-19 06:33:31
【问题描述】:

我正在使用 Ant 来构建我的项目,并使用 Ivy 来解决它的依赖关系。我的项目有一个依赖项,它将快照发布到我的内部 Artifactory 服务器。

如果依赖项发布了新快照,并且我执行<ivy:retrieve />,Ivy 将获取新快照但保留之前的快照。所以我的lib 目录中有两个版本的依赖项。

依赖快照命名为depproject-1.0.0+23.jar,其中23 是内部版本号。它发布在http://artifactory.example.com/example-snapshots-local/com.example/depproject/1.0-SNAPSHOT/depproject-1.0.0+23.jar 之类的地址。这不是一个 Maven 存储库,它被配置为存储唯一的快照。

我是常春藤的新手。这是预期的行为吗?如何配置 Ivy 或 Ant 以便仅保留最新的依赖项快照?

ivysettings.xml

<?xml version="1.0" encoding="UTF-8"?>
<ivy-settings>
    <settings defaultResolver="main" />
    <resolvers>
        <chain name="main">
            <ibiblio
                name="artifactory-example-snapshots"
                m2compatible="false"
                root="http://artifactory.example.com/example-snapshots-local/"
                pattern="[organization]/[module]/1.0-SNAPSHOT/[artifact]-[revision](-[classifier]).[ext]" />
            <!-- more repos listed -->
        </chain>
    </resolvers>
</ivy-settings>

ivy.xml

<ivy-module version="2.0">
    <info organisation="com.example" module="myproject" />
    <dependencies>
        <dependency org="com.example" name="depproject" rev="latest.integration" />
    </dependencies>
</ivy-module>

【问题讨论】:

    标签: ant ivy dependency-management snapshot


    【解决方案1】:

    我假设您正在使用 lib 目录中的 jars 来创建类路径,例如:

    <path id="compile.path">
      <fileset dir="lib" includes="*.jar"/>
    </path>
    

    您的问题是包含相同类的多个 jar?

    我认为你有两个选择:

    1. 使用 ivy cachepath 任务来管理构建类路径
    2. 清除 lib 目录,使用他的 retrieve 任务重新填充最新的 jars

    第一个选项可能看起来更复杂,但它实际上是使用 ivy 的一种非常强大的方式。示例见:

    【讨论】:

      猜你喜欢
      • 2011-12-11
      • 1970-01-01
      • 2010-09-24
      • 2011-05-14
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 2011-03-01
      • 2016-10-11
      相关资源
      最近更新 更多