How Maven‑mvnd Supercharges Java Builds with a Daemon Process
Maven‑mvnd introduces a long‑running daemon to eliminate JVM startup overhead, cut resource usage, accelerate frequent builds, and streamline multi‑module projects, while remaining compatible with existing Maven workflows and offering GraalVM‑based native execution for faster, lighter builds.
Problem
Traditional Maven launches a new JVM for every build. JVM startup loads many classes and initializes the environment, which becomes a dominant bottleneck in large or multi‑module projects. The repeated allocation of CPU and memory also hurts CI/CD pipelines that run builds frequently.
Solution – Maven mvnd (mvnd)
mvnd runs a long‑lived Maven daemon that keeps a JVM alive across builds. The daemon can serve several consecutive or parallel build requests, eliminating the JVM startup cost and reducing resource consumption.
Key Features
Embedded Maven – no separate Maven installation is required.
Builds execute inside a persistent background process (the daemon). If no idle daemon is available, additional daemons are spawned in parallel.
A single daemon instance can handle multiple consecutive mvnd client requests.
Native executable compiled with GraalVM, which starts faster and uses less memory than a traditional JVM.
JIT‑compiled code remains in memory, so subsequent builds benefit from already‑optimized native code.
Installation
Download the latest release from the GitHub page: https://github.com/mvndaemon/mvnd/releases
Extract the archive.
Set the required environment variables:
JAVA_HOME MAVEN_HOME MAVEN_MVND_HOME(the directory where mvnd was extracted)
Add the bin directory of MAVEN_MVND_HOME to PATH. Ensure JAVA_HOME points to a valid JDK.
Verify the installation:
mvnd -vUsage
mvnd uses the same command‑line syntax as Maven. Replace the mvn executable with mvnd while keeping all options unchanged.
# Maven
mvn clean package -Dmaven.test.skip=true
# mvnd
mvnd clean package -Dmaven.test.skip=trueConfiguration
Existing settings.xml can be reused. To point mvnd to a custom settings file, edit /conf/mvnd.properties in the installation directory and add a line such as:
maven.settings=F:/javaee/apache-maven-3.6.3/conf/settings.xmlIf JAVA_HOME is not set globally, you can also specify the JDK path in mvnd.properties using the same property name.
Packaging Performance Comparison
Empirical observations show that as the number of sub‑modules increases, the relative speed advantage of mvnd grows. In large modular projects, mvnd can reduce total packaging time by a noticeable margin compared with plain Maven.
# Maven packaging command
mvn clean package -Dmaven.test.skip=true
# mvnd packaging command
mvnd clean package -Dmaven.test.skip=trueFor teams that require the highest build efficiency, Gradle is mentioned as an alternative, but mvnd provides a low‑risk migration path because it works with existing Maven POMs and settings.
Java Web Project
Focused on Java backend technologies, trending internet tech, and the latest industry developments. The platform serves over 200,000 Java developers, inviting you to learn and exchange ideas together. Check the menu for Java learning resources.
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.
