Used to be that getting a GWT project together using Maven and Eclipse was a tedious and frustrating task. Times have changed so that the process is quite a bit easier.
Google plugin for Eclipse 1.32 http://code.google.com/intl/en/eclipse/
gwt-maven-plugin 1.2 http://mojo.codehaus.org/gwt-maven-plugin/
Maven plugin for Eclipse 0.10.0 http://m2eclipse.sonatype.org/
Install the Google plugin for Eclipse into eclipse specifying the update site url http://dl.google.com/eclipse/plugin/3.5 through Eclipse’s Help->Install New Software->Add… and specify the url
If you have a previous version of the m2 plugin you will need to uninstall it as the 0.10.0 version will not upgrade properly otherwise. Install the Maven plugin.
From Eclipse, create a new Maven project:
Do not check Create a simple project as we want to do archetype selection, but fill the rest in as you see fit then click Next.
Select either Nexus Indexer or All Catalogs as the catalog, then scroll down the list looking for a Group Id of org.codehaus.mojo with an Artifact Id of gwt-maven-plugin and choose the highest version (1.2 at this time) then click Next.
Fill in your Group Id and your Artifact Id and the rest of the fields and click Finish.
The next set of the instructions are mostly from http://code.google.com/intl/en/eclipse/docs/faq.html#gwt_with_maven.
In Eclipse, select your project then choose Project->Properties->Google->Web Toolkit and click Use Google Web Toolkit.
Then click on Web Application (Project->Properties->Google->Web Application and change the War Directory to src/main/webapp and uncheck Launch and deploy from this directory then click OK.
Open the pom.xml file under your project and check some Properties values. You want gwt-version to be 2.0.3 and maven.compiler.source and maven.compiler.source to be 1.6.
Right click on your project and select Run As->Maven Clean, then Run As->Maven Package.
Right-click your project and select Run As->Web Application. The first time you do this, you’ll have to select the location of the exploded WAR directory (by default it should be /target/–).
If everything works out fine, you are now running in hosted mode. Click on the Development Mode view tab down where the Console tab is and copy and paste the URL shown there into a browser to see your app running.
GWT development/hosted mode is now running out of the WAR directory created by Maven. You can step through and debug your code as usual. If you make changes, it is sometimes possible to have your running application reflect those changes without restarting your debugging session:
- If you change client-side code, just click Refresh in your browser.
- To have server-side code changes reflected, your project’s build output path must be set to /target/–/WEB-INF/classes (Project properties > Java Build Path > Source > Default output folder). Then, when you change a server-side class click the Reload web server button in the Development Mode view.
- If you change resource or configuration files in your WAR directory (HTML, JSP, CSS, etc.), you’ll have to terminate the launch configuration, run mvn clean package, and then launch again.