When a project is dealing with a multitier environment, the directory structure invariably starts to get confusing. For example, when a single project handles the EJB layer, the Web Application layer, and potentially a client layer, the directory layout becomes large and unmanageable. The most common solution is to break up the single project into many smaller projects—each with its own ant build file. There's a problem, however: overall project management. If each ant file is not updated at the same time, a form of version skew develops. The properties for the project end up being duplicated across many build files with the resulting errors that causes.
Part of the goal of the Maven project is to solve these problems. Maven is built from the ground up with multiproject development in mind. In this article, I will walk you through a simple multiproject directory structure and demonstrate how Maven puts it all together—including solving the complex dependencies.
This example project has three subprojects:
- util: The util project contains all the classes that are utility in nature, including property handlers, encryption handlers, and so on.
- war: Everything that belongs in the web presentation layer belongs in this project. All of the JSPs, HTML files, servlets, and so on are contained in this project.
- ejb: Everything that belongs in the EJB layer goes into this project. Entity Beans, Session Beans, and Messaging beans are the primary classes found in this project.