I was trying to set up gwt with maven2. And here is tutorials how to do it.
We will use little help. There is already gwt archetype for maven2. (you don’t have to use it. You are fine with maven default war project archetype but set up your project correctly)
- Download this file (it is for version 1.4.59, but by changing the pom you can get the newest version (which is at the time of writing 1.4.61)
- unzip file
- install it to your repository “mvn install”
Use the archetype to create maven gwt skelet.
mvn archetype:create -DarchetypeGroupId=com.totsp.gwt -DarchetypeArtifactId=gwt-archetype -DarchetypeVersion=1.0-SNAPSHOT -DartifactId=gwt-using-archetype -DgroupId=foo.bar
Next we will modify pom.xml
- change version for gwt-user and gwt-servlet (at the time of writing it is 1.4.61)
- change element <compileTarget> to <compileTargets> also for closing element </compileTargets>
- last thing is to tell where is your gwt installation. So add <gwtHome> element (here is example:
<build> ...... <plugin> <groupId>com.totsp.gwt</groupId> <artifactId>maven-googlewebtoolkit2-plugin</artifactId> <configuration> <gwtHome>C:/programs/gwt-windows-1.4.61</gwtHome>
This is very “hardcoded” and it is suggest to define it in ~/.m2/settings.xml (use either way) and here is example of settings.xml
<?xml version=”1.0″ encoding=”UTF-8″?> <settings> <profiles> <profile> <id>gwt-1.4.61</id> <properties> <google.webtoolkit.home>C:/programs/gwt-windows-1.4.61</google.webtoolkit.home> <!–- XstartOnFirstThread needed only on the mac -–> <!–-<google.webtoolkit.extrajvmargs>-XstartOnFirstThread</google.webtoolkit.extrajvmargs>–-> </properties> </profile> </profiles> <activeProfiles> <activeProfile>gwt-1.4.61</activeProfile> </activeProfiles> </settings>
OK and now we are ready to try our example. Run ‘mvn gwt:gwt’ and it will launch browser with your application. By using archetype you are up and running in few minutes.
If you want to integrate it with jetty just run ‘mvn jetty:run-exploded’ and open localhost:8080.
- polish tutorial with little bit different approach
- tutorial I studied from
- Multi project in maven with GWT – use svn to check out code on your local computer and run it
Source code can be downloaded from here.