ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xavier Hanin" <>
Subject Re: Create compile-time and runtime classpath
Date Wed, 04 Jul 2007 09:13:15 GMT
On 7/4/07, hezjing <> wrote:
> Hi!
> With Ivy, we use <ivy:cachepath> to construct the classpath. I think
> this will build a classpath containing all the dependencies in the
> cache (correct?).


How can we create, say a compile-time classpath and runtime classpath
> from the Ivy cache?
> Example, if there are A.jar; B.jar; C.jar; D.jar; E.jar in the cache,
> how do I create a compile-time classpath which contains A.jar + B.jar,
> and a runtime classpath of A.jar + B.jar + E.jar?
> Before Ivy, we used to create two path-like structures shown below,
> <path id="compile.cp">
> <pathelement location="lib/A.jar" />
> <pathelement location="lib/B.jar" />
> </path>
> <path id="runtime.cp">
> <pathelement location="bin" />
> <pathelement location="lib/A.jar" />
> <pathelement location="lib/B.jar" />
> <pathelement location="lib/E.jar" />
> </path>

You have several options here. The best is to use Ivy configurations:
declare one compile and one runtime configuration, and map your dependencies
in those configurations. Then you can call resolve to resolve both
configurations, and call cachepath twice, one for each configuration. You
will get what you want except the bin directory, so you'll still have to
build your real runtime.cp refering to the cp created by ivy:cachepath and
to your bin directory.

The other option is to use the retrieve task to copy your dependencies to
your lib directory, and build your classpath using regular Ant classpath
mechanisms. If you use configurations as above it can be very simple, use
the [conf] token when you call retrieve, then you will have your jars split
in conf directories, and it will be easy to create your paths.

Which option to choose is a matter of taste, disk space and performances
(retrieve require an additonal copy).



> Hez

Xavier Hanin - Independent Java Consultant

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message