All cheatsheetsJava Development

mvnd

Maven Daemon 1.0+

Quick reference for Maven Daemon (mvnd) — a long-lived JVM wrapper around `mvn` that keeps a background daemon to skip JVM startup on every build. Same CLI as Maven, plus daemon management commands.

29 commands

Daemon management

mvnd --status

List every running mvnd daemon: ID, JDK home, version, uptime, idle time, current/finished build count. Mirrors `mvnd --status -o plain` for scripting.

-o plain|json output format

mvnd --status
mvnd --stop

Stop a single idle daemon. Pass the daemon's ID shown by `--status`. Prompts for confirmation unless `-y` is supplied.

-y skip confirmation

mvnd --stop 7d3c4e5f-a1b2-4c3d-9e0f-1234567890ab
mvnd --stop-all

Shut down every running mvnd daemon. Useful before a JDK upgrade, before switching `JAVA_HOME`, or as a CI pre-step that always wants a cold start.

mvnd --stop-all
mvnd --shutdown

Alias for `--stop-all`. Same behavior; preferred in scripts that target mvnd 1.0+ explicitly.

mvnd --shutdown
mvnd --version

Print mvnd version, Java version of the launcher, and the version of Maven used to run the daemon. Confirms which daemon will be created or reused.

mvnd --version
mvnd --create-daemon

Force-create a new daemon with the current JDK and Maven version instead of reusing one. Handy after a `JAVA_HOME` switch to avoid the old daemon holding stale class data.

--user <name> JVM config preset

mvnd --create-daemon clean install

Lifecycle phases (drop-in for mvn)

mvnd validate

Validate the project: parse `pom.xml`, download snapshots, sanity-check dependencies. Identical to `mvn validate`.

mvnd validate
mvnd compile

Compile `src/main/java` into `target/classes`. With a warm daemon this is dramatically faster than `mvn compile` because the JIT has already optimized the plugins.

-DskipTests; -T 4 parallel threads (forwarded to mvn)

mvnd compile
mvnd test

Run Surefire unit tests. Tests still fork a fresh JVM, so test isolation is unchanged — the speedup is only on the Maven side.

-Dtest=ClassName; -Dtest=Class#method; -DfailIfNoTests=false

mvnd test -Dtest=UserServiceTest
mvnd package

Run every prior phase and package the output into `target/*.jar` (or `.war`/`.ear`).

-DskipTests; -Dpackaging=jar

mvnd package -DskipTests
mvnd install

Run verify, then copy the produced artifact into `~/.m2/repository/` so other local projects can depend on it.

mvnd install -DskipTests
mvnd clean install

Wipe `target/` then run through `install`. The standard "rebuild from scratch" command, but considerably faster under mvnd because the daemon survives `clean`.

-U force-update of snapshot dependencies

mvnd clean install -U
mvnd deploy

Build and push the artifact to the remote repository declared in `pom.xml`'s `<distributionManagement>`. Same semantics as `mvn deploy`.

-DskipTests; -P release use release profile

mvnd deploy -P release -DskipTests

Daemon tuning

mvnd -Dmvnd.daemonStorage=<path> <phase>

Override the daemon registry directory (default `~/.m2/mvnd/`). Use a per-project path to give each worktree its own daemon pool.

mvnd -Dmvnd.daemonStorage=.mvnd clean install
mvnd -Dmvnd.idleTimeout=<duration> <phase>

Set how long a daemon can sit idle before auto-shutdown. Default 3h. Accepts `30s`, `5m`, `2h`, `1d`.

mvnd -Dmvnd.idleTimeout=30m test
mvnd -Dmvnd.maxHeap=<size> <phase>

Cap the daemon JVM heap. Default 2G. Lower to share RAM with other tools; raise if you see `OutOfMemoryError` during heavy multi-module builds.

mvnd -Dmvnd.maxHeap=4G clean install
mvnd -Dmvnd.threads=<n> <phase>

Maximum number of concurrent daemons mvnd will keep alive. Default = number of CPU cores. Set lower to reduce idle memory usage; set higher to allow different JDK/Maven combinations in parallel.

