ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gareth Western <gar...@garethwestern.com>
Subject Multi-module dependency configuration
Date Fri, 10 Jul 2009 13:54:48 GMT
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

Mime
View raw message