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.

Writing a GWT library (a.k.a. gwt lib)

A GWT library can be used to package classes for mutualization and/or modularization. A GWT library is just a java archive (JAR) containing both classes and java sources for later GWT compilation and a gwt.xml module descriptor.


The only distinction with a standard JAR project is the mix of sources and classes in the output folder. A simple way to achieve this is to add a dedicated resource in the POM :


Using general purpose JARs as GWT library (a.k.a. shared lib)

Many users want to use common usage libraries as GWT modules. Some would like to reuse the server-side business classes on client side, using a shared Maven module. The requirement to include sources in the JAR can then be annoying : including sur JAR in the webapp means the source code will be distributed with the application.

As the sources are not included in the JAR, you need to use the maven convention for source jars to create a ''sources'' package, and include it as a ''clasifiersources/clasifier'' dependency.


The only missing fragment to allow using this library from your GWT code is to create a ''gwt.xml'' module file. Create file ''com/mycompany/Domain.gwt.xml'' to match package ''com.mycompany.domain'':

  <inherits name=""/>
  <source path="domain"/>

If you have control of the ''domain'' lib, include this file in the ''domain'' project:

  |_ domain
  |  |_ src/main/java/com/mycompany/domain/
  |  |_ src/main/resources/com/mycompany/Domain.gwt.xml
  |_ webapp
     |_ src/main/resources/com/mycompany/web/MyApp.gwt.xml

…otherwise, add the GWT module in the ''webapp'' project:

  |_ domain
  |  |_ src/main/java/com/mycompany/domain/
  |_ webapp
  |  |_ src/main/resources
        |_ com/mycompany/Domain.gwt.xml
        |_ com/mycompany/MyApp.gwt.xml