Boost Maven Build Speed with mvnd: GraalVM-Powered Daemon Explained
The article introduces mvnd, a GraalVM‑based Maven daemon that accelerates builds by reusing processes, leveraging JIT compilation, and supporting parallel execution, then details installation across Linux, macOS and Windows, configuration tips, and usage commands, showing how it narrows the performance gap with Gradle.
Maven is often compared with Gradle , and its biggest drawback has been slower build times—Gradle can be 2 to 10 times faster. The Apache Maven team, inspired by Gradle and Takari (a Maven lifecycle optimizer), has enhanced Maven with the maven-mvnd project.
Simple Introduction
mvnd is not a rewrite of Maven; it embeds Maven inside one or more daemon processes that provide build services. A daemon instance can serve multiple consecutive build requests from mvnd clients, and when no idle daemon is available, mvnd can spawn additional daemons in parallel.
Using GraalVM Instead of the JVM
mvnd gains speed by running on GraalVM rather than the traditional JVM, resulting in faster startup, lower memory usage, and no need to launch a new JVM for each build. Maven plugins are cached across builds, though SNAPSHOT versions are not.
Supporting JIT
The Just‑In‑Time (JIT) compilation feature of GraalVM is applied to Maven build jobs, dramatically reducing compilation time and making optimized code immediately available during repeated builds.
Parallel Builds
While Maven 3’s parallel builds are still experimental and require thread‑safe plugins, mvnd natively supports parallel execution across multiple CPU cores. You can switch to serial builds with the -T1 option if needed.
Simple Try‑Out
Installation
mvnd runs on Linux, macOS, and Windows. It can be installed via package managers such as SDKMAN , Homebrew , or Chocolatey , or by downloading the binary from the mvnd release repository. Example for Windows using Chocolatey: choco install mvndaemon Installation may take some time.
Configuration
Configuration is straightforward; just note two points:
If you install without a package manager, ensure the bin directory of mvnd is added to PATH.
If you do not set JAVA_HOME, add java.home to ~/.m2/mvnd.properties, e.g., java.home=C:\AdoptOpenJDK\jdk-8. Skip this step if the environment variable is already configured.
Other configuration options are documented in the mvnd configuration guide.
Usage
After installation and configuration, run: mvnd --version If the output shows version information, the installation succeeded.
mvnd --version
mvnd native client 0.7.1-windows-amd64 (97c587c11383a67b5bd0ff8388bd94c694b91c1e)
Terminal: org.jline.terminal.impl.jansi.win.JansiWinSysTerminal
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: C:\Program Files\mvndaemon\mvnd-0.7.1-windows-amd64\mvn
Java version: 1.8.0_282, vendor: AdoptOpenJDK, runtime: C:\Program Files\AdoptOpenJDK\jdk-8.0.282.8-hotspot\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"To lower the learning curve, mvnd mirrors the traditional mvn command, so you can replace mvn with mvnd or view options via mvnd --help.
Parallel builds feel as fast as a rocket, and console output has been optimized.
Thanks to GraalVM, this tool may extend Maven’s lifespan and prevent Gradle from pulling ahead too quickly. It’s worth watching Apache Maven’s future developments.
References
Takari (Maven lifecycle optimizer): http://takari.io/book/40-lifecycle.html
maven-mvnd: https://github.com/apache/maven-mvnd
mvnd release repository: https://github.com/mvndaemon/mvnd/releases
mvnd configuration: https://github.com/mvndaemon/mvnd/blob/master/dist/src/main/distro/conf/mvnd.properties
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
