1

I add a dependency(let's name it as A) to ivy.xml which has a pom file in maven central. Ivy uses ibiblio for resolving the maven dependencies. The dependency(A) which is added to ivy.xml has a transitive dependency(B). So far so good till here. The dependency(C) of transitive dependency(B) can not be resolved by ivy.

I defined A in ivy.xml like this:

<dependency org="Z" name="A" rev="0.6-SNAPSHOT" conf="*->default"/>

In pom file of B, C is defined both in compile and test scopes like below:

<dependency>
      <groupId>X</groupId>
      <artifactId>C</artifactId>
    </dependency>
    <dependency>
      <groupId>X</groupId>
      <artifactId>C</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
</dependency>

When I look the xml file of B which is resolved by ivy in ivy's cache file(~/.ivy2/cache/X/C/ivy-0.98.8-hadoop2.xml), it looks like this:

<dependency org="X" name="C" rev="0.98.8-hadoop2" force="true" conf="test->runtime(*),master(*)"/>
<dependency org="X" name="C" rev="0.98.8-hadoop2" force="true" conf="test->runtime(*),master(*)">
  <artifact name="C" type="test-jar" ext="jar" conf="" m:classifier="tests"/>
</dependency>

For this reason, ivy can not define C scopes correctly. For the record, I don't have permissions to modify the pom files as they are third party projects. How can I fix it ?

Talat
  • 68
  • 7
  • I'm quite new to Maven, but in my environment it won't pull the dependency down if the `version` element isn't included with the group and artifact ID's in the pom.xml - does that help? – Michael Dec 31 '14 at 13:19
  • pom file of B is a child pom. Because of that it has not version tag. BTW if I use A in a maven project there is not problem. I think ivy can not map correctly sub dependency's scope of B. – Talat Dec 31 '14 at 14:06
  • If the module is in Maven Central why not just give it as an example? As it stands I don't understand what the problem is. – Mark O'Connor Dec 31 '14 at 17:00
  • You are right @mark-oconnor . I guess I gave example because I wanted to tell problem. For concretization I give real names. I develop Nutch's Hadoop 2 support. Nutch 2 use Apache Gora for reach to Apache Hbase. Apache Nutch use ant+ivy. When I build Nutch, gora-hbase dependency and its transitive dependency hbase-client is fetched. However hbase-client's hbase-common and hbase-annotation dependencies are resolved in test scope. But they are runtime scope at the same time. Their confs is "test->runtime(*),master(*)". When I try to run Nutch did not find and throw exception. Is it clear ? – Talat Dec 31 '14 at 19:11
  • BTW hbase-protocol is depended by hbase-client too. But it resolved and fetched. Its conf is compile, master(*), runtime, compile(*), runtime(*), master. It do not have any test scope defination on hbase-client pom. I think this cause the problem. @MarkO'Connor – Talat Jan 01 '15 at 07:34
  • Apologies...I checked the Nutch project code and could not find a dependency on Apache gora, perhaps you're working on a fork? IMHO the ivy setup for Nutch is overly complex. As one of the developers do you think the project would be open to some refactoring of how ivy is being used? All I can do for now sorry. – Mark O'Connor Jan 01 '15 at 14:43
  • By th default gora dependecies come as comment. You can see there https://github.com/apache/nutch/blob/2.x/ivy/ivy.xml#L120 I use a fork version for Gora. If you want to figure out I can create a maven repo for my gora version. Actually If you understand my problem, Do you know How can I override hbase-common's conf attr is defined in hbase-client ivy xml from Nutch's ivy.xml ? If I figure out that, I can fix my problem. At the present I change manually from ivy2/cache/org.apache.hbase/hbase-client/ivy-0.98.8-hadoop2.xml and it works. – Talat Jan 01 '15 at 16:08
  • I guess Ivy does wrong mapping because of two times defined hbase-common dependecy in hbase-client's pom. https://github.com/apache/hbase/blob/master/hbase-client/pom.xml#L109 In Hbase-clinet Ivy resolve xml, hbase-common define two times like: `` – Talat Jan 01 '15 at 16:21
  • Actually It should defined first dependency in compile scope. Ivy can not resolve correctly. If I can intervene to hbase-common's first dependency definition's conf attr I can fix it. Is it possible @MarkO'Connor ? – Talat Jan 01 '15 at 16:24
  • Just for completeness I added the following dependency to my new ivy.xml file "" BUT **hbase-client is not retrieved** as a transitive dependency as you've described.... Digging deeper I discovered version 0.94.14 of hbase is retrieved which doesn't have hbase-client as a dependency (See: https://repo1.maven.org/maven2/org/apache/hbase/hbase/0.94.14/hbase-0.94.14.pom) BTW having a single ivy report makes this analysis a lot simpler. – Mark O'Connor Jan 02 '15 at 03:00
  • @MarkO'Connor Sorry for late response.Hbase change their module architecture.hbase-client is created after hbase0.96.I realize it does not depend with gora dependency.Can you add in ivy.xml for generate problem?You can see at ~/.ivy2/cache/org.apache.hbase/hbase-client/ivy-0.98.9-hadoop2.xml hbase-annotaion and hbase-coomon dependencies should be in compile scope but Ivy maps to runtime scope.Actually they are defined compile and test scope in hbase-client pom.IMHO This's bug about maven resolving. – Talat Jan 02 '15 at 20:19
  • I think your issue is how you're defining your configuration mapping "*->default". You're saying that the remote "compile" scope (which is the default configuration) should be mapped to all local configurations. Is this intentional? BTW Maven scopes and ivy configurations are not the same thing. – Mark O'Connor Jan 02 '15 at 20:34
  • Does nutch intend to abandon ivy? (NUTCH-1371) Are you interested in a refactor? I have started this work, but am having difficulties understanding the purpose of the plugins and job artifacts. Not a simple build :-) – Mark O'Connor Jan 02 '15 at 20:39
  • I wrote a comment at below your post. No we still continue use ivy. We will be glad, if you refactor our ivy architecture. – Talat Jan 02 '15 at 21:02
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/68102/discussion-between-talat-and-mark-oconnor). – Talat Jan 02 '15 at 21:02
  • How should I define hbase-client conf ? hbase-annotations, hbase-common, hbase-protocol should in compile scope of hbase-client. – Talat Jan 02 '15 at 21:09

