2

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?

Community
  • 1
  • 1
Eyad Ebrahim
  • 971
  • 1
  • 8
  • 21
  • Do you see the word integration anywhere in either of your publish structures above - nope. You actually aren't specifying a status at all during your publish, and so latest.integration will not work. – Rodney P. Barbati Jan 11 '22 at 21:34

2 Answers2

1

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.

Community
  • 1
  • 1
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • This will take some testing of my part and i'm off the office for the weekend. However, the local repository will be used for local development where developers want to test their on-going A project version with an on-going B project version. Using the nexus for that would mean sharing the development artifacts and that's not what we want. I will test the POMs, and I hope they behave more consistently. One last thing, the example you offered has been one of my tutorials into this IVY thing. Thanks man. – Eyad Ebrahim Jun 15 '12 at 21:43
  • @EyadEbrahim Glad to help. Keeping development snapshots locally will certainly be simpler for ivy. If Nexus is being used for releases only, then my final piece of advice is to checkout the ivy buildnumber task. You'll discover it's very useful for incrementing the release number, based on what was previously published. – Mark O'Connor Jun 16 '12 at 09:31
0

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>
Eyad Ebrahim
  • 971
  • 1
  • 8
  • 21