Smelly Jelly to the rescue

07 May, 2007

For a current project I use maven 1 as build tool. I always generate the eclipse plugin for generating the .project and .classpath file because I do not want to add dependencies both in the project.xml and the eclipse classpath. The eclipse plugin can also link the source files to the dependencies in your project, I find this a handy feature because you always need to debug and step through the code of some dependency.
However since the maven 1 repository is maintained even worse as the maven 2 repository you won’t find any sources jars for the newer versions of dependencies (for instance Spring 2.0). Besides this being very annoying the eclipse plugin also takes ages to finish because it gets a lot of time-outs about not being able to download the sources jars from the maven 1 repository. That’s why I created a small Jelly script that made it is possible to traverse through the maven 2 repository and grab the sources jars from there. Here’s the smelly Jelly that made it all possible:


As the maven 2 repository has a different structure I had to rebuild the complete url using all the dependency properties. This script only includes the default maven 2 repository, but with a slight modification (looping over all url’s) it can be extended with more repositories.
The add-sources goal will try to retrieve the sources jar from the maven 2 repository and install it in the local maven 1 repository. If the sources jar cannot be found it will just continue to the next one. With the postGoal you bind the add-sources to the eclipse plugin. Make sure you set the to false in your (or otherwise the eclipse plugin will still take ages to run because of all the time outs it gets from not being able to find the sources jars from the maven 1 repository.
So simply add this to your maven.xml and the sources jars will be linked again in your eclipse (don’t forget to refresh ;-)).

Explore related posts