mvnd -Dmvnd.threads=2 test
mvnd -Dmvnd.scheduler=simple|async <phase>

Choose how the daemon is selected. `simple` (default) picks the most-recently-used daemon; `async` keeps one daemon per Maven/JDK combination and dispatches to the matching one. Use `async` when juggling multiple JDKs.

mvnd -Dmvnd.scheduler=async install

Build control (forwarded)

mvnd -DskipTests <phase>

Skip running tests but still compile them. Same as mvn — mvnd forwards all `-D` system properties unchanged.

mvnd -DskipTests package
mvnd -T <n> <phase> / mvnd -T 1C <phase>

Parallel reactor builds: `-T 4` for 4 threads, `-T 1C` for 1 thread per CPU core. Combined with mvnd's warm daemon, `-T 1C clean install` is the fastest possible full build.

mvnd -T 1C clean install
mvnd -B -ntp <phase>

Batch / non-interactive / no-transfer-progress. The recommended CI invocation — mvnd disables progress bars and ANSI colors so log parsers stay happy.

mvnd -B -ntp clean verify
mvnd -X <phase>

Debug logging. Prints every plugin execution and repository lookup. Pipe to file — output is large.

-e full stack traces on errors

mvnd -X test > mvnd-debug.log 2>&1
mvnd -pl <module> -am <phase>

Build one module plus everything it depends on. `-amd` (also-make-dependents) is the inverse. Identical to mvn flags.

mvnd -pl user-service -am test
mvnd -s <settings.xml> <phase>

Override `~/.m2/settings.xml` for this build. CI uses this to point at mirrored repos / release credentials.

mvnd -s ./.mvn/settings.xml deploy
mvnd -o <phase>

Offline mode — fail if any artifact is missing from the local repo. mvnd forwards this flag unchanged; the daemon just does the resolution work itself.

mvnd -o test

Diagnostics

mvnd --log <phase>

Stream the daemon-side Maven build log into the foreground (it goes to `~/.m2/mvnd/<daemon-id>/daemon.log` by default). Useful for debugging daemon-only failures.

mvnd --log test
mvnd --purge

Delete the entire daemon registry directory (`~/.m2/mvnd/` by default). After a JDK or Maven upgrade that changes byte layout, stale daemons can produce confusing errors — purge first.

mvnd --purge
mvnd --help

List every mvnd-specific flag (the `--status` family). For the full Maven flag set (`-D`, `-P`, `-T`, `-pl`, etc.) see `mvn --help` — mvnd forwards all of them.

mvnd --help

Wrapper

./mvnw <phase>

Run a build through the Maven Wrapper. To use mvnd transparently, rename/symlink to `./mvndw` or configure `.mvn/maven.config` to invoke mvnd instead of mvn — see `mvn -Dmaven.wrapper mvnd` recipes.

./mvnw clean install

Related command cheatsheets

About Maven Daemon

Apache Maven Daemon (mvnd) is a wrapper around the standard `mvn` CLI that keeps one or more long-lived JVM daemons in the background and dispatches builds to them. The project was created by Peter Palaga and the first stable release (1.0.0) shipped in 2024 after years of incubation at the Apache Software Foundation. mvnd reuses the same `pom.xml`, `~/.m2/repository`, plugins, and lifecycle phases as Maven 3.x, so it is a true drop-in replacement — `mvnd compile` behaves exactly like `mvn compile`, just faster. The speedup comes from three sources: (1) the JVM itself is started once and reused across builds (skipping the 1-3 second JVM startup tax that mvn pays on every invocation); (2) mvnd uses GraalVM as the JDK for the daemon process, which lowers warm-up time and RSS; and (3) it can run multiple module builds in parallel within a single daemon. Build speedups range from 2x on small single-module projects to 10x or more on large multi-module reactors with thousands of classes. mvnd writes its daemon registry under `~/.m2/mvnd/` (separate from the regular `~/.m2/repository/`) so multiple daemons can coexist with different JDKs. The daemon auto-shuts down after a configurable idle timeout (default 3 hours). All processing is local; no source code or artifacts are sent anywhere.

Cheatsheet version 1.0.0