user967710
user967710

Reputation: 2007

IVY - multiproject local build - mimcking "resolve dependencies in workspace"

I have three projects: A, B, C and build.xml in ant that should compile them.

C depends on B that depends on A

So far I had all dependencies were in eclipse and I had a build.xml in ant with:

<eclipse.incrementalBuild project="A" kind="incremental"/>
<eclipse.incrementalBuild project="B" kind="incremental"/>
<eclipse.incrementalBuild project="C" kind="incremental"/>

Now, I have ivy.xml files - for example:

<ivy>
   <ivy module="B"/>

   <dependencies>
       <dependency name="A">
   </dependencies>
</ivy>

Now, all works great when I publish A, B, C in this order to a repository (I use sonatype nexus repository), since the repository is also used for resolving, so the process is: 1. resolve dependencies for A - no such 2. upload currently in workspace A as jar to repository 3. resolve dependencies for B - A is resolved as dependency 4. upload currently in workspace B as jar to repository 5. resolve dependenceies for C - B and A are resolved as dependencies 6. upload currently in workspace C as jar to repository

The way I see it publishing to nexus is for delivering the product

What I need is a simple build.xml to just compile my project - and so I don't want to publish all the time new version. Instead I am looking for I way to use ivy to 1. compile A 2. and then compile B using already compiled A 2. and then compile C using already compiled B,A

I thought about using a local repository in the file system, in which stages 1-6 are made - producing local jars to be used - however, this is a bit cumbersome since: 1. my resolve will have to contain two resolvers - the file system preceding the nexus repo - which means that on a real publish, I will have to remember to delete the local jars 2. Sounds a bit too much work for something I believe may have a simpler solution.

In essence, I want to mimic eclipse's IVY plugin that can resolve dependencies in workspace and compile projects using other projects in the workspace - but I am looking for the best, most recommended way of doing this.

Thank you

Upvotes: 0

Views: 354

Answers (1)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 77941

You stated:

I have three projects: A, B, C and build.xml in ant that should compile them.

That suggests that your project is in fact one large monolithic build.

Instead you need to emulate how Maven does its work. Each module needs to have its own build file and an ivy file that lists that module's dependencies. Each module publishes its own jar artifact into a repository (local or remote) making it accessible to other modules using ivy resolve operations.

The following examples give links to the ivy documentation on multi-module builds using ivy.

It's not easy to break up a big project, I hope this helps.

Upvotes: 2

Related Questions