I am new to Maven. I have a parent pom file which lists the modules. I want to package only those modules which are modified. When running mvn package
it is packaging everything each time. How do I package only those modules which have been modified?
Asked
Active
Viewed 609 times
3
-
See https://stackoverflow.com/a/15409894/927493 – J Fabian Meier Oct 23 '17 at 12:03
2 Answers
0
You can package selected modules using the -pl
flag. For example:
mvn -pl moduleA,moduleB clean install
Though this can be somewhat dangerous since it presumes that you know better than Maven which modules should be built.
You can also skip the clean
phase thereby allowing Maven's incremental compiler to work out what should be recompiled. For example ...
mvn install
... instead of:
mvn clean install
Though again this can be somewhat dangerous since it presumes that any classes (or other resources) which haven't changed since the last build are ok for inclusion in the next built artifact.

glytching
- 44,936
- 9
- 114
- 120
0
I prefere using '-rf' option : "mvn package -rf module_i" , with this option '-rf' ; MAVEN also launches dependency on this module. Example :
If A ->B and C->B when B change , you need also validate A and C :
=> mvn package -rf B
Id you want packaging juste B :
=> mvn package -pl B

question_maven_com
- 2,457
- 16
- 21