1

Is there a way when designating a resolver ivy pattern to be able to produce the following output?

C:/MyRepository/MyCompany/MyModule/1.2.3/4/ivy.xml

Currently, the [revision] token resolves to the full 4-digit version number. I'd like to be able to use the first three digits of the revision for a part of the pattern and use the last digit for a subfolder below that. Is this possible or would I have to write custom ant code to do this?

Something like this:

<resolvers>
    <filesystem name="myresolver">
        <ivy pattern="${my.dir}/[organisation]/[module]/[shortversion]/[rev]/ivy.xml" />
        <artifact pattern="${my.dir}/[organisation]/[module]/[shortversion]/[rev]/([target])[artifact].[ext]" />
    </filesystem>
</resolvers>

where:

${my.dir} = C:/MyRepository/

and the ivy tokens have these values:

[organisation] = MyCompany
[module] = MyModule
[shortversion] = 1.2.3
[rev] = 4

I realize I'm making up these fictitious tokens (shortrevision and rev), but what I'd like to be able to do is get at the revision number parts (major, minor, build, revision) so that I can use them in the pattern.

drohm
  • 226
  • 2
  • 15

1 Answers1

1

ivy supports extra attributes which can attached to the dependency declaration as follows:

<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
    ..
    <dependency org="MyCompany" name="MyCompany" rev="1.2.3" e:buildnum="4"/>

The extra attributes are used as normal within your resolver patterns as follows:

<resolvers>
    <filesystem name="myresolver">
        <ivy pattern="${my.dir}/[organisation]/[module]/[revision]/[buildnum]/ivy.xml" />
        <artifact pattern="${my.dir}/[organisation]/[module]/[revision]/[buildnum]/[artifact].[ext]" />
    </filesystem>
</resolvers>
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • So if I went the 'extra attributes' route, does Ivy auto-increment the e:buildnum value when you do a build and publish? Or is that something I'll have to manually update? The way I currently publish is I call resolve, deliver, and then publish. I pass in the 'pubrevision' value to the deliver ant task. I'm guessing I'll now have to manually update the e:buildnum value in the Ivy.xml file manually. Is that the best way to handle this? – drohm Apr 27 '12 at 19:16
  • See the buildnumber task, for an autoincrement capability. http://ant.apache.org/ivy/history/latest-milestone/use/buildnumber.html. Problem is it only works for the standard revision parameter. You'd have to come up with an alternative strategy to duplicate this for a custom revision attribute. Secondly the ivy publish task also only has a single field for revision.... To be honest I think you're doing too much work, do you really need two revision fields? – Mark O'Connor Apr 27 '12 at 19:40
  • I agree, its going to end up being more work than necessary, but in our build scenario, we need it. If there is only a single folder under the module name for the 4 digit revision, all builds will go into one folder which will get extremely large if you're doing a lot of builds. The thought was to use a folder for the first 3 digits, then underneath a folder for each build. This would help segregate the builds to minimize the number per major.minor.build. To be honest, we were kind of shocked this level of flexibility wasn't baked in, at least not yet. – drohm Apr 27 '12 at 20:15
  • You could try and use properties within the ivy file, to set dynamic values of the extra attributes. Auto incrementing the version number is really into new question territory :-) – Mark O'Connor Apr 28 '12 at 23:20