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
<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> |
<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>gwt-servlet</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 |