Announcing gwt-maven-archetypes project

Crossposted to codehaus-mojo-gwt-maven-plugin-users


I started using Maven 2 years ago for a project at work, and I soon started to believe that “the Maven way” of doing a GWT project is to separate client (GWT-compiled) and server (servlets, javac'd) code into separate projects.

I undoubtedly was influenced by the Flexmojos, talked about in Sonatype's “Maven: The Complete Reference” book, but on the other hand, who knows better than Sonatype how to layout/structure your Maven projects?


In our project, I thus soon put that belief in action by creating (among many others: we have nearly 20 modules in the project) 4 modules: client, server, shared and webapp. You'd deploy your server code and then run GWT's DevMode in -noserver mode.

The separation between server and webapp was only so that server depends on our "api" modules only, while webapp depends on their specific implementations (for example, server would depend JAX-RS and webapp would use RestEasy as the implementation). I'm not sure it's worth it in many projects, but it helps segregating your dependencies if that's something you want to do.

Two years later, the project is going into production, and overall that project structure was a success (it should be noted that due to our project architecture –JNDI, extensive use of Jetty's XML configuration–, we couldn't use DevMode's embedded server; and we only use the gwt-maven-plugin for its gwt:compile goal: launching our customize Jetty server was done using a shell script, and the GWT DevMode was only ever launched from within Eclipse).


In the last few days (being on vacations), I spent some time making a Maven archetype for that setup, with working mvn jetty:run and mvn gwt:run goals (well, I have to admit: not fully tested yet):

I intend to add at least another archetype for projects using RequestFactory instead of GWT-RPC, and there's currently absolutely no documentation (the browser tab next to the one I'm typing this in is the “Site Generation” chapter from the “Maven: The Complete Reference” book).


Here's how it goes (after you install it in your local repo):

  1. mvn archetype:generate -DarchetypeGroupId=net.ltgt.gwt -DarchetypeArtifactId=gwt-maven-archetypes-modular-webapp -DarchetypeVersion=1.0-SNAPSHOT
  2. mvn package -Pdraft
  3. In one terminal window: cd server; mvn jetty:start -Pdev
  4. In another (or you could use -Djetty.daemon in the previous step): cd client; mvn gwt:run -Ddev

Feedback, including issues and pull requests, is more than welcome!