How can I boost the Integration build using Maven

Tag: maven Author: shiming747s Date: 2011-03-29

I have around 20 modules need to built and how I could achieve this in faster way using maven 2.0+

Currently my build starts from root pom.xml using hudson just calls mvn clean install

I do not want to skip any of the unit tests as well.

Currently it is taking almost an hour.Please advice.


Are you running Maven 3? Maybe you can run your unit/integration tests parellelized? What is the bottleneck of the build? integration test/compile/generating ?

Other Answer1

Wish I had more "high tech" suggestion but I would start by splitting tests into two groups:

  1. "Fast" ones which will be part of every build and
  2. "Slow" ones which will be part of "Slow" build. The "Slow" build is run several times a day.

Usually, unit tests are fast and become part of the "Fast" build while integration tests are part of the "Slow" build.

I would be careful with parallel tests: they can create more problems than they solves.

You can read more on integration test implementation in Maven here:

Other Answer2

What Sasha O said is really important. If your build takes so much times, maybe your tests are not simple unit tests. So splitting the tests among two categories will be a good idea. Your fast tests should be real unit tests, which means that they should not involve Spring context, important disk I/O, or real database connection (you can use in-memory database, such as H2 or HSQLDB).

If you are using TestNG for your tests, you can use the groups feature to split your tests. If you are using JUnit, the @Category can be useful. Using JUnit, this @Category is not perfect, and it was a problem for me. I solve my problem by creating a custom JUnit Runner (the solution is not perfect neither, but can be helpful).

Another advice: maybe you could consider using a better hardware for your continuous integration server. Indeed, compilation and tests execution can be really improved by using a computer with better performances. As well, if you are not using a recent JDK, you may migrate to JDK 1.6 for example...

Finally, there is an interesting option with Maven since version 2.1: the incremental build. This option is available when you click on the "Advanced" button of the Maven build options if you are using Hudson / Jenkins.

The principle is to build only the modules that are impacted by your changes (i.e. commits). Let's take an example. I have this project:

  +- commons
  +- persistence
  +- business

The business project is dependent on persistence, which is dependent on commons. Now, if you have a commit on the persistence project, why would you need to compile, test and package commons, as this project did not change? The incremental build option will only rebuild the modified project, as well as the dependent modules. In my example, persistence will be rebuilt, as well as business.


Hi romaintaz,Thanks for the valuable input how to configure incremental build in Hudson?