Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build to generate only changed artifact

In our project, Maven build generates artifacts for different modules i.e. jar, console, car etc in corresponding folder structure.

Everytime we check in the code, the build genarates full new artifacts even if there is only change in "console" module.

Is there any Maven plugin or a way to generate only the artifacts which were changed since last successful build?

For instance, if I have changed the code for "console" module, then the artifact generated should only have console file in its corresponding folder.

like image 356
Pankaj Dwivedi Avatar asked Dec 04 '12 12:12

Pankaj Dwivedi


2 Answers

If you are on command line you can use

mvn -pl moduleToBuild

which can be combined with:

mvn -pl moduleToBuild -am

which will also build the dependencies of moduleToBuild.

If you are in a CI solution like jenkins there is a check box to activate this behaviour. This can be found under the Maven configuration part Incremental build - only build changed modules.

You have to start the maven call on the root of your multi-module build.

like image 108
khmarbaise Avatar answered Sep 20 '22 14:09

khmarbaise


You may want to look at using maven reactor plugin's reactor:make-scm-changes goal. This link has example on how to use this.

like image 44
Raghuram Avatar answered Sep 21 '22 14:09

Raghuram