You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Jim Garrison <Ji...@troux.com> on 2009/09/18 19:48:06 UTC

Ivy and Maven Repository with nth-level transitive dependencies in POMs

Ivy newbie here.

We have a fairly large project with dependencies on maybe 40 open-source packages available from Maven (we have a local Nexus repository for caching).

Many of these open-source packages have their own dependencies, expressed in their POM files.  From reading the Ivy docs, I believe I'm correct in stating that those dependencies, and any further transitive dependencies, would not be processed by Ivy since Ivy doesn't do POMs.

Do I have to hand-build that web of dependencies, to ensure that all the required libraries get retrieved, or is there a tool to POM dependencies into Ivy files, and maintain them as the underlying POMs change?

Thanks in advance

Re: Ivy and Maven Repository with nth-level transitive dependencies in POMs

Posted by Mitch Gitman <mg...@gmail.com>.
Jim, there are two approaches you can take to integrating your Maven
repository.

To build on what Geoff wrote, one is just to consume it directly, as if it
were an Ivy repository, without converting it to an Ivy repository. So in
your ivysettings.xml, you would have an entry like so, replacing the Maven2
public URL with your own Nexus URL:
    <ibiblio name="maven2.resolver" m2compatible="true" root="
http://repo1.maven.org/maven2" />

See:
http://ant.apache.org/ivy/history/trunk/resolver/ibiblio.html

The other approach is to convert your Maven repository into an Ivy
repository. Now, if you're satisfied with the dependencies Maven has
established (if you think Maven has made the right choices about what
library depends on what) and you are using Nexus rather than having to hit
the public Maven 2 repo, then you probably don't need to do the conversion.

But anyway, to convert a Maven repository to an Ivy repository--or rather to
copy certain modules in a Maven repository to an existing Ivy
repository--you would use the ivy:install Ant task. See:
http://ant.apache.org/ivy/history/trunk/use/install.html

The ivy.xml files that get generated are good to go, although if you weren't
satisfied with consuming your Maven repository directly in the first place,
then you probably want to manually massage them.

The reason I'm answering this question myself is because I have a question
myself from running into that very matter of manually massaging the ivy.xml
files generated from a Maven repository. My issue involves all the optional
dependencies that show up in the ivy.xml corresponding to Maven's optional
scope. Actually, this is more of a Maven question because I'm trying to
reverse-engineer Maven's thinking about this. But in Maven, how does one
control optional dependencies for a given module? Do you say, "Give me all
the optional dependencies for module A?" vs. "Give me none?" Can you pick
and choose which optional dependencies you get, and how?

OK, I think I've just put together a question that is better asked on the
maven-user list. But the Ivy part of this question is, how do you translate
optional dependencies into an Ivy paradigm? My suspicion is that this is a
case where Ivy confs come into play, and for lack of having the equivalent
of confs for each optional dependency (or valid combination thereof), Maven
possibly suffers from a certain information loss.

On Fri, Sep 18, 2009 at 11:13 AM, Geoff Clitheroe <g....@gmail.com>wrote:

> Hi Jim,
>
> Ivy will use Maven repos (e.g.,
> http://mirrors.ibiblio.org/pub/mirrors/maven2/) and fetch transitive
> dependencies without any additional work (it will read the POMS).
> We've been using it like this with great success.  You will run into
> Maven projects with bad or incorrect POM specs and have to fix them or
> work around them but this tends to be older projects.  Ivy roundup is
> worth a look if this becomes a problem
> http://code.google.com/p/ivyroundup/
>
> Also, some projects may have dependencies in the 'wrong' configuration
> and need a manual exclude:
>
> <dependency org="org.apache.activemq" name="activemq-pool" rev="5.2.0"
> conf="provided->default">
>                <exclude module="spring-beans"></exclude>
>        </dependency>
>
> There are also some things you just can't get from a repo (e.g., some
> DB drivers).  We run our own 'manual' repo for this with hand rolled
> skeleton ivy files.  If you're already using Nexus and caching locally
> then you're well advanced anyway.
>
> Cheers,
> Geoff
>
>
>
> On Sat, Sep 19, 2009 at 5:48 AM, Jim Garrison <Ji...@troux.com>
> wrote:
> > Ivy newbie here.
> >
> > We have a fairly large project with dependencies on maybe 40 open-source
> packages available from Maven (we have a local Nexus repository for
> caching).
> >
> > Many of these open-source packages have their own dependencies, expressed
> in their POM files.  From reading the Ivy docs, I believe I'm correct in
> stating that those dependencies, and any further transitive dependencies,
> would not be processed by Ivy since Ivy doesn't do POMs.
> >
> > Do I have to hand-build that web of dependencies, to ensure that all the
> required libraries get retrieved, or is there a tool to POM dependencies
> into Ivy files, and maintain them as the underlying POMs change?
> >
> > Thanks in advance
> >
>

