You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Hart, Leo" <Le...@FMR.COM> on 2010/05/06 16:39:53 UTC

Large Enterprise Project, Multiple Layers, Recommended POM Structure?

I currently have a fairly large enterprise app (~70,000 lines of code)
that is built using Maven2 with the resulting artifact being one large
WAR.  
 
The application has many different functions, some with more
dependencies than others, but overall our package-level cyclical
dependencies are minimal; where they exist, we are in the process of
removing them.
 
My POM structure is as follows (folders in bold):

*	leosApplication: 

	*	app: application (service) layer, has externally exposed
services, command handlers, etc 
	*	build: maven build configuration reused by module 
	*	content: content management infra service 
	*	dal: data access layer, implementation of DDD
repositories, etc 
	*	domain: entities, values, services, repository
interfaces, etc 
	*	domain-builder: entity builder classes used for testing 
	*	feed:  batch and feed infrastructure services 
	*	mail: mail infra services 
	*	query: query services used to create UI view objects 
	*	spec: specification (acceptance) tests 
	*	statement: statement generation infra services 
	*	test: reusable test code 
	*	util: misc utility classes 
	*	util-datainit: testing infra services used to set up
data for integration tests 
	*	view: view objects used to render UI 
	*	web: the creator of the WAR file - controllers, JSPs,
etc
		pom.xml: parent and aggregate POM

Each of these folders has a single pom.xml file and each generates a JAR
or a WAR file, save the build project which only contains configuration.
Within some of these projects like domain, dal, app and web, we have
many sub-packages:

*	domain.account 
*	domain.award 
*	domain.banking 
*	domain.beneficiary 
*	...50 more...

Problems: 

*	mvn clean test takes way too long to be effectively used prior
to code commits or as part of CI builds.  
*	Eclipse with m2eclipse is incredibly slow to refresh, build,
etc.

Solutions under consideration:

*	Separate out unit tests from integration tests:  this needs to
be done and will be done 
*	Project re-organization: currently web depends on app depends on
domain, etc.  If I make a change to the banking module in domain, I end
up having to build and test all of my domain packages, all of my app
packages, all of my web packages, even if the change only affects one or
two classes in those higher-level layers.  As I see it, I could do one
of the following things (folders in bold, each folder has a pom.xml): 

	*	Organize by function: 

		*	leosApplication: 

				
			*	account 

				*	classes for domain 
				*	classes for dal 
				*	classes for app 
				*	classes for web

			*	banking 

				*	classes for domain 
				*	classes for dal 
				*	classes for app 
				*	classes for web

			*	...50 more... 
			*	web-resources: 

				*	JSPs and other web resources
across functions

			Let's assume that one of banking's app classes
depends on the account's domain.  When I make a change in account, I
need to run tests on all layers of account and on banking's app and web
classes.  
			
			Pros: speed improvement, simpler structure
			Cons: Because all layers are in one project per
function, I am creating unnecessary dependencies.  banking.app may only
depend on account.domain, but my POM structure suggests otherwise.

	*	Organize by function and layer: 

		*	leosApplication: 

			*	account-domain 
			*	account-dal 
			*	account-app 
			*	account-web 
			*	banking-domain 
			*	banking-dal 
			*	banking-app 
			*	banking-web 
			*	...50 X 4 more 
			*	web-resources

			Once again, let's assume that one of banking's
app classes depends on the account's domain.  When I make a change in
account, I need to run tests on all layers of account and on banking's
app and web classes.  
			

			
			Pros: major speed improvement, no unnecessary
dependencies.  
			Cons: large, complex project structure...not
sure what effect this will have on eclipse performance.

My question to the group is this: how are you all organizing your large,
multi-module projects?  Has anyone tried one of these two approaches and
if so, were there any unexpected side-effects?
 
My thanks for your help!