1

I am working with a large open source java project that uses ant and ivy for dependency management. The project itself has a ivy.xml that specify a dependency of apache's httpclient version 3.1.

<dependency org="commons-httpclient" name="commons-httpclient" rev="3.1" conf="*->master" />

However, this project contains plugins(different ivy.xml file) that I need to work with. And the plugin itself has a library that needs httpclient version 4.5.

<dependency name="httpclient" org="org.apache.httpcomponents"  rev="4.5" force="true"/>

After running ant compile, I see that it has downloaded the jar package for both version. However, when I tried to use method from the 4.5 version in the plugin, it gave me a method not found error which indicates that it loads the older version.

So I am wondering if there's a way to force the plugin inside the project to use a specified version of a certain library without breaking the rest of the project? Thanks!

Samson Z
  • 11
  • 2
  • http://java.dzone.com/articles/java-classloader-handling – Karthigeyan Vellasamy Jun 29 '15 at 06:24
  • @Karthigeyan Thank you for your reply. I have read upon multiple class loaders solution but I don't think it works for me. For this project, it's not the code I wrote that has conflicting library. The library I am using has a transitive dependency that conflict with the dependency of the rest of the code base. – Samson Z Jun 29 '15 at 06:55
  • Is each plugin being built separately? That might explain the different ivy files. In that case it's quite ok for ivy to download multiple versions of a particular jar, provided the classpaths are kept separate for both compilation and run-time. Would need more details of how your ANT build file is setup before providing more then generic guidance. – Mark O'Connor Jul 01 '15 at 17:34
  • @MarkO'Connor Thank you for your reply. I am working with Apache Nutch. At the top level there is a build.xml,ivy.xml and ivysettings.xml. At the plugins folder there is a build-plugin.xml and build.xml. Then at each plugin there is a build.xml,ivy.xml and plugin.xml. So I would assume you are right that each plugin is being built separately. I don't know whether the classpath is separated, sorry. – Samson Z Jul 02 '15 at 05:15
  • I looked at the Nutch project a while ago: http://stackoverflow.com/questions/27721507/ivy-can-not-resolve-the-scope-of-a-dependency-which-is-a-dependency-of-a-transit/27736499#27736499 Have not revisited this work since. Are you a core developer in Nutch? – Mark O'Connor Jul 02 '15 at 06:25
  • @MarkO'Connor No, I am just developing on top of Nutch. I've read your post but I am weary that my understanding of ivy is not enough to apply your patch without breaking anything. But anyway, since you have some knowledges with nutch's ivy usage, do you think there's a solution for this problem? That a nutch plugin depends on A which depends on B that is a different version from the B that main code base is using. Again, thank you so much for your reply! – Samson Z Jul 02 '15 at 06:55

0 Answers0