1 Answers1

1

I reviewed the ivy usage of the nutch project and apologies but my conclusion is that it's overly complex for the following reasons:

  • "compile" and "test" targets are issuing separate calls to the resolve task
  • Each plugin is also calling an ivy resolve task
  • Complex logic for maintaining classpaths. Could be simplified using the cachepath task and ivy configurations.
  • Build plugins are not managed by ivy (Sonar, eclipse, rat)

I started to refactor the build, but had to stop when I realised that I didn't understand the relationship between the main nutch artifact and the plugins... (I discovered NUTCH-1515 the hard way... big time-waster The feed plugin has missing dependencies).

I also noticed issue NUTCH-1371 calling for the removal of ivy. This would be a tricky refactoring without significant change to the current codebase. I suspect it would have to be a multi-module build with each plugin listing its own dependencies.

In conclusion, this work does not answer your question, but thought I needed to at least document the result of a few hours analysis :-) In light of NUTCH-1371 I don't know if your project will tolerant major ivy refactoring?

Refactoring ivy

Here follows what I achieved so far:

Benefits:

Impacts the following Nutch issues

  • NUTCH-1881 : This new approach removes resolve-test and resolve-default targets and manages the classpaths using ivy instead of the ${build.lib.dir}
  • NUTCH-1805 : Can easily setup a separate configuration for the job target with it's own dependencies.
  • NUTCH-1755 : I think this one is fixed by assigning a name to the the build.xml (see: diff)
Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • you are really amazing. Thank you very much. Your work is wonderful. I will review and create a patch if you are ok. Yes we talk about maven at the present maven is not suitable for us. I guess we still continue to using ivy. If you want to help us for our ivy problem, We will be appreciated. – Talat Jan 02 '15 at 20:58
  • @Talat I wasn't ready to submit my own patch, as I was unsure whether my changes were 100% backwardly compatible. I would appreciate the review. I'd be happy to help. – Mark O'Connor Jan 02 '15 at 23:02