How to speed up the maven builds

This article has good tips how to increase the build time using maven:

https://zeroturnaround.com/rebellabs/your-maven-build-is-slow-speed-it-up/

 

I’ve addapted it for the IntelliJ idea IDE:

In short, for IntelliJ Idea change the following

in parameters add(inside the Run/Debug Configurations):

install -DskipTests=true -offline

it’s better to use install instead of the clean install because most of the time clean is not required, -DskipTests=true will skip the tests and -offline won’t download any snapshots that already exists.

in General, in Threads (-T option) add 1C, this means that each core will dedicate one thread  for building

In Runner, in the VM options add:

-XX:+TieredCompilation -XX:TieredStopAtLevel=1

this is the Java VM options for speeding up the build

Alternatively, you can add the only project that you actually need

Ex: instead of install -DskipTests=true -offline use

install  –pl YOUR_MODULE -am -DskipTests=true -offline

pl makes Maven build only specified modules and not the whole project.

am makes Maven figure out what modules out target depends on and build them too.

Advertisements