Maven-mvnd blew my screen over the weekend, so I downloaded an MVND to try it out. Although the test data are based on my local project, it is not universal and authoritative, but it is enough to illustrate the problem. Its test results far exceeded my expectations, so let’s take a look.

What is MVND?

MVND is short for Maven Daemon, which translates to Maven Daemon in Chinese.

MVND is a subproject of Apache/Maven. It is not a new build tool, but an extension of Maven. Maven is built in by building one or more Maven daemons to perform build services.

MVND overview

1. The goal of MVND is to provide faster Maven builds using techniques known to Gradle and Takari.

Gradle is an automated project builder based on Apache Ant and Apache Maven concepts. Gradle build scripts are written using Groovy or Kotlin’s domain-specific language instead of traditional XML. Gradle’s biggest advantage is that it builds faster than traditional Maven. Takari is at the heart of Maven-Wrapper, and most open source projects provide Warpper to allow users to quickly build projects without installing Maven.

2. MVND is embedded with Maven, so there is no need to install Maven separately.

3. A daemon instance can serve multiple consecutive requests from MVND clients.

4. MVND clients build local executables using GraalVM, which starts faster and consumes less memory than traditional JVMS.

5. If MVND does not have free daemons to service a build request, multiple daemons can be generated in parallel.

MVND advantages

MVND has the following advantages:

  1. The JVM used to run the build does not need to be restarted with each build.
  2. Classloaders that hold Maven plug-in classes are cached in multiple builds. Therefore, the plug-in JAR file is read and parsed only once. (Snapshot versions of Maven plugins are not cached.)
  3. Native code generated by the just-in-time (JIT) compiler in the JVM is also retained, and JIT compilation takes less time than regular Maven. During repeated builds, JIT-optimized code is immediately available, not only for code from Maven plug-ins and Maven Core, but for all code from the JDK itself.

MVND installation

MVND supports Windows, Linux, and Macos. This document uses Windows as an example.

1. Download and decompress MVND

Download address:Github.com/apache/mave…Select the latest Windows resource pack, as shown below:

After the download is complete, unzip to a local directory, as shown below:

2. Configure environment variables

Configure the execution directory bin of the MVND decoding package into the system variable path, as shown in the following figure:

3. Test the MVND installation

Then open the command line window and use “mvnd-version” to check whether MVND is installed successfully, as shown in the following figure:If the related version information is printed, the installation is successful.

MVN VS MVND performance test

The highlight of this article is to test the performance gap between MVN and MVND using one of my local projects.

My computer configuration is as follows:

1. MVN performance test

A traditional Maven execution would look like this:

Package one of my local projects and skip unit testing.

MVN performance test result: 1.312 seconds.

2. MVND performance test

MVND performance test result 0.154 seconds.

conclusion

This article introduces MVND, a tool that has Maven built in but performs much faster than Maven. It’s easy to get started, just changing the beginning of maven commands from “MVN” to “MVND” for users.

MVND builds one or more Maven daemons, uses a new VM engine, and adds caching and JIT optimization, which greatly improves the build speed of The Maven project and gives us a hope that we can compete with Gradle. I will keep watching this project. I hope it develops better and better.

Reference: github.com/apache/mave…

Judge right and wrong from yourself, praise to listen to others, gain and loss in the number.

Public account: Java Chinese Community