Maven is often compared to Gradle. One of the biggest disadvantages is that Maven builds slowly. Gradle builds 2 to 10 times faster than Maven. The Apache Maven team took inspiration from Gradle and Takari(The Maven lifecycle optimizer) to enhance Maven. The Maven project is called Maven-MVND.
A simple introduction
Instead of refactoring Maven, MVND has Maven built in. It is actually one or more Maven daemons that perform the actual build services. A single daemon instance can provide Maven build services for multiple consecutive requests from MVND clients. MVND can generate multiple daemons in parallel when there are no free daemons to support build requests.
Use GraalVM instead of JVM
MVND is fast because it uses GraalVM instead of traditional JVMS, so it starts faster, takes up less memory, and does not need to start a new JVM for each build when it executes a build. Maven plug-ins are no longer loaded multiple times at build time, but cached in multiple builds. Maven plug-ins with the SNAPSHOT version will not be cached.
Support the JIT
GraalVM’s Just-in-time (JIT) compilation feature is also applied to Maven build jobs. JIT can greatly reduce compilation time and improve build efficiency by making JIT optimized code immediately available during repeated builds.
Parallel build
Parallel builds for Maven 3 are currently an experimental feature that requires plugins to be thread-safe. MVND supports parallel builds with multiple CPU cores by default. Of course, if your source code does not support parallel builds, you can switch to serial builds by adding the -t1 parameter.
Simply try
Let’s briefly try MVND.
The installation
At present, MVND already supports Linux, MacOS and Windows platforms. You can install them through SDKMAN, Homebrew, and Chocolatey package managers. You can also go directly to the MVND distribution repository to download the corresponding binary and install it. For Windows as an example, I chose Chocolatey to install:
choco install mvndaemon
Copy the code
It may take a little longer.
configuration
The configuration is simple, with only two points to note
- Make sure to install if you are not using package managermvndthe
bin
Directory associated withPATH
. - If not configured or do not want to configure
JAVA_HOME
For environment variables, please refer to~/.m2/mvnd.properties
Set in thejava.home
To specify theJavaContents, for example:java.home=C:\\AdoptOpenJDK\\jdk-8
. If environment variables have been configured, ignore this item.
For other configuration items, see MVND Configuration.
use
After the installation and configuration is complete, run the MVND –version command. If the following information is displayed, the installation is successful.
MVND - version MVND native client 0.7.1 - Windows - amd64 (97 c587c11383a67b5bd0ff8388bd94c694b91c1e) Terminal: Org. Jline. Terminal. Impl. Jansi. Win. JansiWinSysTerminal Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739) Maven Home: C: Program Files\mvndaemon\ mvnd-0.7.1-Windows-amd64 \ MVN Java Version: 1.8.0_282, vendor: Maven Home: C: Program Files\mvndaemon\ mvnd-0.7.1-Windows-amd64 \ MVN Java Version: 1.8.0_282, vendor: AdoptOpenJDK, Runtime: C:\Program Files\AdoptOpenJDK\ JDK-8.0.282.8 -hotspot\ JRE Default locale: zh_CN, platform encoding: GBK OS name:"windows 10", version: "10.0", arch: "amd64", family: "windows"
Copy the code
To reduce learning costs, MVND is changed to MVND in a similar way to traditional Maven. You can also view the full list of command options via MVND –help.
To be honest, parallel construction is fast, it’s like a rocket. In addition, the console output has been optimized.
Thanks to GraalVM, this tool is likely to extend Maven’s life and prevent Gradle from gaining an early advantage. For us, this project can wait and see what further action Apache Maven has officially taken.
Follow our public id: Felordcn for more information
Personal blog: https://felord.cn