Fork me on GitHub
NOTICE There is a new plugin (archetypes and eclipse integration), a fresh start that correctly support multi-module projects, it is not version-bounded with GWT, support multiples GWT versions and other fixes, improvements and best practices. This plugin is now considered the legacy GWT maven plugin (aka mojo GWT maven plugin) and the new one is considered the new generation GWT maven plugin (aka tbroyer GWT maven plugin). The legacy maven plugin is still supported but it is strongly encouraged to use the new one for new projects.

Processing Annotation @RemoteServiceRelativePath to generate web.xml content

Because life is too short to manually write xml content for servlets in web.xml files (and not everybody uses servlet 3.0), you can now automatically merge your web.xml with generated servlet lines for classes annotated with @RemoteServiceRelativePath. This feature has been added in mergewebxml mojo

<project>
  [...]
  <build>
    <plugins>
      [...]
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.8.1</version>
        <configuration>
          <packageNamePerModule>
            <hello>org.codehaus.mojo.gwt.test.server</hello>
          </packageNamePerModule>
          <scanRemoteServiceRelativePathAnnotation>true</scanRemoteServiceRelativePathAnnotation>
        </configuration>
        <executions>
          <execution>
            <id>mergewebxml</id>
            <phase>process-classes</phase>
            <goals>
              <goal>mergewebxml</goal>
            </goals>
          </execution>          
        </executions>
      </plugin>
      [...]
    </plugins>
  </build>
  [...]
</project>

As the the annotation processing need the compiled classes you need to bind the mojo to at least compile phase. The other mojo parameters are :

  • scanRemoteServiceRelativePathAnnotation : to activate this feature
  • packageNamePerModule : to configure per module the root package to scan. Here you can use the "module name" ( org/codehaus/mojo/gwt/test/Hello.gwt.xml -> org.codehaus.mojo.gwt.test.Hello) or the rename-to value coming from your module name.