Thursday, January 20, 2011

GWT with Maven

  1. Install the plugins depending on your eclipse version(my eclipse version is 3.5) - gwt for eclipse(http://dl.google.com/eclipse/plugin/3.5), m2eclipse(http://m2eclipse.sonatype.org/sites/m2e)
  2. To create a maven based gwt project with GWT's webAppCreator utility, simply specifiy send -maven -noant as options. Say for example, webAppCreator -maven -noant -out C:\sample -junit C:\eclipse\plugins\org.junit4_4.5.0.v20090824\junit.jar com.testing.sample.sample
  3. Once the folder structure is created, use mvn eclipse:eclipse and import the project to eclipse
  4. Apply the tool kit settings to your project: Select your project - Right click - Google -Web Toolkit settings - check the use Google Web Toolkit and select the appropriate gwt version
  5. Compile: Select your project - Right click - Google - GWT compile
  6. Run: Select your project - Right click - Run as - Web Application
Maven Issues:
[ISSUE] M2_REPO (non modifiable)

Eclipse picks the value of M2_REPO from $MAVEN_HOME/conf/settings.xml using <localRepository> element. If nothing is specified, then ${user.home}/.m2 becomes the m2_repo path. Also verify the version of the maven from eclipse (preferences->maven->user settings).

Build Issues:
[ISSUE] The project doesn't have GWT SDK on its build path
check the order of your GWT SDK in the 'order and export' tab on your project build path.  gwt sdk library must appear before the maven dependencies. so, move it up in the order.


Compiler Issues:
[ERROR] Line 12: No source code is available for type com.google.gwt.junit.client.GWTTestCase; did you forget to inherit a required module?
add this to your *.gwt.xml <inherits name="com.google.gwt.junit.JUnit"/>

Run Issues:
[ERROR] Could not find host pages in the project 
Go to the project properties -> build path -> configure build path -> Select Google - WebApplication -> check 'This project has a WAR directory' - specify war directory as 'src/main/webapp'