Support Wikipedia

Thursday, May 31, 2012

Debugging dependency source with IvyDE

IvyDE an Eclipse plug-in for Ivy makes it a lot easier to work with Ivy. Some of the notable things that IvyDE does are automatic resolving of dependencies when ivy.xml is modified or the first time a project is loaded, ability to clear caches by providing a sub menu, Error checking/validation of ivy configurations and so on.
 Once you install IvyDE and enable a project to use IvyDE for managing dependencies, you lose the ability to attach a source to any of the jars in the classpath. That makes it difficult to debug the source for any dependency. The crude way I was doing it was to comment out the said dependency in ivy.xml. Saving the file should trigger a resolve on the project. That should remove the dependency from the build path. Then add the desired project to the classpath.

I found out later that it doesn't have to be that way though. IvyDE provides a neat way out. Even though there are no examples of how exactly to setup configure. After numerous trials and errors I got it working. Hope somebody else who is trying to Debug source with Ivy finds this post useful enough.

I created a tutorial at the following location. Utility is the project which publishes a binary Utility.jar and artifacts. TRY-IVY-DEBUG is the project which uses Utility.jar and has a simple class that can be used to debug into the source.
      <conf name="default" description="binary" />
      <conf name="sources" description="source codes" />
     <publications defaultconf="default">
      <artifact name="Utility" type="jar" conf="default" ext="jar" />
      <artifact name="Utility-sources" type="source" conf="sources" ext="zip" />
There are two configurations defined, default and source. The description attribute is self explanatory. The artifacts are Utility.jar and Utility-sources. The key here is type=”source”. That's one of the two things IvyDE is looking for when trying to bind the sources to the jars. The other requirement is that the source artifact name suffix needs to match the ones in default IvyDE configuration as shown below.
If you load the two projects mentioned above in eclipse. Build the Utility project using the included build.xml and perform a resolve on the TRY-IVY-DEBUG project. That should make eclipse download and attach the to the Utility.jar artifact.You should now be able to debug class and step into the attached source.

No comments:

Post a Comment