GWT 1.6.4 maven and google eclipse plugin

Uki and I wanted to switch our application to using GWT 1.6.4, still use maven for our dependencies, and be able to use the google eclipse plugin to run our gwt application from. By no means have we even come close to making a perfect solution, but it is a start.

1. Create a new web application project using google's eclipse plugin.

2. Create a folder called maven/resources (we use this for resource filtering).

3. Create a pom.xml that looks something like this (we run this using ant and don't use the eclipse plugin):
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelversion>4.0.0</modelversion>
<groupid>Application</groupid>
<artifactid>Application</artifactid>
<version>1.0</version>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>maven/resources</directory>
<excludes>
<exclude>*.properties</exclude>
</excludes>
</resource>
</resources>
<filters>
<filter>maven/resources/${target}.properties</filter>
</filters>
</build>
<dependencies>
<dependency>
<groupid>com.google.gwt</groupid>
<artifactid>gwt-servlet</artifactid>
<version>1.6.4</version>
</dependency>
<dependency>
<groupid>com.google.gwt</groupid>
<artifactid>gwt-user</artifactid>
<version>1.6.4</version>
</dependency>
</dependencies>
</project>


4. Create a build.xml file that looks like this:
<project name="Application" default="copy_jars" basedir=".">

<property name="GOOGLE_WAR_LIB" value=".\\war\\WEB-INF\\lib">
<property name="MAVEN_TARGET_JARS" value=".\\target\\Application-1.0\\WEB-INF\\lib">
<property name="GOOGLE_SRC" value=".\\src">
<property name="MAVEN_TARGET_RESOURCES" value=".\\target\\classes">
<property file=".\\maven\\resources\\${user.name}.properties">

<target name="maven_war">
<echo>Maven Executable: ${MAVEN_EXEC}</echo>
<exec taskname="mvn war" dir="${basedir}" executable="${MAVEN_EXEC}">
<arg line="clean resources:resources war:war -Dtarget=${TARGET}">
</arg>
<delete file=".\\target\\csd.war">
</delete>

<target name="copy_jars" depends="'copy_filtered_resources'">
<copy todir="${GOOGLE_WAR_LIB}">
<fileset dir="${MAVEN_TARGET_JARS}">
</fileset>
</copy>

<target name="copy_filtered_resources" depends="'maven_war'">
<copy todir="${GOOGLE_SRC}">
<fileset dir="${MAVEN_TARGET_RESOURCES}">
</fileset>
</copy>
</project>


5. Remove from the war/WEB-INF/lib folder the gwt-servlet.jar that the google eclipse plugin (gep) added for you automatically.

6. Run ant (ignore any errors about a missing web.xml file, we will update the pom and build files later to hopefully get rid of this issue).

7. Edit the projects build path, project > properties > Java Build Path > Libraries, and add all of the jars in the war/WEB-INF/lib folder.

8. Run the project as a google Web Application, Run > Run As > Web Application.

Every time you add/remove dependencies to your pom you must rerun the ant task and add/remove those jars from your build path.
Also if you change any files in the maven/resources folder you must rerun the ant task.

I definitely don't like having a seperate folder to keep my resource files that have to be filtered, and I also don't like that we have to use ant to run maven to basically just copy the jars into the right folder, then to add them to the build path. But at least it runs using google's eclipse plugin as well as being able to somewhat use maven for the dependencies.


As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles