I have a project with three levels of modules. Let’s suppose it has the following organization …
+-- maven-root
+-- maven-module-1
| +-- maven-submodule-1-1
| +-- maven-submodule-1-2
+-- maven-module-2
| +-- maven-submodule-2-1
| +-- maven-submodule-2-2
+-- maven-module-3
+-- maven-submodule-3-1
+-- maven-submodule-3-2
Additionally, we have the following set of dependencies
maven-module-2depends uponmaven-module-1maven-module-3depends uponmaven-module-3
In this structure, and supposing artifacts for maven-module-1 and its submodules are already available in local repository, is there a solution using maven reactor (as an example) to build only maven-module-2 and its submodules ?
I already know that, using maven reactor, if I do
mvn clean install -pl :maven-module-2 --also-make-dependant
It will build
- maven-module-2
- maven-submodule-2-1
- maven-submodule-2-2
- maven-module-3
- maven-submodule-3-1
- maven-submodule-3-2
as maven-module-3 have a dependency upon maven-module-2
And obviously, running
mvn clean install -pl :maven-module-2 --also-make
will only build maven-module-1 and maven-module-2.
So, how, using that project organization, can I build only maven-module-2 ?
Using
will build only maven-module-2 and
will build maven-module-2 and its children
Take care that -f is used to say to Maven to use another POM (or module directory and it takes the pom.xml in it) than the one in the current directory. Thus unlike -pl where maven considers all modules in your project and then build only a subpart of them, -f only build what is referenced by this project/module/pom. To do
is exactly like