2
votes

I'm having problems understanding how latest.integration works.

I have an example that is not giving the output mentioned in: http://ant.apache.org/ivy/history/latest-milestone/tutorial/defaultconf.html

which says, the local resolver has precedence over other resolvers, regardless of the time of publishing.

My ivysettings.xml goes like this:

<resolvers>
<chain name="download-chain" returnFirst="false" >
    <url name="nexus-repo" m2compatible="true" >
        <artifact pattern="${nexus}/[organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]" />
        <ivy pattern="${nexus}/[organisation]/[module]/[revision]/[type]s/[artifact].[ext]" />
    </url>
    <resolver ref="local" />
</chain>
</resolvers>

here I declare that I have a nexus url repository and a reference to the default local. I use this chain when I want to resolve my dependencies.

I build the designated artifact and publish it to local with status "integration" with a revision "HEAD" (something like SNAPSHOT for us), first using the local resolver:

<ivy:publish 
    overwrite="yes"
    update="true"
    artifactspattern="${project.dist.dir}/[artifact]-[revision](-[classifier]).[ext]" 
    resolver="local"
    settingsRef="ivy.nexus"
/>

and rebuild it again and publish it to nexus repository:

<ivy:publish 
    overwrite="yes"
    update="true"
    artifactspattern="${project.dist.dir}/[artifact]-[revision](-[classifier]).[ext]" 
    resolver="publish-url"
    forcedeliver="true"
    settingsRef="ivy.nexus"
/>

I have another project that declares the previous artifact as dependency with revision "latest.integration".

I expect that the artifact should be downloaded from the local repository regardless of the order of the declared resolvers. But that's not the case. The artifact downloaded is always of the resolver mentioned first. Changing the name of the "local" resolver didn't affect anything. The order is always what matters.

I tried appending changing="true" to my dependency. It didn't help.

In this question: Ivy: Forcing local snapshot for dependency

The Asker mentions an even different behavior, namely that the very latest is picked up (the order of resolvers doesn't even matter).

SO to wrap it up and sorry for prolongation: How to get an artifact:

1) always the latest.integration (the most recent) regardless of location.

2) always from local even if there's a more recent integration version in other locations.

3) Am I that clueless?

2

2 Answers

1
votes

I would recommend reading the following answer on publishing artifacts to Nexus

how to publish 3rdparty artifacts with ivy and nexus

Use the ibiblio resolver, it's much simpler.

A second piece of advice is to have a clear separation between an integration and a release builds, within your ANT logic. The former can use a timestamp as it's revision, whereas the latter needs to have a strategy for maintaining an incrementing revision number (that's a whole different question). Maven calls these "SNAPSHOT" or "Release" builds and implements two different types of repository to support them.

A final piece of advice is to avoid using the local repository, unless, that is where you decide to store your integration builds. Ivy maintains a local cache of downloaded artifacts, it's rarely worth the effort or maintaining a local repo.

0
votes

I could manage to make the order insignificant after all.

I'm not sure how far I should've gone but:

I used the latest="latest-time" in the chain resolver as well as in the URL resolver. This wasn't however enough and when I debugged the code, I found that each resolver judged by its own 'latest'. So I overrode the local repository like this:

<filesystem name="local" latest="latest-time" > 
    <ivy pattern="${ivy.local.default.root}/${ivy.local.default.ivy.pattern}"/>
    <artifact pattern="${ivy.local.default.root}/${ivy.local.default.artifact.pattern}"/>
</filesystem>