Friday, September 13, 2013

Ivy, Ant buildnumber task and Nexus

So finally some technical stuff. Currently I'm working on some project migration from nothing to Dependency Management System. I was forced to use Nexus and Ant so best choice was to implement Ivy. Everything worked fine - I was able to download artefacts and publish them to Nexus with Ivy. At some point I realized that I need to somehow calculate next version of my artefact so ivy:buildnumber task appeared to be made especially for this task. So I started implementing it, very simple actually - http://ant.apache.org/ivy/history/2.2.0/use/buildnumber.html

Just one problem with it - it was not calculating next number but showing next number as 0 all the time. Browsing on internet didn't helped much. Finally I was so frustrated so I tried to, how we Latvians say "paskatīties, kas lācītim vēderā" and added magical "-v" to my Ant to enable verbosity. And voila! -

[buildnumber] CLIENT ERROR: The server has not found anything matching the request URI url=https://myserver/nexus/content/repositories/releases/my/core/maven-metadata.xml
[buildnumber] maven-metadata not available: https://myserver/nexus/content/repositories/releases/my/core/maven-metadata.xml
Property "ivy.build.number" has not been set


Maven? What? I thought I was working with Ivy! Tried to remove "m2compatible" mode in ivysettings.xml which is required by Nexus and build failed of course. After some searching on Google I got to this point - https://issues.apache.org/jira/browse/IVY-1334

To cut long story short, just add useMavenMetadata="false" to your ivysettings.xml. Opensource, yeah...