Home | Blog

Speed up the Maven Build Time

Cover Image for Speed up the Maven Build Time
Matija Kovacek
Matija Kovacek

Recently I found a tool to speed up the build time of your Maven-based projects.

Maven Daemon is a maven wrapper that provides faster build time.

Some facts about Maven Daemon:

  • build executes in a long-living background process
  • native executable
  • use multiple CPU cores to build modules in parallel

More information about Maven Daemon you can find in github repository.

Maven Daemon Installation

Use sdk or brew to install Maven Daemon

$ sdk install mvnd

$ brew install mvndaemon/homebrew-mvnd/mvnd

Verify the installation with

āžœ  ~ mvnd --version
mvnd native client 0.2.0-darwin-amd64 (0cd0b3f04692b7970fda06c206c1fbaac68fe9ce)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.osx.OsXNativePty
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/mvnd/HEAD-1c610c3/libexec/mvn
Java version: 15.0.1, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.1/libexec/openjdk.jdk/Contents/Home
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"

Maven vs Maven Daemon build time comparison

I will compare build times for the Adobe Experience Manager (AEM) project for testing purposes. The project was built 2x times before measurement.

This measurement is not perfect, since a lot of factors can affect the final build time (+- a few seconds), but it's fair enough to see a difference. For testing purposes, I have used AEM Project Archetype version 24.

  • mvn clean install vs mvnd clean install
    • mvn: 26.586 s
    • mvnd: 12.654 s
mvn clean install

