1. create GWT project using mojo's gwt-maven-plugin archetype
mvn archetype:generate -DarchetypeRepository=repo1.maven.org -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.2.0
2. input project information defined by properties
[INFO] Archetype defined by properties
Define value for module: : HelloGwt
Define value for groupId: : com.sample
Define value for artifactId: : HelloGwt
Define value for version: 1.0-SNAPSHOT: :
Define value for package: com.sample: :
Define value for module: : HelloGwt
Define value for groupId: : com.sample
Define value for artifactId: : HelloGwt
Define value for version: 1.0-SNAPSHOT: :
Define value for package: com.sample: :
3. import this project in eclipse and add generated-sources into build path.
Using "Import -> Existing Projects into Workspace" to import the "HelloGwt" into Eclipse.
However, you will find there is a error, complaining about cannot find GreetingServiceAsync calss. But if you run "mvn gwt:run", your application can run sucessful.
This is gwt-maven-plugin automatically generate Async service interface for us (in target/generated-sources/gwt), but did not include it in eclipse's build path. You can also use gwt:generateAsync
to do the job after you create another service.
So right click on "HelloGwt" project, select "Build path -> Configure Build Path" and add "target/generated-sources/gwt" into source folder.
Now you can enjoy maven in your gwt project.
1 comments:
Instead of configuring build path in eclipse it can be done with maven:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>add-generated-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals> <configuration>
<sources>
<source>target/generated-sources/gwt</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Post a Comment