Search code examples
javaantdependenciesivytransitive-dependency

Specify Transitive Dependencies with Ivy


Ok, so say I have a module that all of my projects build on, "Module_A", I then have "Module_B" which builds on A and finally I have my top level project which depends on B and so also needs the appropriate version of A.

Both Module A and B are being published to Artifactory using Ivy from an ant script. When I come to develop Module B I can use IvyDE to resolve my dependency on Module A.

The problem I have is when I come to develop my top level project, I specify that I am dependent on Module B and I want Module A also to be pulled from Artifactory but this doesn't happen and I'm not sure what I need to do to make it happen.

So for clarity with the following ivy file I want both Module B and its dependency Module A to appear, as if by magic, on my class path.

<dependencies>
   <dependency org="MY_ORG" name="NAME" rev="latest.integration">
      <artifact name="MODULE_B" type="jar" ext="jar" />
   </dependency>
</dependencies>

When I look at some of the jars I have resolved, say guava, this has its META-INF directory populated with a pom file. Is there an equivalent for Ivy that I need to create and bundle inside the jar?

Thanks.

Edit

I believe some of the above is incorrect and IvyDE should just be using the ivy file hosted by artifactory to determine the transitive dependencies, not looking inside a jar - when I look at the file held by artifactory it does define the transitive dependencies that I want resolved. When I look at the IvyDE cache it contains a different ivy file with a default configuration that doesn't exist in artifactory and no dependencies!

I'm getting towards the point of deciding that either Ivy, IvyDE and/or Artifactory are a waste of time... can someone please suggest what might be going wrong.


Solution

  • The problem, I believe I have resolved, by using URL resolvers rather than ibiblio. Despite using Ivy to publish to artifactory and using Ivy to resolve my dependencies I needed to use the URL resolver to allow me to specify the ivy pattern. Once I had done this my transitive dependencies started to be resolved.

    Just to note, I'm still using an ibiblio resolver for my external dependencies like junit.