Visitors are also reading...
← PreviousNext →

About Running Maven Plugins and Running Maven Jetty Plugin

21 Nov 2012

When I followed tutorials and guides for using Maven Jetty Plugin
I kept seeing the same instructions saying:

mvn jetty:run

But when I tried it, I kept getting failures.
So I investigated and here is what I found.

Executing A Maven Plugin

When you run a Maven plugin you may use the following pattern

mvn groupId:artifactId:version:goal

However, this is quite long and exhausting. So Maven came up with a method to shorten the command.
As an example, we will have a look at the Jetty Maven Plugin.
The full command for running it with version: 7.2.0.v20101020 is:

mvn org.mortbay.jetty:jetty-maven-plugin:7.2.0.v20101020:run

Plugin Groups

The Plugin Groups is a settings configuration.
Without this, you won't be able to shorten the command.
If you go to your settings.xml file (under %M2_HOME%/conf)
search for pluginGroups section and you can specify a pluginGroup by adding:


You might think that by adding this line, you can simply get rid of the groupId section in the plugin execution.
Apparently, you cannot.
First of all - if you want to specify the version, you must specify the groupId as well.
If you do not specify the groupId, you must not specify the version.
You can control the version by specifying details in the POM like so:


If the plugin's artifaceId has one of the following patterns:

you cannot specify the entire artifaceId.
Instead you need to specify only the "prefix" part.
Since the Jetty Maven Plugin suites the second pattern, we need to replace the artifactId with simply "jetty".
Once you remove the groupId, version and switch artifactId to "jetty" you get the famous command:

Mvn jetty:run

The pluginGroups section support the following values by default:

so if you set your groupId to once of these, you won't need to modify the settings.

Feature Or Bug?

Seems to me that the expected behavior would be :


← PreviousNext →