Announcing gwt-maven-archetypes project

1384 views
Skip to first unread message

Thomas Broyer

unread,
Apr 26, 2012, 10:39:24 AM4/26/12
to codehaus-mojo-gwt-...@googlegroups.com
Hi all,

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: http://www.sonatype.com/books/mvnref-book/reference/flex-dev.html 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): https://github.com/tbroyer/gwt-maven-archetypes
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!

Juan Pablo Gardella

unread,
Apr 26, 2012, 1:29:25 PM4/26/12
to codehaus-mojo-gwt-...@googlegroups.com
Thanks for sharing!!

--
You received this message because you are subscribed to the Google Groups "Codehaus Mojo gwt-maven-plugin Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/codehaus-mojo-gwt-maven-plugin-users/-/0oL-89D5m2gJ.
To post to this group, send email to codehaus-mojo-gwt-...@googlegroups.com.
To unsubscribe from this group, send email to codehaus-mojo-gwt-maven-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/codehaus-mojo-gwt-maven-plugin-users?hl=en.

Yannis Gonianakis

unread,
May 4, 2012, 3:04:49 PM5/4/12
to codehaus-mojo-gwt-...@googlegroups.com
Very handy archetypes Thomas, thanks for sharing!

I was looking into the POM files today and found some areas for improvement. Do you want me to file issues first or are the pull requests enough?

Thomas Broyer

unread,
May 4, 2012, 4:52:22 PM5/4/12
to codehaus-mojo-gwt-...@googlegroups.com

Pull requests *are* issues on GitHub, so no need to create issues first (quite the contrary actually, unless you're using tools like 'hub' using the GitHub API to link pull requests to existing issues)

--
You received this message because you are subscribed to the Google Groups "Codehaus Mojo gwt-maven-plugin Users" group.

ido

unread,
May 6, 2012, 7:42:16 AM5/6/12
to codehaus-mojo-gwt-...@googlegroups.com
Hey Thomas, 

Again, thanks a lot for the archetype.
I started playing with it a bit and I can't make it play nicely  with Eclipse.
Eclipse recognizes non of the packages as GWT project (which actually make sense).

I've not been using multi module scheme for GWT apps till now and I would very happy to change it.

Again, thanks a lot for sharing.

In addition, GWT + Spring backend using request factory archetype  would be awesome also :)

Thanks a lot for your major contributing for the project!
Ido

Thomas Broyer

unread,
May 6, 2012, 8:51:45 AM5/6/12
to codehaus-mojo-gwt-...@googlegroups.com


Le 6 mai 2012 14:07, "ido" a écrit :
>
> Hey Thomas, 
>
> Again, thanks a lot for the archetype.
> I started playing with it a bit and I can't make it play nicely  with Eclipse.
> Eclipse recognizes non of the packages as GWT project (which actually make sense).

It should apply the GWT nature automatically to the "client" module.
For the GWT RPC archetype, I'd like to make it work for the "shared" module as well but haven't really looked at it yet. This is not really needed for RF version, as the GWT nature here only brings the RPC interfaces validation and helpers.

> I've not been using multi module scheme for GWT apps till now and I would very happy to change it.
>
> Again, thanks a lot for sharing.
>
> In addition, GWT + Spring backend using request factory archetype  would be awesome also :)

I don't like Spring, so it only ever will be included if someone contributes it. I'll soon add a GIN + Guice + Activities + RF archetype though.

> Thanks a lot for your major contributing for the project!
> Ido
>
> On Thursday, April 26, 2012 5:39:24 PM UTC+3, Thomas Broyer wrote:
>>
>> Hi all,
>>
>> 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: http://www.sonatype.com/books/mvnref-book/reference/flex-dev.html 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): https://github.com/tbroyer/gwt-maven-archetypes
>> 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):
>> mvn archetype:generate -DarchetypeGroupId=net.ltgt.gwt -DarchetypeArtifactId=gwt-maven-archetypes-modular-webapp -DarchetypeVersion=1.0-SNAPSHOT
>> mvn package -Pdraft
>> In one terminal window: cd server; mvn jetty:start -Pdev
>> 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!
>

> --
> You received this message because you are subscribed to the Google Groups "Codehaus Mojo gwt-maven-plugin Users" group.

> To view this discussion on the web visit https://groups.google.com/d/msg/codehaus-mojo-gwt-maven-plugin-users/-/cdN22T82hZwJ.

