This project contains Maven archetypes for modular GWT projects.
mvn archetype:generate \
-DarchetypeCatalog=https://oss.sonatype.org/content/repositories/snapshots/ \
-DarchetypeGroupId=net.ltgt.gwt.archetypes \
-DarchetypeArtifactId=<artifactId> \
-DarchetypeVersion=1.0-SNAPSHOT
where the available <artifactIds>
are:
modular-webapp
modular-requestfactory
guice-rf-activities
This uses the snapshot deployed to Sonatype OSS. Alternatively, and/or if you want to hack on / contribute to the archetypes, you can clone and install the project locally:
git clone https://github.com/tbroyer/gwt-maven-archetypes.git
cd gwt-maven-archetypes && mvn clean install
You'll then use the mvn archetype:generate
command from above, except for the
-DarchetypeCatalog
argument which you'll remove, as you now want to use your local
catalog.
Note that tests are sensitive to line endings, so if you're on Windows make sure
your clone has Windows (CRLF) end of lines. In case it's not enough, you can simply
delete the src/test
folder thus bypassing tests (provided the tests pass on the
continuous integration platform, it's not a big risk).
Change directory to your generated project and issue the following commands:
- In one terminal window:
mvn gwt:codeserver -pl *-client -am
- In another terminal window:
mvn tomcat7:run -pl *-server -am -Denv=dev
The same is available with tomcat6
instead of tomcat7
.
Or if you'd rather use Jetty than Tomcat, use cd *-server && mvn jetty:start -Denv=dev
instead of mvn tomcat7:run
.
Note that the -pl
and -am
are not strictly necessary, they just tell Maven not to
build the client module when you're dealing with the server one, and vice versa.
There's a special profile defined in the POM file of server modules:
env-dev
, which is used only when developping. It configures the Tomcat and Jetty
plugins and removes the dependency on the client module (declared in the env-prod
profile, active by default.)
To activate the env-dev
profile you can provide the -Denv=dev
system property, or
use -Penv-dev
.
To use variable interpolation in parameters during mvn archetype:generate
,
you need at least version 2.2 of the maven-archetype-plugin. Archetypes use
${module.toLowerCase()}
as the default value for the module-short-name
parameter, so if you don't use version 2.2 or above of the
maven-archetype-plugin, make sure you provide a value and do not use the
default one for that parameter. You can also make sure you use version 2.2 of
the plugin by using mvn org.apache.maven.plugins:maven-archetype-plugin:2.2:generate
instead of mvn archetype:generate
. It should be noted that variable interpolation also does
not work in M2Eclipse's wizard, despite using recent versions of Maven thus
(probably) a recent-enough version of the maven-archetype-plugin.