title: Maven, Spring configuration for multi-module project
body: <p>I am looking to set up a multi module maven project (described below) that would scale well. I have some questions about the approach which is largely drawn from the <a href="http://www.sonatype.com/books/mvnex-book/reference/multimodule.html" rel="nofollow noreferrer">Sonatype example</a>.</p>
  <p>I have done a certain amount of reading on maven multi module projects but couldn't find an example going beyond the basic level.</p>
  <h2>Questions:</h2>
  <ol>
  <li>Is this (below) a good project structure to start with? Or does it smell of disaster right from the start - i.e. would lead to heavy restructuring when setting up builds? In short, I am looking to avoid setting up something that goes against the grain with Maven.</li>
  <li>I am expecting some modules to be quite independent, while most will be interrelated. Is it alright to start with each module as a Git repo and later refactor in together modules that are tightly linked?</li>
  </ol>
  <h2>Objectives:</h2>
  <ol>
  <li><p>Good project structure for a modular Spring, JSF2, Maven based project, that would allow for builds involving a selection of modules and their dependencies.</p>
  </li>
  <li><p>It should be possible to deploy an individual web module on a lightweight container like Tomcat/Jetty through Maven configuration (like jetty-maven-plugin). This should be able to pull in the necessary dependencies through Maven. That makes it easy during development to focus on the module being worked on (not having to run a full build and deployment) and deploy the full application only in a complete build.</p>
  </li>
  <li><p>The setup should allow for multiple distributions based on a selection of modules to be included in the build. I take it this can be achieved through the use of build modules that will pull and package the corresponding modules.</p>
  </li>
  </ol>
  <h2>Project structure</h2>
  <pre><code>Core domain classes.  
  somapp.core (maven project)  
   |- someapp.core (maven module)  
   |- someapp.core.tests  
  
  Account Management Domain classes   
  someapp.accountmgmt   
  |- someapp.accountmgmt   
  |- someapp.accountmgmt.tests   
  
  component1 domain classes   
  someapp.component1   
  |- someapp.component1   
  |- someapp.component1.tests
  
  Service 1 - # account management (User login)
  someapp.accountmgmt  
   |- someapp.accountmgmt.api  
   |- someapp.accountmgmt.impl  
   |- someapp.accountmgmt.mocks  
   |- someapp.accountmgmt.tests  
  
  someapp.service2  
   |- someapp.service2.api  
   |- someapp.service2.impl  
   |- someapp.service2.mocks   
   |- someapp.service2.tests   
   |- someapp.service2.cli    # CLI access for service2
  
  someapp.service3  
   |- like above  
  
  someapp.accountmgmt.web  
   |- someapp.accountmgmt.web  
  
  someapp.service2.web  
   |- someapp.service2.web  
  
  someapp.service3.web  
   |- someapp.service3.web  
  
  someapp.build1 # bundle accountmgmt and service2 into 1 war file  
  
  someapp.build2 # bundle accountmgmt and service3 into 1 war file  
  
  somapp.build3 # bundle  accountmgmt, service2 and service3 into 1 war file  
  
  (i.e. someapp.accountmgmt.web.war, someapp.accountmgmt.jar, someapp.service2.web.war, someapp.service2.jar, someapp.service3.web.war, someapp.service3.jar, someapp.core.jar)
  </code></pre>
  <p>I understand project structures are not set in stone. I would like to set up one that is a good starting point. Suggestions / Links to examples are welcome.</p>