Gwt and Maven Jetty Plugin

The Maven Gwt Plugin is a powerful tool in developing Gwt applications using Maven Build Management. I have set up my development environment to code and run JUnit test in eclipse IDE (without using eclipse IAM etc but the Maven Eclipse Plugin instead), and I test gwt code using the Maven Gwt Plugin, either using the gwt:run or gwt:test goals.

In combination with the Maven Jetty Plugin it is very easy to deploy Maven dependent Gwt applications into an exploded war or a packed war. Below the required plugins plus versions as well as some sample commands.

Required Plugins

Maven War Plugin

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-war-plugin</artifactId>

<version>2.1.1</version>

Maven Gwt Plugin (see repository location)

<groupId>org.codehaus.mojo</groupId>

<artifactId>gwt-maven-plugin</artifactId>

<version>2.1.1-SNAPSHOT</version>

Maven Jetty Plugin

<groupId>org.mortbay.jetty</groupId>

<artifactId>jetty-maven-plugin</artifactId>

Pom.xml Settings

The jetty server instance will require gwt-servlet.jar. Below a convenient way to define this archive as additional dependency.

<dependency>

<groupId>com.google.gwt</groupId>

<artifactId>gwtservlet</artifactId>

<version>${gwtVersion}</version>

<scope>war</scope>

</dependency>

Maven War Plugin configuration

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-war-plugin</artifactId>

<version>2.1.1</version>

 

<configuration>

<warSourceDirectory>war</warSourceDirectory>

<webXml>src/main/webapp/WEB-INF/web.xml</webXml>

</configuration>

</plugin>

Deploying & Running

Run jetty from the exploded project contents in your project’s directory with your Gwt application.

mvn gwt:compile jetty:run –Djetty.port=9990

Deploy Gwt application to a packaged war:

mvn war:war

(should trigger goal gwt:compile)

Extract a generated war and run the exploded war contents in jetty.

mvn jetty:deploy-war –Djetty.port=9998

 

 

 

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