From Maven 3.x we can request that builds run with multiple Threads.
Like?
using the option -T [number of threads]
we can define how many Threads we want to build, as well as determine how many per CPU
Examples
mvn -T 4 clean install # Builds with 4 threads
mvn -T 1C clean install # 1 thread per cpu core
mvn -T 1.5C clean install # 1.5 thread per cpu core
What is the expected performance improvement we can expect?
Well, this may vary depending on the structure of your projects, but the following evidence has been obtained:
- Speed improvement 20-50% is quite common.
- If the tests of your modules are distributed in modules, there is great possibility of performance gain, having a single test project, tends to decrease performance unless another surefire plugin is run in parallel.
Sources:
http://jknowledgecenter.blogspot.com/2015/06/maven-tips-and-tricks.html
https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3