ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xavier Hanin" <>
Subject Re: question about: Ivy option 'main'
Date Tue, 26 Jun 2007 15:21:20 GMT
On 6/26/07, Tjeerd Verhagen <> wrote:
> When I would like to make use of Ivy as a classloader for an application
> FooMain, which also depends on commons-lang,
> it is nessesary that the class, is loaded through the
> Ivy process? Or simpler said, that the class needs to ne in a 'jar' which
> is
> loaded through the Ivy process?

Yes. This is a classloader problem, if you put your FooMain class in your
java classpath, it won't have access to class loaded by Ivy classloader
(which is actually a mere URLClassloader).

But since Ivy is very flexible about its repositories, you can simply define
an additional repository in which Ivy will find your application jar. With a
pattern like [artifact].[ext], your jar can be in the directory in which you
launch Ivy and it's enough.

Another solution is to use Ivy to package your apps and its dependencies,
then use Ivy as a launcher.

I've used this technique in another open source project where you can have a
look at the build scripts if you are interested (not very well documented,
but shouldn't be too difficult to understand):
Project home:
Build script:

Have a look at the distrib target, which packages the app. You can also have
a look at the packaged application (available from the download page).

In this case I keep a public repository in my settings to make it easily
possible to change the libraries used by updating the main ivy file. But
this is not mandatory.



java  org.apache.ivy.Main  -dependency apache commons-lang 2.1  -main
> or
> java  org.apache.ivy.Main  -main
> with a ivy.xml (which contains the reference to apache commons-lang 2.1)
> This class '', must be on the classpath loaded through
> Ivy!
> And not on the normal java classapth like:
> java  -cp foo.jar  org.apache.ivy.Main  -dependency apache commons-lang
> 2.1
> -main
> Regards, Tjeerd

Xavier Hanin - Independent Java Consultant
Manage your dependencies with Ivy!

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