sebastiandaschner blog


Analyze Maven build time

#maven sunday, november 15, 2015

Maven project builds are often said to be slow. In fact Maven itself is quite fast — it’s the extensive use of plugins and dependencies which makes it slow. To see which Maven module, goal or plugin takes which amount of time the Maven buildtime extension can be added.

Therefore simply add following build extension to your pom:

<build>
    <extensions>
        <extension>
            <groupId>co.leantechniques</groupId>
            <artifactId>maven-buildtime-extension</artifactId>
            <version>2.0.2</version>
        </extension>
    </extensions>
</build>

This will result in an output containing information about each module, goal and plugin:

...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.761 s
[INFO] Finished at: 2015-11-15T13:57:31+01:00
[INFO] Final Memory: 26M/277M
[INFO] ------------------------------------------------------------------------
[INFO] Build Time Summary:
[INFO]
[INFO] asciiblog
[INFO]   maven-clean-plugin:clean (default-clean) ................. [0.113s]
[INFO]   maven-compiler-plugin:testCompile (default-testCompile) .. [0.377s]
[INFO]   maven-install-plugin:install (default-install) ........... [0.133s]
[INFO]   maven-surefire-plugin:test (default-test) ................ [6.656s]
[INFO]   maven-war-plugin:war (default-war) ....................... [1.919s]
[INFO]   maven-compiler-plugin:compile (default-compile) .......... [1.629s]
[INFO]   maven-resources-plugin:resources (default-resources) ..... [0.190s]
[INFO]   maven-resources-plugin:testResources (default-testResource [0.008s]
[INFO] ------------------------------------------------------------------------

With that information it’s a lot simpler to optimize the build time of your Maven projects. The overhead of the extension itself is negligible; it made the build time about 0.5 seconds slower in my example.

 

Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: