Using Multiple Threads to Run a Faster Build on Maven

Asked

Viewed 228 times

0

What the Maven offers in terms of parallelism for the execution of builds?

If I execute one build in 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?

1 answer

1


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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.