RE: Ivy and Maven Repository with nth-level transitive dependencies in POMs

Posted by Jim Garrison <Ji...@troux.com>.
> -----Original Message-----
> From: Geoff Clitheroe [mailto:g.clitheroe@gmail.com]
> Sent: Friday, September 18, 2009 1:14 PM
> To: ivy-user@ant.apache.org
> Subject: Re: Ivy and Maven Repository with nth-level transitive
> dependencies in POMs
> 
> Hi Jim,
> 
> Ivy will use Maven repos (e.g.,
> http://mirrors.ibiblio.org/pub/mirrors/maven2/) and fetch transitive
> dependencies without any additional work (it will read the POMS).
> We've been using it like this with great success.  You will run into
> Maven projects with bad or incorrect POM specs and have to fix them or
> work around them but this tends to be older projects.  Ivy roundup is
> worth a look if this becomes a problem
> http://code.google.com/p/ivyroundup/
> 
> Also, some projects may have dependencies in the 'wrong' configuration
> and need a manual exclude:
> 
> <dependency org="org.apache.activemq" name="activemq-pool" rev="5.2.0"
> conf="provided->default">
>     		<exclude module="spring-beans"></exclude>
>     	</dependency>
> 
> There are also some things you just can't get from a repo (e.g., some
> DB drivers).  We run our own 'manual' repo for this with hand rolled
> skeleton ivy files.  If you're already using Nexus and caching locally
> then you're well advanced anyway.


OK, I got that to work, but there's something fundamental I still don't get.  When I give activemq as a dependency, Ivy retrieves huge gobs of stuff I know isn't needed just to use activemq, such as jetty, derby and  geronimo.  

If I set usepoms="false" in ivysettings.xml it fetches only activemq.jar, but that defeats the purpose of Ivy and relegates it to a simple jar-fetcher.

There's a bigger issue here, what used to be called "DLL Hell" in Windows.  We depend on 40 or so OSS packages, many of which have common dependencies on other packages.  In some cases, two first-level dependencies will need different versions of the same transitive dependency, which Java doesn't handle at all (without custom classloaders - yuck).  Keeping things working seems like it will require manually specifying the version of just about everything -- finding that one version of, say, log4j et al that works with everything else we need. 

Or, am I missing something here?

Re: Ivy and Maven Repository with nth-level transitive dependencies in POMs

Posted by Geoff Clitheroe <g....@gmail.com>.
Hi Jim,

Ivy will use Maven repos (e.g.,
http://mirrors.ibiblio.org/pub/mirrors/maven2/) and fetch transitive
dependencies without any additional work (it will read the POMS).
We've been using it like this with great success.  You will run into
Maven projects with bad or incorrect POM specs and have to fix them or
work around them but this tends to be older projects.  Ivy roundup is
worth a look if this becomes a problem
http://code.google.com/p/ivyroundup/

Also, some projects may have dependencies in the 'wrong' configuration
and need a manual exclude:

<dependency org="org.apache.activemq" name="activemq-pool" rev="5.2.0"
conf="provided->default">
    		<exclude module="spring-beans"></exclude>
    	</dependency>

There are also some things you just can't get from a repo (e.g., some
DB drivers).  We run our own 'manual' repo for this with hand rolled
skeleton ivy files.  If you're already using Nexus and caching locally
then you're well advanced anyway.

Cheers,
Geoff



On Sat, Sep 19, 2009 at 5:48 AM, Jim Garrison <Ji...@troux.com> wrote:
> Ivy newbie here.
>
> We have a fairly large project with dependencies on maybe 40 open-source packages available from Maven (we have a local Nexus repository for caching).
>
> Many of these open-source packages have their own dependencies, expressed in their POM files.  From reading the Ivy docs, I believe I'm correct in stating that those dependencies, and any further transitive dependencies, would not be processed by Ivy since Ivy doesn't do POMs.
>
> Do I have to hand-build that web of dependencies, to ensure that all the required libraries get retrieved, or is there a tool to POM dependencies into Ivy files, and maintain them as the underlying POMs change?
>
> Thanks in advance
>