Support Wikipedia

Thursday, August 9, 2012

Overriding Ivy dependency

IvyDE (the eclipse plugin for Ivy) manages dependencies by automatically downloading them from the repository. It also attaches the sources(if they are available in the repository) to binaries under the hood without any custom settings. Helps to debug the source for any dependency.

That's great but what if you are working on multiple projects at the same time and want to test/debug the new code that you are writing in a dependency module.

One way to do that is to comment out the dependency(let's call it project X) entry in ivy.xml for X and then include the source for X by adding project X to the buildpath of the main project(let's call it project A).

Now if the dependency is used in multiple  projects(say B and C) and B and C are dependencies of project A,  then you have much more work to do.
  • Comment out entries for projects B and C in project A's ivy.xml and then add project B and C to project A's build path.
  •  Comment out entries for X in project's B and C's ivy.xml
  • Add project X to the build path for projects B and C.

A quicker and much more cleaner alternative is to add the dependency (project X) to the main project's (A) buildpath and move the order of  X to the top of the classpath. In Eclipse IDE, this is available under "Order and Export" tab of "Java Build Path" menu under project properties. As shown in the picture below.

 You are done. Set a breakpoint within project X and see how it goes!

No comments:

Post a Comment