buildmaven-2build-automation

How can I do parallel builds in Maven?


When you build with Maven on a multicore / multi-CPU machine, it would often be possible to build different subprojects in parallel. Is there a way to do this with Maven? Is there a plugin for this / whatever?


Solution

  • Maven 3 (as of beta 1) now supports parallel builds as an experimental feature.

    For example,

    mvn -T 4 clean install    # Builds with four threads
    mvn -T 1C clean install   # One thread per CPU core
    mvn -T 1.5C clean install # 1.5 thread per CPU core
    

    Full documentation can be found on the Maven wiki: Parallel builds in Maven 3 - Apache Maven - Apache Software Foundation.