Maven-mvnd: Drop-In Replacement for Faster Java Builds via Daemon & GraalVM
This article introduces Maven-mvnd (mvnd), a drop-in replacement for Apache Maven that uses a persistent daemon process and GraalVM native executables to dramatically accelerate build times, especially for multi-module projects, while maintaining full compatibility with existing Maven POM files and commands.
Maven-mvnd Introduction
Apache Maven is stable, reliable, and has a mature ecosystem, but its build speed becomes a bottleneck for larger projects — often forcing builds to run only on servers. Gradle offers faster builds via daemon processes and caching, yet its rapid version churn and steeper learning curve deter some teams.
Maven-mvnd (mvnd) is developed by the Apache Maven team, borrowing ideas from Gradle and Takari. It is a strengthened version of Maven that solves the slow-build problem without requiring developers to learn a new tool; if you know Maven, you can use mvnd immediately.
Pain Points Addressed
Slow build speed: Maven's main bottleneck is JVM initialization at the start of every build cycle. Loading thousands of classes and setting up the environment is especially costly in large, multi-module projects. mvnd maintains a long-running Maven daemon, avoiding repeated JVM startups.
High resource consumption: Each Maven build consumes CPU and memory for JVM startup. mvnd's daemon stays alive between builds, reducing waste — particularly beneficial in CI/CD pipelines with frequent builds.
Latency in frequent builds: Modern development demands fast feedback loops. Traditional Maven makes developers wait longer after code changes. mvnd accelerates the build process, shortening wait times and boosting productivity.
Multi-project build optimization: Organizations with many Maven projects see significant time savings. The daemon can be shared across multiple build requests, reducing per-project overhead.
Easy migration: mvnd usage mirrors traditional Maven almost exactly. No new syntax or POM changes are needed, making it a low-risk adoption for teams wanting performance gains without leaving the Maven ecosystem.
Key Features
Embeds Maven — no separate Maven installation required; seamless transition.
Actual builds run in a persistent background daemon process. If no idle daemon is available, multiple daemons can be spawned in parallel.
A single daemon instance handles multiple sequential requests from the mvnd client.
Built as a GraalVM native executable, it starts faster and uses less memory than a traditional JVM.
Architectural Advantages
The JVM running the actual build does not restart for each build, saving time.
JIT-compiled native code is retained in the daemon. Compared to Maven, JIT compilation time is reduced; optimized code is immediately available on repeated builds.
This applies not only to Maven core and plugin code, but also to all code from the JDK itself.
Installation Steps
Download
Releases:
https://github.com/mvndaemon/mvnd/releasesInstall
Unzip the archive, then configure environment variables:
JAVA_HOME MAVEN_HOME MAVEN_MVND_HOMEAdd the bin directory to PATH. Prerequisite: JAVA_HOME must exist.
Test
mvnd -vUsage
Usage and parameters are identical to Maven. Replace mvn with mvnd:
Maven: mvn clean package mvnd:
mvnd clean packageConfiguration
For maximum compatibility, reuse the existing Maven settings.xml.
Open $MAVEN_MVND_HOME/conf/mvnd.properties and append at the end:
maven.settings=F:/javaee/apache-maven-3.6.3/conf/settings.xmlIf JAVA_HOME is not set, you can also specify the JDK path in this file.
Packaging Comparison
# maven packaging command
mvn clean package '-Dmaven.test.skip=true'
# mvnd packaging command
mvnd clean package '-Dmaven.test.skip=true'The more sub-modules a project has, the more pronounced the speed advantage. For projects with many modules, mvnd can save significant time in test and production packaging.
Gradle remains another viable option for high-efficiency packaging; teams can adopt one or a mixed approach.
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.
SpringMeng
Focused on software development, sharing source code and tutorials for various systems.
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.
