2

Maven is often used and Gradle do comparison, one of the biggest disadvantage is Maven build slowly, Gradle than Maven build speed 2-10 times, and now Maven be faster Up. the Apache Maven team from Gradle and Takari (Maven Lifecycle Optimizer) get inspiration for Maven has been enhanced, derived Maven-mvnd project, fat brother with you today to taste fresh.

basic introduction

mvnd not Maven , but a built-in Maven . It is actually one or more Maven daemons, used to perform the actual build service. A daemon instance can Maven build services for multiple consecutive requests mvnd When there is no free daemon to support the build request, mvnd can generate multiple daemons in parallel.

Use GraalVM instead of JVM

mvnd fast because it uses GraalVM replaces the traditional the JVM , so it starts faster and uses less memory, and does not require construction of a new start in applying for each building the JVM . In addition, the Maven plug-in no longer needs to be loaded multiple times during the build, but is cached in multiple builds. SNAPSHOT version of the Maven plugin will not be cached.

Support JIT

GraalVM 's JIT (Just In Time) real-time compilation feature is also used in the Maven build job. JIT can greatly reduce compilation time. In the repeated build process, JIT optimized code is immediately available, which also greatly improves the build efficiency.

Parallel build

The current Maven 3 are still experimental features, and the plug-ins used must be thread-safe. And mvnd supports the use of multiple CPU cores for parallel construction by default. Of course, if your source code does not support parallel construction, you can also switch to serial construction - T1

Simple try

Next, simply try mvnd .

Install

Currently mvnd already supports Linux , MacOS , Windows platform. You can them through 161c6d6a1a774f SDKMAN , Homebrew , Chocolatey package managers. You can also go directly to mvnd release warehouse download the corresponding binary for installation. Take Windows as an example, I choose Chocolatey install:

choco install mvndaemon

The time may be longer.

Configuration

The configuration is very simple, just need to pay attention to two points

  • If you do not use the package manager to install, please make sure that the bin directory of mvnd PATH .
  • If no or do not want to configure JAVA_HOME environment variable, then please ~/.m2/mvnd.properties setting java.home to specify the Java directory, for example: java.home=C:\\AdoptOpenJDK\\jdk-8 . If you have already configured environment variables, please ignore this one.

For other configuration items, please refer to mvnd configuration .

use

After the installation and configuration are completed, the command line executes mvnd --version following results appear, indicating that the installation is successful.

mvnd --version
mvnd native client 0.7.1-windows-amd64 (97c587c11383a67b5bd0ff8388bd94c694b91c1e)
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: 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"

In order to reduce the cost of learning mvnd is similar to the Maven mvn becomes mvnd . You can also view the complete list of mvnd --help

To be honest, parallel construction is fast, just like a rocket. In addition, the console output has also been optimized.

Thanks to the GraalVM , this tool is likely to extend the life of Maven and avoid prematurely being advantage of by 161c6d6a1a78df Gradle For us, this project can wait and see to see the official further actions of Apache Maven

Follow the public account: Felordcn for more information

personal blog: https://felord.cn


码农小胖哥
3.8k 声望8k 粉丝