Java Tip of the Week #7 – Maven Slow?

This week Java Tip of the Week is a follow up of last session about Maven. The first video covered aspects related to Maven Dependencies. This video will cover some techniques to speed up your Maven build.

Maven Slow?

Since Maven 3, you are able to run your builds in parallel. Depending on the build machine and the project structure, you might get a 60% speedup increase!

Also, there are some ways to selectively pick just the things you want to build, using the -amd and -am flags. These are available since Maven 2, but for some reason they don’t seem to be used that much.

Check the video:

For reference, here are the commands:

Command

Description

mvn clean install -T 1C

Builds the project with one Thread per Core

mvn clean install -T 2C

Builds the project with two Threads per Core

mvn clean install -T 4

Builds the project with fours Threads

mvn clean install -pl [project-name] -amd

Builds just the project specified in -pl and all the dependent projects.

mvn clean install -pl [project-name] -am

Builds just the project specified in -pl and all the required projects to build it.