Resolving SNAPSHOT dependencies with timestamps from Ivy
Asked Answered
C

1

5

I am attempting to resolve timestamped SNAPSHOT dependencies with Ivy.

The environment is Ant + Ivy 1.2.0 + Archiva. Archiva itself is populated from Maven2 builds. Ivy is only used to resolve dependencies (from a single, non Maven2 project).


How can Ivy be configured to correctly resolve timestamped artifacts from an Archiva or m2 repository?


For reference my current configuration is:

ivysettings.xml looks similar to:

<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>

The ivy.xml dependencies are simple:

<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 does not attempt to resolve a timestamped artifact. E.g.

[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

There is a maven-metadata.xml in snapshots/com/myorg/myartifact:

<?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>

The maven-metadata.xml in snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT:

<?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>

Not all that useful, but for completeness, the files in the directory snapshots/com/myorg/myartifact/1.8.0-SNAPSHOT for the referenced 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
Churchwarden answered 8/3, 2010 at 3:20 Comment(0)
F
8

Ivy supports resolving timestamped snapshots, but with the following limitation: the specified pattern on your ibiblio resolver must end with:

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

This is not the case in your setup, so Ivy won't try to find your timestamped snapshot. Updating your pattern to this one should solve your problem; update the definition of your archiva-snapshots repository to:

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

Remark: mind the 's' in [organisation] instead of the 'z'.

Maarten

Friede answered 19/3, 2010 at 21:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.