Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ivy: Resolving and Publishing JARs Locally

Tags:

java

ivy

We have been using Ivy for a few months and have our own hosted "Ivy Repo" on a web server here in the office. All of our projects are configured to go to this repo to resolve dependencies.

We have several "commons" type JARs that are used by many of our projects. Because of this, and because we only have 1 repo, we're finding a lot of ugly overhead coming from the following scenario:

  • A developer is given a task to add a feature to Project 1 (which depends on a Common jar)
  • During the course of developing Project 1, the developer realizes he/she needs to make changes to the Common jar
  • Common jar changes are made
  • Common jar has to go through code review and normal code promotion
  • Build master publishes new Common jar
  • Project 1 can resume development now that Common jar has been updated

This is becoming ridiculous and painful for our team.

To me, the obvious solution is to provided ant targets in each project that allow the developer to publish/resolve locally (to and from their file system). That way they can break the Common jar 9 ways to Sunday, but without losing 2 - 4 days while waiting for Common to get published. This way, the developer makes local changes to both Project 1 and Common, and the code goes through our promotion process all at once.

I know this is possible with Ivy, but I'm so new to it I wouldn't even know where to begin.

Currently we use a global ivy.settings file for all projects. In the settings file, we use a chain resolve that has 1 url resolver inside of it, which connects to our "ivy repo".

I believe the following is the only change that will be necessary, but I'm not 100% sure:

  • In ivy.settings we will need to add a local file system resolver before the url resolver gets called; this way we check the local file system for dependencies before moving on to the ivy repo (web server)
  • Configure each project's ivy.xml with an option somehow that allows local cache publishing
  • Tweak the Ant builds to have a publish-locally target that exercises the option mentioned above

I believe these changes will allow us to: (1) always look locally for dependencies before looking to the web server, (2) publish locally as a build option (target).

If this is not true, or if I am missing any steps, please advise! Otherwise, I can probably figure out how to add a file system resolver from the Ivy docs, but have no idea how to get the publish-locally target to work. Any ideas? Thanks in advance!

like image 547
IAmYourFaja Avatar asked Jan 14 '12 20:01

IAmYourFaja


1 Answers

I too would prefer Marks approach.

As to publish-locally you can tell the publish task which resolver(resolver="local") to use. This way it can publish to the local filesystem or to any defined resolver.

<ivy:publish 
        resolver="local" 
        overwrite="true"
        revision="${project.version}">  
        <artifacts pattern="dist/[artifact]-[revision].[type]" />
    </ivy:publish>

And if you use a chain resolver you should set returnFirst="true" so that resolving will stop when something was found locally.

like image 133
oers Avatar answered Sep 18 '22 03:09

oers