How to Use Multiple Threads to Run a Faster Build on Maven

0

What does Maven offer in terms of parallelism to run builds ?

If I run a build on a machine with more than one processor , how can I take advantage of more resources for processing?

What is the expected performance improvement we can expect?

    
asked by anonymous 27.06.2015 / 23:34

1 answer

1

From Maven 3.x we can request that builds run with multiple threads.

How?

using the -T option [number of threads] we can define how many threads we want for the build, so we can determine how many threads 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 your module tests are distributed in modules, there is a great possibility of performance gain, having a single test project, tends to decrease performance, unless another surefire plugin is run in parallel.

Sources:

link

link

    
27.06.2015 / 23:34