ido

unread,
May 6, 2012, 9:01:10 AM5/6/12
to codehaus-mojo-gwt-...@googlegroups.com
Thanks a lot

> To post to this group, send email to codehaus-mojo-gwt-maven-plugin...@googlegroups.com.
> To unsubscribe from this group, send email to codehaus-mojo-gwt-maven-plugin-users+unsubscribe@googlegroups.com.

Biri

unread,
Jul 13, 2012, 12:12:25 PM7/13/12
to codehaus-mojo-gwt-...@googlegroups.com
Hey Thomas,

First of all thanks a lot for the archetype.
I followed your readme file and successfully started the server & client outside eclipse. I am now trying to use eclipse in order to debug both without success, I sure am missing something. It would be great if you could point me in the right direction.

Thanks a lot! 

On Thursday, April 26, 2012 5:39:24 PM UTC+3, Thomas Broyer wrote:

Juan Pablo Gardella

unread,
Jul 13, 2012, 4:52:33 PM7/13/12
to codehaus-mojo-gwt-...@googlegroups.com
Did you specify the -war parameter when try to debug the application?

2012/7/13 Biri <itay.b...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Codehaus Mojo gwt-maven-plugin Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/codehaus-mojo-gwt-maven-plugin-users/-/7zfau7mwNkMJ.

To post to this group, send email to codehaus-mojo-gwt-...@googlegroups.com.
To unsubscribe from this group, send email to codehaus-mojo-gwt-maven-...@googlegroups.com.

Biri

unread,
Jul 13, 2012, 5:10:20 PM7/13/12
to codehaus-mojo-gwt-...@googlegroups.com
Thanks for the response Juan.
I did use the -war parameter. When I run it asks for startupUrl parameter and the login.html sits under the server module. 
"[WARN] No startup URLs supplied and no plausible ones found -- use -startupUrl"

The only GWT project is the "client", I can't seem to run it from Eclipse while configuring the jetty server to start the "server" module.

Juan Pablo Gardella

unread,
Jul 13, 2012, 5:13:11 PM7/13/12
to codehaus-mojo-gwt-...@googlegroups.com
You have at least, two projects.

1) GWT project.

In this, use run as->web application. Remember add -noserver parameter too.

2) Server project.

I debug or start the server with m2eclipse plugin inside eclipse. Run mvn jetty:start -Pdev



2012/7/13 Biri <itay.b...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Codehaus Mojo gwt-maven-plugin Users" group.

Biri

unread,
Jul 13, 2012, 7:06:10 PM7/13/12
to codehaus-mojo-gwt-...@googlegroups.com
Thanks again!
If I am not mistaken you are talking about running them separately in debug mode from eclipse. That's what I did as well.

The gwt eclipse plugin can run GWT projects as web applications using an embedded server (Jetty as well).
I was wondering if I can run the client module using the plugin while telling it to run the server module as its server using the embedded server option.

Thomas Broyer

unread,
Jul 13, 2012, 10:27:06 PM7/13/12
to codehaus-mojo-gwt-...@googlegroups.com
I suppose you could do it: set -war to point to the server's target/myapp-server-1.0-SNAPSHOT. But that means each time you make a change in "shared" you run "mvn war:exploded" on the server to copy the myapp-shared .jar" to the WEB-INF/lib.
You could make a special ServletContainerLauncher (extending JettyLauncher) with a custom ClassLoader to load shared classes from the shared project's target/classes, but that's a bit convoluted and probably not worth it.

I find running the client and server separately to be more flexible. You can run DevMode against another server (e.g. a test server where the app is deployed daily/nightly by your CI system) without changing anything to your config (you already run DevMode in -noserver mode, it's just a matter of hitting a different URL; I generally pass -startupUrl several times, with e.g. localhost, test-server1 and test-server2, so I can simply double-click the one I want form the DevMode view in Eclipse). And you can use whichever server you want (I generally need specific configuration of the server, for JNDI or authentication, things that are not possible –or not easy– with the embedded server of DevMode).
Also, given that with GIN you need to restart the DevMode from time to time (might no longer be the case with recent snapshots, but still required with 1.5, the latest stable release), I can restart it without restarting the server.

Biri

unread,
Jul 14, 2012, 4:32:03 AM7/14/12
to codehaus-mojo-gwt-...@googlegroups.com
Thanks for the reply!
Reply all
Reply to author
Forward
0 new messages