Why Maven mvnd Can Boost Java Build Speed Up to 10×

The article introduces Maven mvnd, explains its daemon‑based architecture, shows benchmark results where multi‑module builds run 3.5–5.5 times faster (up to 10× for single modules), and provides step‑by‑step installation, configuration, PowerShell encoding fixes, and IDEA integration guidance.

Java Companion
Java Companion
Java Companion
Why Maven mvnd Can Boost Java Build Speed Up to 10×

Overview of mvnd

Maven mvnd is a daemon‑based replacement for Maven introduced in 2023. It embeds Maven, runs builds in a long‑lived background process, and uses a GraalVM‑compiled native client for faster startup and lower memory usage. Multiple daemon instances can serve consecutive client requests, and if none are idle, new daemons are spawned in parallel.

Architectural Benefits

The JVM used for the actual build does not need to restart for each build.

Classloader caches for Maven plugins persist across builds, so plugin JARs are read and parsed only once (SNAPSHOT versions are not cached).

JIT‑compiled native code is retained, reducing compilation time for repeated builds.

Installation and Configuration

Download the appropriate mvnd package from https://downloads.apache.org/maven/mvnd/ and extract it to a directory without Chinese characters. Edit config/mvnd.properties to point to your existing Maven settings.xml if needed. Add the mvnd directory to MAVEN_HOME and update the PATH (or use the bin folder directly). Verify the installation by running mvnd --version and checking the displayed version number.

Performance Comparison Tests

Tests were run on a laptop with an Intel Core Ultra 5 125H (14 cores/18 threads), 32 GB RAM, and a 1 TB SSD. Three scenarios were measured:

Multi‑module clean + package: 65/17≈3.5× faster.

Multi‑module package (no clean): 22/4≈5.5× faster.

Single‑module clean + package: 10/5=2× faster.

When using mvnd package, the console shows parallel execution of modules, explaining the larger speedup for multi‑module builds. Single‑module builds still benefit from mvnd’s optimizations, roughly doubling the speed.

Fixing Console Chinese‑Garbage Output

Running mvnd in the default PowerShell console produced garbled Chinese characters. The solution is to set PowerShell’s output encoding to UTF‑8:

$OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[Console]::InputEncoding = [System.Text.Encoding]::UTF8

For a permanent fix, add the same commands to the PowerShell profile (retrieved via $profile) and optionally set JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8". After restarting the console, the build output displays correctly.

Using mvnd in IntelliJ IDEA

Because the IDE’s Maven side‑panel may not yet recognize mvnd, keep the original Maven configuration unchanged and invoke mvnd via the command line or the maven‑helper plugin. Install the plugin from the marketplace, restart IDEA, and configure the plugin to call mvnd. The plugin adds two new Maven actions to the right‑click menu; selecting them runs the build with mvnd, and the executed command (e.g., mvnd package) is shown in the console. The original Maven lifecycle actions remain functional.

Conclusion

mvnd delivers noticeable build‑time reductions, especially for multi‑module projects, with up to a ten‑fold speed increase for single‑module clean builds. The article provides a complete workflow: download, install, configure environment variables, resolve console encoding issues, and integrate mvnd into IDEA.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PerformancemavenIntelliJ IDEAJava buildPowerShellmvnd
Java Companion
Written by

Java Companion

A highly professional Java public account

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.