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-2
depends upon maven-module-1
maven-module-3
depends upon maven-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
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
mvn clean install -f maven-module-2 -N
will build only maven-module-2 and
mvn clean install -f maven-module-2
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
mvn clean install -f maven-module-2
is exactly like
cd maven-module-2; mvn clean install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With