How to decrease the Maven build time of your Java projects

23 May

There are good resources on the web that shows how you can decrease the Maven build times of Java projects, but since I couldn’t find the following information in most of them, I wanted to note this down for future reference. One of the simplest things you can do to decrease the Maven build time is to add the following to your command line:


But is it worth it? Let’s check. Take an example project such as Hadoop that is about 2 million lines of source code. Without skipping the generation of Javadoc,

mvn clean package -Pnative -Pdist -DskipTests -Dtar

Maven reports that build took about 8.5 minutes.

whereas building the same project by skipping the Javadoc generation:

mvn clean package -Dmaven.javadoc.skip=true -Pnative -Pdist -DskipTests -Dtar

the build time goes down to approximately 1.5 minutes.

Going down to 1.5 minutes from about 8.5 minutes simply by using a single additional option to Maven is not a bad win I suppose, especially if you are in the business of patching, building and deploying some big open source projects for testing, such as Hadoop, and you don’t need any Javadoc.

These numbers are from a desktop machine, running Ubuntu GNU/Linux 15.04, Oracle Java version 1.8.0_45, and Maven version 3.3.9. The machine has 16 GB of RAM, INTEL i7-4790 CPU with 8 cores, and a Samsung SSD 850 disk with 500 GB capacity.


Posted by on May 23, 2016 in java, Programlama


Tags: , ,

2 responses to “How to decrease the Maven build time of your Java projects

  1. Volkan Yazıcı

    June 1, 2016 at 19:46

    Interesting insight. Would you mind also providing individual effect of each parameter? Additionally, note that -Pnative and -Pdist are per see Hadoop specific profiles.

    • Emre Sevinç

      June 1, 2016 at 20:56

      If by your request you mean the build times when `-Pdist` (with `-Dtar`) and `-Pnative` are enabled in isolation (one without the other), sure, I’ll give it a go when I have time. My initial guess is that, not building the native libraries might shave a few minutes.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: