Building Single Module in a Multi-Module Project
When multiple teams work on a large multi-module project, it is often desirable to build just one module instead of the world. But Maven doesn’t make this obvious. For example, if the sub-module-A depends on the sub-module-B, building sub-module A was not even possible in 2009 without “mvn install” sub-module-B in the repository first! Fortunately, Maven has evolved. This is where the advanced reactor options come in. To build a single module, run this command at the parent level:
mvn –projects sub-module-A –also-make clean test
The “—also-make” option tells Maven to automatically build
all modules that sub-module-A depends on before building A. No “mvn install” of
dependent modules is needed. This ensures a clean build for single-module
building.
Build Profile
Developers often want to set up repository locations and
test environments in physical proximity because of cost and regulation
differences between geographical regions. Build profiles allow developers to
tailor their projects to diverse build environments without interfering with each
other.
Command-Line Settings.xml
Secure environments often require access credentials. For
security reasons, Maven requires these credentials to be stored in settings.xml.
This often causes more problems than it solves. One workaround is to store
different versions of settings.xml files along with the project files in the
source repository. Then when a project is checked out, the “-s” command line
option can be used to specify which settings.xml file to use for running Maven.mvn –s ${CHECKOUT_DIR}/setting/settings.xml clean test