m2eclipse playing nice with nexus

At my workplace, a while ago the wonders of Apache Maven for supporting our software build processes were discovered. Soon we also had set up a local Sonatype Nexus repository with a growing number of artifacts.

Together with Eclipse and its m2eclipse plugin, everything was nice and dandy, except for the fact that the frakin local repo was not browseable with m2eclipse, and the artifacts were not found when trying to add a dependency with m2e (which kind of obsoletes the use of a nice GUI ).

The solution to this is simple, the way to the solution was annoying because my google-fu sucked in this particular case. So what’s the gist, physicist?

The problem:

When you use Eclipse with m2e, there’s a view for adding and browsing maven repos.

m2e-repoview

Normally, you can use the tree view to click your way down to versions of artifacts. If the repository is b0rked, you cannot do that.

The other problem: when you have a maven project and want to add dependencies, you can use the Add dependency dialog which offers a search function.

m2e-adddep

If a repository is b0rked, you will not find the artifacts within.

Now why is a repository b0rked (at least for m2e)?

What happens:

This blog entry helped me find the starting point: m2e logs to $WORKSPACE/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log. When you try to access a repository, you’ll see something like in the log
NexusIndexManager – Unable to update index for ait-nexus|http://1.2.3.4:8081/nexus/content/groups/public/java.io.IOException: Server returned status code 404: Not Found

Unfortunately the log did not tell me what exactly it did not find. But that one was easy to trace: fire up tcpdump and capture some packets.

sudo tcpdump -A -i eth0 -vvv -s 200 ‘dst port 8081’ -f

Then you see that this is the resource being looked for:

GET /nexus/content/groups/public/.index/nexus-maven-repository-index.gz HTTP/1.1

So m2e tries to access some kind of index file, which simply did not exist on our local Nexus. Now what?

 

The solution:

Here’s how you configure Nexus to recreate the index periodically – basically you just configure a Scheduled Task.

RepairIndexJob

Then your Nexus will start generating those nice nexus-maven-repository-index.properties files that kids these days are crazy about .

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.