Maven GWT 2.0 and Eclipse

Does anyone know of a good guide for creating a project with a new version of GWT 2.0 using maven and eclipse? I face a lot of problems forcing them to play together.

Why can I create a gwt project using the maven eclipse plugin that works fine, but porting it to maven does not work (so a guide for this would be great).

Similarly, I can use the maven plugin (gwt-maven-plugin), but when I import it into eclipse (import -> materialize maven projects), it is not recognized as a GWT project ...

thank

+51
java eclipse maven-2 gwt
Dec 12 '09 at 16:56
source share
5 answers

EDIT: I updated my answer with the extra steps provided by OP. Credits for OP for details.

I just broke the Eclipse setup, trying to install the latest Google plugin for Eclipse (for GWT 2.0), so I canโ€™t confirm everything, but let's say the following prerequisites are fulfilled:

Have you tried:

  • Create a new project from Eclipse (New> Other ... then select the Maven Project and select the gwt-maven-plugin archetype).

  • Edit the generated pom.xml , update the gwt.version property to 2.0.0 (which was released in the central repo), add the Codehaus snapshot repository and set the version of gwt-maven-plugin to 1.2-SNAPSHOT (version 1.2 will not be released in the center , this should happen soon) 1.2 (which was also released in the center).

  • Add <runTarget> to the gwt-maven-plugin configuration as described in Using the Google Eclipse Plugin .

  • Configure the maven-war plugin as described on the page mentioned in the previous step.

  • Manually enable GWT in the project from the projectโ€™s preferences by checking the Use Google Web Toolkit box . This step is not necessary as you will create / run using the Maven launch configuration, not the GWT Plugin for Eclipse.

This is what my pom.xml looks like:

 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <!-- GWT-Maven archetype generated POM --> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.demo</groupId> <artifactId>my-gwtapp</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>gwt-maven-archetype-project</name> <properties> <!-- convenience to define GWT version in one place --> <gwt.version>2.0.0</gwt.version> <!-- tell the compiler we can use 1.5 --> <maven.compiler.source>1.5</maven.compiler.source> <maven.compiler.target>1.5</maven.compiler.target> </properties> <dependencies> <!-- GWT dependencies (from central repo) --> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <version>${gwt.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwt.version}</version> <scope>provided</scope> </dependency> <!-- test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.4</version> <scope>test</scope> </dependency> </dependencies> <build> <outputDirectory>war/WEB-INF/classes</outputDirectory> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <goals> <goal>compile</goal> <goal>generateAsync</goal> <goal>test</goal> </goals> </execution> </executions> <configuration> <runTarget>com.mycompany.demo.gwt.Application/Application.html</runTarget> </configuration> </plugin> <!-- If you want to use the target/web.xml file mergewebxml produces, tell the war plugin to use it. Also, exclude what you want from the final artifact here. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webXml>target/web.xml</webXml> <warSourceExcludes>.gwt-tmp/**</warSourceExcludes> </configuration> </plugin> --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0.2</version> <configuration> <warSourceDirectory>war</warSourceDirectory> <webXml>src/main/webapp/WEB-INF/web.xml</webXml> </configuration> </plugin> </plugins> </build> </project> 

Run the gwt:eclipse target (using m2eclipse Maven2> build ...) to configure your environment and create a launch configuration for your GWT modules.

Run gwt:compile gwt:run to compile and run the GWT module in GWT hosting mode.

+42
Dec 12 '09 at 18:19
source share

You can run the following command to create a Maven GWT project:

webAppCreator -maven -noant -out

For more information:

GWT webappcreator creating Maven project: source attachment does not contain source for URLClassPath.class file

+3
Dec 25 '10 at 20:53
source share

Just in case. If you use the Google GIN in your project, you must add the goal to compile before gwt: compile . So the whole sequence will be:

 compile gwt:compile gwt:run 

You can read the explanation here: http://code.google.com/p/google-gin/wiki/GinTutorial#Compilation

+1
Jan 28 '10 at 0:30
source share

An annoying problem with GWT and m2eclipse:

GWT development mode requires all JARs to be hosted in WEB-INF / lib. This is especially painful when programmers use m2eclipse, which provides their own Eclipse classpath.

http://code.google.com/p/google-web-toolkit/issues/detail?id=5693

good news, workaround works for me

+1
Jan 14 '11 at 19:59
source share

very useful topic

@Pascal: Thank you (I don't have enough reputation to comment on other posts, so here I post what works for me).

I need 2.5.1 GWT (not 2.6, the latter) working with maven and eclipse (since sencha GXT is not yet supported for 2.6). Tried no luck

1) tried several archetypes using eclipse to create a project

2) modify the pom file (based on the discussion above) to change versions to 2.5.1

After me worked http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html

  mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.5.1 mvn gwt:eclipse mvn gwt:run 
0
Mar 06 '14 at 19:30
source share



All Articles