Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to time the different stages of maven execution

I have a maven build that is extremely slow. I would like to know whether there is a way to profile maven execution in order to find out which are the most time-consuming steps.

Later I will want to compare these times between builds for older versions (which were faster), so they should be ideally in a format that can be compared/diffed/graphed.

like image 627
Carles Barrobés Avatar asked Feb 25 '11 17:02

Carles Barrobés


People also ask

What are the Maven stages?

Maven Lifecycle: Below is a representation of the default Maven lifecycle and its 8 steps: Validate, Compile, Test, Package, Integration test, Verify, Install and Deploy.

What are the 3 build lifecycle of Maven?

There are three built-in build lifecycles: default, clean and site. The default lifecycle handles your project deployment, the clean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's web site.

How many phases are there in Maven?

Each lifecycle consists of a sequence of phases.The default build lifecycle consists of 23 phases, as it's the main build lifecycle. On the other hand, the clean life cycle consists of 3 phases, while the site lifecycle is made up of 4 phases.


1 Answers

This is the quickest possible way:

export MAVEN_OPTS="-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS \                    -Dorg.slf4j.simpleLogger.showDateTime=true"  mvn test 

Results in

MAVEN_OPTS="-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS -Dorg.slf4j.simpleLogger.showDateTime=true" mvn test 17:06:07,330 [INFO] Scanning for projects... 17:06:07,447 [INFO]  17:06:07,447 [INFO] ------------------------------------------------------------------------ 17:06:07,448 [INFO] Building bimble-server 0.0.1-SNAPSHOT 17:06:07,448 [INFO] ------------------------------------------------------------------------ 17:06:07,747 [INFO]  17:06:07,748 [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ bimble-server --- 

If you then add that environment variable to your shell's config file (like ~/.bashrc or ~/.profile) you will have those timings every time you use Maven.

Based on info from Stanley Hillner's blog:

like image 98
oligofren Avatar answered Sep 22 '22 23:09

oligofren