[INFO] Reactor Summary for mysite 1.0.0-SNAPSHOT:
[INFO]
[INFO] mysite ............................................. SUCCESS [  0.242 s]
[INFO] My Site - Core ..................................... SUCCESS [  6.994 s]
[INFO] My Site - UI Frontend .............................. SUCCESS [ 11.099 s]
[INFO] My Site - Repository Structure Package ............. SUCCESS [  0.795 s]
[INFO] My Site - UI apps .................................. SUCCESS [  3.890 s]
[INFO] My Site - UI content ............................... SUCCESS [  1.672 s]
[INFO] My Site - UI config ................................ SUCCESS [  0.105 s]
[INFO] My Site - All ...................................... SUCCESS [  0.138 s]
[INFO] My Site - Dispatcher ............................... SUCCESS [  0.080 s]
[INFO] My Site - UI Tests ................................. SUCCESS [  0.274 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  26.586 s
[INFO] Finished at: 2020-12-30T11:59:11+01:00
[INFO] ------------------------------------------------------------------------
mvnd clean install

[INFO] Reactor Summary for mysite 1.0.0-SNAPSHOT:
[INFO]
[INFO] mysite ............................................. SUCCESS [  0.016 s]
[INFO] My Site - Core ..................................... SUCCESS [  4.300 s]
[INFO] My Site - UI Frontend .............................. SUCCESS [ 10.442 s]
[INFO] My Site - Repository Structure Package ............. SUCCESS [  0.178 s]
[INFO] My Site - UI apps .................................. SUCCESS [  1.126 s]
[INFO] My Site - UI content ............................... SUCCESS [  0.911 s]
[INFO] My Site - UI config ................................ SUCCESS [  0.156 s]
[INFO] My Site - All ...................................... SUCCESS [  0.107 s]
[INFO] My Site - Dispatcher ............................... SUCCESS [  0.078 s]
[INFO] My Site - UI Tests ................................. SUCCESS [  0.063 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.654 s (Wall Clock)
[INFO] Finished at: 2020-12-30T11:59:58+01:00
[INFO] ------------------------------------------------------------------------
  • mvn clean install -PautoInstallPackage vs mvnd clean install -PautoInstallPackage

    • mvn: 29.582 s
    • mvnd: 12.995 s

mvn clean install -PautoInstallPackage

[INFO] Reactor Summary for mysite 1.0.0-SNAPSHOT:
[INFO]
[INFO] mysite ............................................. SUCCESS [  0.223 s]
[INFO] My Site - Core ..................................... SUCCESS [  7.354 s]
[INFO] My Site - UI Frontend .............................. SUCCESS [ 11.338 s]
[INFO] My Site - Repository Structure Package ............. SUCCESS [  0.826 s]
[INFO] My Site - UI apps .................................. SUCCESS [  4.343 s]
[INFO] My Site - UI content ............................... SUCCESS [  2.885 s]
[INFO] My Site - UI config ................................ SUCCESS [  0.454 s]
[INFO] My Site - All ...................................... SUCCESS [  0.346 s]
[INFO] My Site - Dispatcher ............................... SUCCESS [  0.061 s]
[INFO] My Site - UI Tests ................................. SUCCESS [  0.374 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  29.582 s
[INFO] Finished at: 2020-12-30T12:06:29+01:00
[INFO] ------------------------------------------------------------------------


mvnd clean install -PautoInstallPackage

[INFO] Reactor Summary for mysite 1.0.0-SNAPSHOT:
[INFO]
[INFO] mysite ............................................. SUCCESS [  0.005 s]
[INFO] My Site - Core ..................................... SUCCESS [  4.004 s]
[INFO] My Site - UI Frontend .............................. SUCCESS [ 10.288 s]
[INFO] My Site - Repository Structure Package ............. SUCCESS [  0.177 s]
[INFO] My Site - UI apps .................................. SUCCESS [  1.433 s]
[INFO] My Site - UI content ............................... SUCCESS [  1.010 s]
[INFO] My Site - UI config ................................ SUCCESS [  0.292 s]
[INFO] My Site - All ...................................... SUCCESS [  0.227 s]
[INFO] My Site - Dispatcher ............................... SUCCESS [  0.079 s]
[INFO] My Site - UI Tests ................................. SUCCESS [  0.053 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.995 s (Wall Clock)
[INFO] Finished at: 2020-12-30T12:08:30+01:00
[INFO] ------------------------------------------------------------------------

Note Your AEM project build will fail with Maven Daemon if you use bnd-maven-plugin version older than 5.1.0

[ERROR] Failed to execute goal biz.aQute.bnd:bnd-maven-plugin:5.0.0:bnd-process (bnd-process) on project my-site.core: bnd error: null: ConcurrentModificationException -> [Help 1]

Sum up

As test results shows, Maven Daemon build time is approximately 2x faster then normal maven. Installation is pretty much straightforward and so far didn't notice any downsides, so why not use it and save some time.

Read more

Cover Image for Optimizing slow Unit Tests

Optimizing slow Unit Tests

Understanding the motivation behind optimizing slow unit tests is crucial. We'll explore the challenges faced by Client XYZ, why we wanted to fix them, and the good things that happened afterward. Expect insights into how faster tests can boost productivity and project success.

Matija Kovacek
Matija Kovacek
Cover Image for Importance of Code reviews

Importance of Code reviews

Inspired by some of the last few projects, I have noticed that still a lot of people don't consider Code Review seriously. So what is code review? A code review is a process where someone other than the author(s) of a piece of code examines that code. Code review should be used to maintain the quality of our code and products.

Matija Kovacek
Matija Kovacek
Cover Image for AEM API Integration with Feign HTTP client

AEM API Integration with Feign HTTP client

How to call RESTful Web Service in AEM? Luckily there is Feign HTTP client which simplifies REST API Integrations. Check out how to integrate it in AEM project.

Matija Kovacek
Matija Kovacek
Cover Image for Speed up the Maven Build Time

Speed up the Maven Build Time

How to speed up Maven build time? 2x time faster Maven build time with Maven Daemon.

Matija Kovacek
Matija Kovacek
Cover Image for Test behaviour, not implementation

Test behaviour, not implementation

Test behaviour, not implementation if you want to build right product. For your own good it will save you time and money.

Matija Kovacek
Matija Kovacek
Cover Image for Really? Preselected checkbox not working, common AEM?

Really? Preselected checkbox not working, common AEM?

Why one simple preselected checkbox doesn't work in page properties?

Matija Kovacek
Matija Kovacek
Cover Image for Updating AEM content with Sling Pipes

Updating AEM content with Sling Pipes

You are still updating content manually? Try out Sling pipes. Sling pipes is simple tool for executing CRUD operations over resources in AEM repository. But is it powerfull enough to replace your groovy scripts?

Matija Kovacek
Matija Kovacek