user1768830
user1768830

Reputation:

Use Ivy API to obtain latest version of a dependency?

We have a simple Ivy repository we host off of an in-house server (Apache httpd serving up JARs and their XML Ivy descriptors).

I now have a need to programmatically determine what the latest version of a dependency is in our repo. Thus if we have two versions of Mockito, our repo might look like:

mockito/                       ==>    organisation
    mockito-all                ==>    module
        1.9.4/                 ==>    revision #
            mockito-all-1.9.4.jar
            mockito-all-1.9.4-ivy.xml
        1.9.5/
            mockito-all-1.9.5.jar
            mockito-all-1.9.5-ivy.xml

It would be nice if, from Java, I can use Ivy to determine that "1.9.5" is the latest version of the mockito/mockito-all module that we have.

This would likely not be an Ant task, and instead would likely be some custom Java code using the classes that exist inside ivy.jar.

Any ideas? Thanks in advance!

Upvotes: 5

Views: 5102

Answers (2)

AlexC
AlexC

Reputation: 1415

So I found your question looking to do the same thing and after some research found that in Ivy 2.4, such a thing exists.

http://ant.apache.org/ivy/history/latest-milestone/use/checkdepsupdate.html

Here is a sample step:

<target name="ivy.outdated" description="Check ivy for outdated jars">
    <ivy:resolve/>
    <ivy:checkdepsupdate showTransitive="false" revisionToCheck="latest.release"/>
</target>

Upvotes: 0

DigitalZebra
DigitalZebra

Reputation: 41603

I believe you can use latest.integration revision value to specify the absolute latest version needed. For example, specify your Ivy dependency like so:

<dependency org="mockito" name="mockito-all" rev="latest.integration" />

You can also specify latest.milestone or latest.release if you don't want the "edge" version. Here is a good explanation on the rev value: http://ant.apache.org/ivy/history/latest-milestone/ivyfile/dependency.html

Upvotes: 2

Related Questions