GWTMaven-1.6

This page benefits from the fine work found on Salvador Diaz's blog. This describes the first-time setup of a Maven GWT 1.6.x project inside Eclipse.

Create shell project

  • Starting at the root of my Maven Projects source directory and running this archetype. This is the snapshot revision rather than a released revision. It appears I don't need a) to use the SNAPSHOT version and b) can use the Maven plugin template to create the project within Eclipse. The method below is good if you want to keep your source directory outside of the Eclipse workspace, although I'm not seeing a substantial advantage, particularly if you import the maven project from SCM (such as Subversion) as described on the page GWTMaven-1.6FromSCM
$ mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin \
-DarchetypeVersion=1.1-SNAPSHOT -DarchetypeRepository=http://snapshots.repository.codehaus.org/ \
-DgroupId=com.jettmarks.gmaps -DartifactId=gwtMaps3
  • Imported the project into Eclipse using the Maven Projects wizard. All defaults are OK.

POM Config

(<gwt.module.alias>Application</gwt.module.alias>) that we will come back to later.

Set Application Name

This is also an opportunity to rename the application from the default name ("Application") to something more descriptive.

  • Add 'rename-to="«your Application»"' to the GWT module declaration file (Application.gwt.xml).
    • Example: <module rename-to="showRoutes"> instead of <module>
    • This file should then be moved to the src/main/webapp folder.
    • This file replaces the index.html that is located there and which should be deleted.
  • Open the web.xml file located in src/main/webapp/WEB-INF and change the value of the welcome-file to Application.html.

m2eclipse plugin config

  • Following Salvador's instructions.

Create Eclipse Launch

  • Following Salvador's instructions.

Running the App

  • The /Application.html isn't found when I first try this. This is controlled by the startupUrl parameter to the Hosted Mode executable. It needs to refer to a path relative to the ${gwt.output.directory} .
  • I also notice that the target/gwt isn't populated. Not sure what maven goal should be used, but I've tried package. This should be automatically populated by a couple of things: making sure ${gwt.output.directory} is set to ${basedir}/target/gwt and making sure the gwt-maven-plugin is bound to the process-classes phase and the compile goal:
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>1.1-SNAPSHOT</version>
        <executions>
          <execution>
            <phase>process-classes</phase>
            <configuration>
              <output>${gwt.output.directory}</output>
              <logLevel>INFO</logLevel>
            </configuration>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
  • When I tried package as the goal, it complained about the directory target/gwt/Application did not exist. I created this and the package goal completed successfully.
  • This did not allow Application.html to be found.
  • I switched the URL to be Application and this allows picking up the /Application/Application.html file, but at that point, the nocache.Application.js file is in the wrong relative directory.
  • I found that when the launch occurs, the Application.html from the java/src/main directory is copied in; not the one in the src/main/webapp as you would expect from the instructions listed above. There are a number of files that are taken from the ${basedir}/src/main/java/ side instead of the ${basedir}/src/main/webapp/ side. I think this has to do with what needs to be presented to the GWT compiler versus what needs to be presented to the webapp/war packaging. This could be one of the rough spots that Salvador Diaz refers to.

Multi-module

  • Brought in separate showRoutes.gwt.xml file.
  • Got it to compile by setting up a separate run configuration (Eclipse Launch) with the following arguments:
-logLevel INFO
-war .
-startupUrl showRoutes
com.jettmarks.gmaps.showRoutes
  • Make sure the working directory is the location where the files are being placed: ${workspace_loc:gwtMaps3/target/gwt}

web.xml shortcut

I was wondering if there was a better way to have multiple modules reference the same set of services. A discussion of exactly this happened right here:

Other Notes

  • I found I had to explicitly import the version 1.6.4 of the gwt-user.jar file. Although the gwt-version property was set to 1.6.4, the dependency management automatically chose version 1.5.3. This led to an exception when loading the MapPanel about an object being expected.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License