New GWT Maven Project

Background

There have been many approaches to getting a project going under Eclipse that supports Maven and GWT. This one also pulls in the git tool for source control.

Future Directions

Pre-Requisite

Steps

  1. If you don't have a git repo created, do this first.
  2. cd to the root of the git repo so all the generated files show up under that repo's file system.
  3. Use Maven and the gwt-maven-plugin from org.codehaus.mojo to generate a new maven-aware GWT WAR project. The archetypeVersion matches the GWT version you wish to use in the project.
mvn  archetype:generate \
-DarchetypeGroupId=org.codehaus.mojo \
-DarchetypeArtifactId=gwt-maven-plugin \
-DarchetypeVersion=2.7.0
  1. You'll be asked the group, artifactId and so on. If you screw up, it's easy to delete the whole thing and start over again.
  2. After the structure is created, you'll want to turn this project (with its new pom.xml) into an eclipse project (with a .project file). Do this by running
cd <newly created module directory>
mvn eclipse:eclipse
  1. From inside eclipse — which has a workspace outside of the git repo — import "General -> Existing Projects into Workspace".
    1. The root directory will be the repo; once selected, the newly created project should show up in the list of "Projects:".
    2. Leave "Copy projects into workspace" unselected.
    3. Add to working sets if you prefer (recommended)
  2. From there, the project will be brought in, compiled and there will perhaps be an error regarding the location of the output classes (shown in the "Problems" tab). I used CTRL-1 to offer quick fixes and chose to alter the output folder to be WEB-INF/classes
  3. It may also be necessary to manually tell Eclipse that this is a Maven project (right-click, Configure -> Convert to Maven Project)
  4. I also got the "lifecycle configuration" error for a the generate-sources phase. This is resolved by the CTRL-1 quick fix and selecting to ignore those targets/goals.
  5. There was also an error for the ClassPath being unrecognizable: http://stackoverflow.com/questions/10564684/how-to-fix-error-updating-maven-project-unsupported-iclasspathentry-kind-4
  6. Once you've confirmed the code is what you want to keep, you can use the Git Repository view to add and commit the new project's files.

Historical

This archetype from the mGWT (mobile GWT) is something I had used with success, but the archetype doesn't appear to be provided any longer as of Aug, 2014. The mGWT website (https://github.com/mgwt/mgwt/wiki/Getting-started-with-mgwt) remains useful.

mvn archetype:generate -DarchetypeRepository=http://www.m-gwt.com/m2/repo \
-DarchetypeGroupId=com.googlecode.mgwt.archetypes \
-DarchetypeArtifactId=mgwt-standard-archetype \
-DarchetypeVersion=1.0.8
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License