Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven incremental building

We currently have a big Maven 2 project that is rather a collection of many single standalone projects with complicated dependencies, with the exception of some common parent POMs for building. In the end we always have to ship the application as one piece, so I would rather like to convert it to one or a few big projects.

Does anyone have experience in how to optimize continuous integration builds for big projects. Is the incremental build functionality of Maven or Hudson any good? I would prefer not to wait always 2 hours when having made only a small change in one module.

On the other hand, to be sure, you always would have to rebuild and re-test at least all direct and indirect dependencies of a changed module. That is also what we are currently doing with Hudson, triggering automatically all dependent jobs.

Does a split up into multiple build jobs for the same project pay off? I generally do not like to have artifacts on the server where all the other generated stuff like reports, docs, etc. could possibly be out of date.

Thanks for any thoughts.

like image 972
anselm Avatar asked Jun 08 '11 15:06

anselm


People also ask

Does Maven do incremental build?

4) Apache Maven doesn't support incremental builds very well. Because of that fact, most people use mvn clean compile instead of mvn compile for example. This is pretty time consuming and can be improved a lot. The goal is to make mvn compile , mvn verify , mvn install , ...

What is incremental build Java?

This is what the incremental compiler does: it analyzes the dependencies between classes, and only recompiles a class when it has changed, or one of the classes it depends on has changed.

How do incremental builds work?

Incremental builds are builds that are optimized so that targets that have output files that are up-to-date with respect to their corresponding input files are not executed.

What is incremental build in Jenkins?

For a large Maven project, you can tell Jenkins to do incremental builds. In this mode, Jenkins will only build those modules that are affected by new commits. For example, if someone makes a change to moduleA/src/main/java/Foo.


1 Answers

I just did some more testing and as I found out Maven does not really support incremental builds. Without any plugins Maven actually has a dangerous behavior. If you change the code in some module and compile without prior clean, dependent modules will not get rebuilt, meaning they then reference an old outdated version of the dependency and will not react to the updated code.

With the incremental build plugin it is possible to build without clean. Every module that changed gets rebuilt plus all dependents will be cleaned and rebuilt. However, in my case compiling uses only like 10% of the build time, 90% are for testing. And when I install/deploy all tests get executed again, so the time benefit from the incremental build plugin is very small.

So I still only see the option of splitting up builds in Hudson which is hardly ideal in my opinion.

like image 85
anselm Avatar answered Oct 04 '22 23:10

anselm