jetty-maven-plugin

It’s been a while since I used the Jetty Maven plugin. I really liked it, though, because it always allowed me to launch my service rapidly from the command line as a part of a build, without having to worry about starting/stopping a service, moving around jars and wars, etc.

Some people really like the Tomcat or Jetty integration right inside Eclipse, but I just never really took a liking to that.

I discovered yesterday, for the project that I’m on, that there’s a new version of the Jetty plugin for Maven. This setup goes into the <build><plugins> section of the pom. It doesn’t require any additional dependencies.


<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.0.0.pre5</version>
<configuration>
<useTestClasspath>true</useTestClasspath>
<webAppConfig>
<contextPath>/</contextPath>
</webAppConfig>
</configuration>
</plugin>

Note that I tied it to 7.0.0.pre5, but you can delete the <version> element altogether. However, if you delete it, then maven prints a warning.

To launch it, use:

mvn jetty:run

Although I usually do a cleanup as a part of the launch:

mvn clean jetty:run

Then the base URL (note that I set the contextPath to / above) is:

http://localhost:8080/...myservlet...

The one snag I hit is that I had to go into my maven/conf settings.xml and add this element:


<pluginGroups>
<pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>

…I saw some other posts around the blog, and no one was sure why that was necessary. For some reason, the invocation of the jetty plugin was tripping over an org.apache jetty plugin.

For more documentation on the plug-in, see:

http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin

This version of the plug-in is a replacement for the 6.0 plugin.

Advertisements

Leave a comment

Filed under servlets

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s