首页 文章

使用Ant和Ivy仅保留最新的依赖关系快照

提问于
浏览
1

我正在使用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的新手 . 这是预期的行为吗?如何配置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>

1 回答

  • 1

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

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

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

    我想你有两个选择:

    • 使用ivy cachepath任务来管理构建类路径

    • 清除lib目录,使用他的retrieve任务重新填充最新的jar

    第一个选项可能看起来更复杂,但实际上它是使用常 Spring 藤的一种非常强大的方式 . 有关示例,请参阅:

相关问题