Gareth,
>>>I'm sure that what I'm trying to achieve is
incredibly simple, but …
Well, I agree it should be incredibly simple, but it is not. :)
I was facing the similar problem and that is how I solved it.
First of all, all my ivy files have configurations as follow:
<configurations>
<conf name='default' description='Default configuration
used when nothing is specified'/>
<conf name='deploy' extends='default' description='Deps
which are available in the build classpath.'/>
<conf name='compile' extends='deploy'
description='Compile time deps, including deploy deps.'/>
<conf name='run' extends='deploy' description='Dependencies
required at runtime, including deploy.'/>
<conf name='test' extends='default' description='Test
deps are only available in the test classpath.'/>
</configurations>
as you can see I have separated configurations for deps for run time, test,
compile
and deploy. Having that, I can define the dependencies how I want. Most of the
time I use 'deploy' configuration for my deps, but if I need to specify an
artifact that I need for the compilation but do not need to include it into war
file, I use 'compile' configuration and vice versa if I need an artifact to be
included into war, but I do not need it at 'compile' time I define it at 'run'
configuration. I hope you got it. (As for the situation where I need an
artifact for both test and compile time I use ‘default’ configuration)
Now, the interesting part is that how you resolve the artifacts. When I compile
my artifact I use <ivy:resolve conf='compile' ...> <ivy:retrive
conf="compile" ...>, but when I build my war I use <ivy:resolve
conf="run" ...> <ivy:retrive conf="run" ...>.
Again, I hope it makes sense.
This all above works like a charm, but the problem is how you would put things
together at the resolution time. Let’s take for example of A depending on B. ‘A’
may have ‘run’ dependencies, but B may not. When you build (not compile) A’s
war you will not get B’s dependencies artifacts, unless you explicitly define
them with conf=’run’. (I am not may be clear about the exact resolution hurdles
and it is not a point her,
but if you try you will see the problems). So, how to fix that? :)
And now the trickiest part ever. You should define your
dependency for all modules as:
<dependencies
defaultconfmapping="*->@(default)">
<dependency …/>
</dependencies>
If you need additional help, just ask.
Aleksey
> Date: Fri, 10 Jul 2009 14:54:48 +0100
> Subject: Multi-module dependency configuration
> From: [email protected]
> To: [email protected]
>
> Hi,
>
> I'm having trouble configuring a multi-module project. It's a
> straightforward scenario, but I can't seem to get the syntax quite
> right. Here's the situation:
>
> Module A is a webapp, producing a .war artifact, and has a dependency
> on module B, which produces a jar. Both modules have a dependency on a
> third-party jar, which is provided by the servlet container at runtime
> and I therefore do not want included in the module A war file.
>
> The module B (the jar module) configuration looks like this:
>
> <ivy-module version="2.0">
> <info organisation="com.garethwestern" module="B"/>
> <configurations>
> <conf name="compile" extends="jar" />
> <conf name="jar" />
> </configurations>
> <publications>
> <artifact type="jar" conf="jar" />
> </publications>
> <dependencies>
> <dependency org="j2ee" name="j2ee" rev="1.3.1"
> conf="compile->default" /> <!-- this is the "provided" jar -->
> <dependency org="commons-beanutils" name="commons-beanutils"
> rev="1.7.0" conf="jar->default" />
> </dependencies>
> </ivy-module>
>
>
> The module A configuration looks like this:
>
> <ivy-module version="2.0">
> <info organisation="com.garethwestern" module="A" />
> <configurations>
> <conf name="compile" extends="war"/>
> <conf name="war" />
> </configurations>
> <publications>
> <artifact name="myModule" type="war" conf="war"/>
> </publications>
> <dependencies>
> <dependency org="j2ee" name="j2ee" rev="1.3.1"
> conf="compile->default"/> <!-- provided jar again -->
> <dependency org="com.garethwestern" name="B" rev="SNAPSHOT"
> changing="true" conf="compile->jar" />
> </dependencies>
> </ivy-module>
>
> In the Ant script for module A I use the cachepath task to create the
> classpath for compiling the module:
> <ivy:cachepath pathid="classpath" conf="compile" />
>
> Then, when I construct the war file, I use the cachefileset task to
> create a fileset for all files to be copied to WEB-INF/lib inside the
> war:
> <ivy:cachefileset setid="webinf-lib" conf="war" />
>
> The problem is that the com.garethwestern.B dependency is specified
> with the "compile->jar configuration" meaning that it will not be
> included in the webinf-lib fileset (which uses the "war" configuration
> to avoid including the j2ee.jar). If i change the B dependency to
> conf="war->jar" then compilation fails because the classpath is
> configured using the "compile" configuration. I thought that maybe a
> conf such as *->jar might work, but that seems to just have the same
> affect as war->jar...
>
> I'm sure that what I'm trying to achieve is incredibly simple, but
> after reading through the Ivy documentation and looking through
> various examples online my head's in a muddle at the moment, and so
> I've resorted to the mailing list. Can anyone out there help me?
>
> Thanks,
>
> Gareth
_________________________________________________________________
Hotmail® has ever-growing storage! Don’t worry about storage limits.
http://windowslive.com/Tutorial/Hotmail/Storage?ocid=TXT_TAGLM_WL_HM_Tutorial_Storage_062009