3

Context

  • big project with multi maven module or single maven module structure

Question

  • did you finally use multi-maven-module or single-maven-module structure?

Details

If you've worked on a big project that had long development duration and contains lots of functionality(i.e. not a trivial project), did you choose to split the project into multiple maven modules or went with the single-module approach?

For example, having a multi-module structure, crashes when running maven commands like mvn gwt:eclipse(see http://bit.ly/gs4Rmo). I guess this would have worked well with single module GWT project. And there could be other commands like the above that has issues with multi-module structure.

However, the multi-module structure could bring the benefits of a faster development, i.e. if you separate the "server" from "client" module, you could compile the business logic(server) separately and package it into resulting web archive. Compiling the GWT code, takes about 20 seconds, so if you only modify the server package, it could save you lots of time in the long run.

Which other cases like the one above did you encounter when working with a multi-module/single module project?

Thank you!

Dan L.
  • 1,717
  • 1
  • 21
  • 41

2 Answers2

6

A few notes:

  1. On development server you don't have to compile the code "by hand": dev server compiles the code automatically and reloads it. Just keep dev server running, change some code and then reload the page in browser. (this is only true if you change existing classes and don't change project structure)

  2. Multiple maven modules have nothing to do with multiple GWT modules.

  3. You would want to have multiple GWT modules (= multiple entry points) if you have code that executes in different environments: for example you have web and mobile sites that have quite different code bases. Then you would split the project into three modules: web, mobile and common. Then you'd reference common in both web and mobile.

  4. Another case for multiple GWT modules would be if you, for some reason, want to have a multiple host (entry) HTML pages. There are rare cases when you'd want this, for example when you need to do redirects when integrating OpenID. The other case would be that you already have existing Web pages where you are only adding GWT to add some functionality.

  5. Don't split the GWT project into multiple modules just to reduce download size: use Code Splitting instead.

  6. If your main gripe is long gwt compile times then read: How do I speed up the gwt compiler?

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • Thank you for your consistent and comprehensive reply! – Dan L. Feb 23 '11 at 14:42
  • It's not about reducing the download size, I just wanted a faster development and in the long run, code separated between client logic and server logic. – Dan L. Feb 23 '11 at 14:43
  • The reason is, if I change something in the business logic and all code is in the same maven project(not to be confused with GWT module), I'd have to execute "mvn package" which also compiles the GWT code(20 seconds lost here).Another reason is if I'd want to host the server-side code in another web container(i.e. tomcat), having the "server" maven project would help alot. I don't have multiple environments yet, so no need for multi-GWT modules – Dan L. Feb 23 '11 at 14:43
  • what do you think? does it still make sense to split the project into multiple maven subprojects? – Dan L. Feb 23 '11 at 15:54
  • 1
    I'm not an expert on maven, but it seems logical to have (since you compile/run via maven) two modules: server and gwt – Peter Knego Feb 23 '11 at 15:59
  • 1
    we use maven in a server+gwt project, but during development I always run via Intellij's run configuration, for the exact reason that it does not require full compile – Peter Knego Feb 23 '11 at 16:00
  • Yes, running via IDE's compiling capability is a good way to save compile time. Thanks! I'll try that! In my case I have also a "shared" maven project(besides "client" and "server") in which I put the code that needs to be accessible by the "server" project and the "client" project – Dan L. Feb 23 '11 at 16:17
1

We started with multiple modules and eventually merged into a single module. The main reason for this was maintenance of modules is a huge overhead. Each module had a pom to build the UI, RPC layer and backend services. So with 30 modules we had 90 maven projects to manage.

Merging the modules turned 90 maven projects into 3 with one parent level pom.

This considerably lowers maintenance overhead and improves build times. GWT's compiler is notoriously slow so having a single compile parsing source files once instead of multiple times makes things much faster.

On the flip side, a single module means the compiler slurps everything up into memory at once. This could make split points intolerably slow to find if you insert any in your code. Therefore if you intend to split, it may be worth considering where you're putting those points and arrange your project accordingly.

locka
  • 5,809
  • 3
  • 33
  • 38