Saturday, 31 October 2009

Configuring Maven-based GWT projects for Eclipse

When developing with GWT and maven in Eclipse, you don't get the benefits of the Google Eclipse Plugin by default, as maven and the Maven GWT plugin doesn't configure your Eclipse project settings to work with the GWT plugin. Here's how I changed my POM file to configure the Eclipse project correctly:
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-eclipse-plugin</artifactId>
      <configuration>
        <additionalProjectnatures>
          <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
        </additionalProjectnatures>
        <additionalBuildcommands>
          <buildcommand>com.google.gwt.eclipse.core.gwtProjectValidator</buildcommand>
        </additionalBuildcommands>
        <classpathContainers>
          <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
          <classpathContainer>com.google.gwt.eclipse.core.GWT_CONTAINER</classpathContainer>
        </classpathContainers>
        <excludes>
          <!-- These are provided by the GWT container -->
          <exclude>com.google.gwt:gwt-user</exclude>
          <exclude>com.google.gwt:gwt-dev</exclude>
        </excludes>
      </configuration>
    </plugin>
  </plugins>
</build>
If you're using GWT 1.x or earlier snapshots of GWT 2.0 you'll have to replace gwt-dev with gwt-dev-${platform}.

Now, when running mvn eclipse:eclipse, the Eclipse project will use the Google GWT plugin for the core GWT dependencies.

1 comment:

generic propecia said...

Great site,this information really helped me , I really appreciate it.Thanks a lot for a bunch of good tips. I look forward to reading more on the topic in the future. Keep up the good work! This blog is going to be great resource. Love reading it.
nice tip