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 :
<resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.java</include> <include>**/*.gwt.xml</include> </includes> </resource> </resources>
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.
<dependencies> <dependency> <groupId>com.mycompany</groupId> <artifactId>domain</artifactId> <version>${project.version}</version> <classifier>sources</classifier> <scope>provided</scope> </dependency> </dependencies>
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'':
<module> <inherits name="com.google.gwt.user.User"/> <source path="domain"/> </module>
If you have control of the ''domain'' lib, include this file in the ''domain'' project:
|_ domain | |_ src/main/java/com/mycompany/domain/SomeDomainClass.java | |_ 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/SomeDomainClass.java |_ webapp | |_ src/main/resources |_ com/mycompany/Domain.gwt.xml |_ com/mycompany/MyApp.gwt.xml