5

我正在尝试使用 Ivy 解决带时间戳的 SNAPSHOT 依赖项。

环境是 Ant + Ivy 1.2.0 + Archiva。Archiva 本身是从 Maven2 构建中填充的。Ivy 仅用于解决依赖关系(来自单个非 Maven2 项目)。


如何配置 Ivy 以正确解析来自 Archiva 或 m2 存储库的带时间戳的工件?


作为参考,我当前的配置是:

ivysettings.xml类似于:

<ivysettings>
  <settings defaultResolver="archiva-chain"/>

    <resolvers>
      <chain name="archiva-chain" changingPattern=".*SNAPSHOT" checkmodified="true">

        <ibiblio name="archiva-internal"
                 m2compatible="true"
                 usepoms="true"
                 pattern="[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
                 root="http://host:port/archiva/repository/internal"/>

        <ibiblio name="archiva-deploy"
                 m2compatible="true"
                 usepoms="true"
                 pattern="[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
                 root="http://host:port/archiva/repository/deploy"/>

        <ibiblio name="archiva-snapshots"
                 m2compatible="true"
                 usepoms="true"
                 pattern="[organization]/[module]/[revision]/[artifact]-[revision].[ext]"
                 root="http://host:port/archiva/repository/snapshots"/>
    </chain>
  </resolvers>
</ivysettings>

ivy.xml依赖很简单

<ivy-module version="2.0">
  <info organisation="com.myorg" module="myapp"/>
    <dependencies>
      <dependency org="com.myorg" name="myartifact" rev="1.8.0-SNAPSHOT" changing="true"/>
    </dependencies>
</ivy-module>

Ivy 不会尝试解析带时间戳的工件。例如

[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve]          module not found: com.myorg#myartifact;1.8.0-SNAPSHOT
[ivy:retrieve]  ==== archiva-internal: tried
[ivy:retrieve]    -- artifact com.myorg#myartifact;1.8.0-SNAPSHOT!myartifact.jar:
[ivy:retrieve]    http://host:port/archiva/repository/internal/com.myorg/myartifact/1.8.0-SNAPSHOT/myartifact-1.8.0-SNAPSHOT.jar
[ivy:retrieve]  ==== archiva-deploy: tried
[ivy:retrieve]    -- artifact com.myorg#myartifact;1.8.0-SNAPSHOT!myartifact.jar:
[ivy:retrieve]    http://host:port/archiva/repository/deploy/com.myorg/myartifact/1.8.0-SNAPSHOT/myartifact-1.8.0-SNAPSHOT.jar
[ivy:retrieve]  ==== archiva-snapshots: tried
[ivy:retrieve]    -- artifact com.myorg#myartifact;1.8.0-SNAPSHOT!myartifact.jar:
[ivy:retrieve]    http://host:port/archiva/repository/snapshots/com.myorg/myartifact/1.8.0-SNAPSHOT/myartifact-1.8.0-SNAPSHOT.jar
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          ::          UNRESOLVED DEPENDENCIES         ::
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]          :: com.myorg#myartifact;1.8.0-SNAPSHOT: not found
[ivy:retrieve]          ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS

snapshots/com/myorg/myartifact中有一个maven-metadata.xml

<?xml version="1.0" encoding="UTF-8"?>

<metadata>
  <groupId>com.myorg</groupId>
  <artifactId>myartifact</artifactId>
  <versioning>
    <latest>1.8.0-SNAPSHOT</latest>
    <versions>
      <version>1.3.0-SNAPSHOT</version>
      <version>1.4.2-SNAPSHOT</version>
      <version>1.6.1-SNAPSHOT</version>
      <version>1.8.0-SNAPSHOT</version>
    </versions>
    <lastUpdated>20100303003206</lastUpdated>
  </versioning>
</metadata>

snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT中的maven-metadata.xml

<?xml version="1.0" encoding="UTF-8"?>

<metadata>
  <groupId>com.myorg</groupId>
  <artifactId>myartifact</artifactId>
  <version>1.8.0-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <buildNumber>7</buildNumber>
      <timestamp>20100303.003206</timestamp>
    </snapshot>
    <lastUpdated>20100303003206</lastUpdated>
  </versioning>
</metadata>

不是那么有用,但为了完整起见,目录中的文件snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT用于引用的快照:

-rw-r--r-- 1 archiva archiva 240670 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7.jar
-rw-r--r-- 1 archiva archiva     32 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7.jar.md5
-rw-r--r-- 1 archiva archiva     40 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7.jar.sha1
-rw-r--r-- 1 archiva archiva   4068 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7.pom
-rw-r--r-- 1 archiva archiva     32 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7.pom.md5
-rw-r--r-- 1 archiva archiva     40 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7.pom.sha1
-rw-r--r-- 1 archiva archiva 180821 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7-sources.jar
-rw-r--r-- 1 archiva archiva     32 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7-sources.jar.md5
-rw-r--r-- 1 archiva archiva     40 Mar  3 10:32 myartifact-1.8.0-20100303.003206-7-sources.jar.sha1
4

1 回答 1

8

Ivy 支持解析带时间戳的快照,但有以下限制:您的 ibiblio 解析器上的指定模式必须以:

[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]

在您的设置中并非如此,因此 Ivy 不会尝试查找您的时间戳快照。将您的模式更新到此模式应该可以解决您的问题;将您的存档快照存储库的定义更新为:

    <ibiblio name="archiva-snapshots"
             m2compatible="true"
             usepoms="true"
             pattern="[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]"
             root="http://host:port/archiva/repository/snapshots"/>

备注:注意[组织]中的's'而不是'z'。

马丁

于 2010-03-19T21:40:16.907 回答