Nexus, a Maven Repository Manager

26. July, 2008

If you’re using Maven in a corporate environment, then you’re struggling with the same problems all over again: How to make sure that the build builds?

While a simple task at first glance, there are a few hidden obstacles which boil down to two things: Downloads via the Internet and plugin or dependency version stability. Both can be solved by a using a proxy or a in-house repository.

The guys from Sonatype have been busy in the last months and have released Nexus 1.0.0-beta-4.2 which gives you another option to chose from besides Archiva or DSMP (my own Maven 2 proxy). I’ve tried Nexus yesterday and I have to say that I’m very pleased with the result. As usual for Open Source Software, the beta is more stable than some post-beta commercial products and it delivers with very little setup (follow the link to see the documentation).

Now, we have a second issue: version stability. Here is my recipe to achieve that. First of all, version anything in your POM. All dependencies, all plugins, everything. I’m using properties for that which I define in a common parent POM plus I’m using the dependency management. Maven 2.0.9 helps a lot here because it forces you to add version elements everywhere.

The next step is to make sure the maven builds can find their stuff. To do that, I suggest to set up two Nexus repositories. The first one is the “build” repository, the second one is the “cache” repository. While all developers should use the “build” repository, the “cache” repository can actually download dependencies from the Internet.

The “build” repository, on the other hand, is just a local repository with no Internet connection. To avoid mistakes, I suggest to install the build repo with the default settings but with all remote repositories deleted or turned into local ones. The “cache” repository should run on an unusual port and with the remote repositories enabled as described in the installation documentation.

Next, you need to create a profile in your settings.xml which switches mirrors between the two. When you want to check out a new version of some plugin, switch to the cache repository and have it download all the new stuff. This will pollute your local copy of the maven repository but only yours. After you have verified that the build completes (or fixed all the problems you’ve got), check the RSS feeds of Nexus for stuff it downloaded. Then, all you have to do, is to copy those to the “build” repository. After a refresh, all the other developers in your company can use the new, verified downloads.

Clean your local repository and build again to make sure that your colleagues won’t have any problems after the change and you’re set.

Jazoon: Spring and Maven 2

26. June, 2008

After some technical difficulties (the only ones I saw during the whole show, well done Jazoon!), we got a short company placement. One or two sentences, next slide, that’s how it’s ought to be (if at all; I mean if I was interested in your company, I’d look at the web site and not at the presentation but I digress).

They presented the EL4J project which is the result of several years of developing web applications. From what I gathered, it makes it a bit more simple to wire web apps together using a bit of convention over configuration and Maven 2. It also has some Swing support in it.

IllegalStateException: The PluginDescriptor for the plugin … was not found

14. April, 2008

Ever saw this error?

java.lang.IllegalStateException: The PluginDescriptor for the plugin Plugin [org.apache.maven.plugins:maven-resources-plugin] was not found.
        at org.apache.maven.plugin.DefaultPluginManager.addPlugin(
        at org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin(
        at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindLifecycleForPackaging(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappings(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(
        at org.apache.maven.DefaultMaven.doExecute(
        at org.apache.maven.DefaultMaven.execute(
        at org.apache.maven.cli.MavenCli.main(

When you see this, check:

  1. That the JAR file of the plug-in is okay and that it contains a file META-INF/maven/plugin.xml
  2. That the pom.xml of the plug-in exists and is valid.
  3. That all parent POMs exist and are valid.

Good luck. I’ve opened this issue to get a better error message.

Downloading Sources for Maven2 Projects

25. September, 2007

If you ever needed to download the source artifacts for a Maven2 project, there were several options: If you use the Eclipse plugin (either the Eclipse plugin for Maven2 or the Maven Plugin for Eclipse, also called “Maven Integration for Eclipse”), you can use the option -DdownloadSources=true from the command line or enable the “Download sources” preferences option.

Both have some drawbacks. When you use the Maven Plugin in the Eclipse IDE, it will try to download the sources all the time which blocks the workflow. If you just want to do it once, you have to enable and disable the option all the time plus you have to force the plugin to start the download (with 0.12, you can add and delete a space in the POM and save it). But it will only download the sources for a single project.

If you use the command line version to download the sources, it will overwrite the .project file and modify your preferences, etc. Also not something you will want.

There are two solutions. One would be the “-Declipse.skip=true” option of the command line plugin. Unfortunately, this option doesn’t work. It will prevent the plugin from doing anything, not only from writing the project files.

So if you have a master POM which includes all other projects as modules and all your projects are checked into CVS, you can run:

mvn eclipse:eclipse -DdownloadSources=true

to download all sources and then restore the modified files from CVS. I’ve opened a bug which contains a patch for the skip option. After applying it, -Declipse.skip=true will just skip writing the new project files but still download the source artifacts.