preface:
When packing the project in the morning, I found that the packing speed was very slow and took a long time. I asked for help in a group. How to speed up the packing efficiency of maven, a group friend sent a link, as shown in the figure.
Google later found that this tool was actually produced by the apache maven team and a sub project of maven, so using Maven can seamlessly switch to mvnd.
Introduction to Mvnd
Maven mvnd is a faster build tool developed by the Apache Maven team after learning from Gradle and Takari. Maven is embedded in mvnd, which is why we can seamlessly switch Maven to mvnd (there is no need to install Maven separately).
In terms of design, one or more daemons will be generated in mvnd to serve the construction request, so as to achieve the effect of parallel construction. In addition, in the choice of VM, mvnd uses GraalVM to replace the traditional JVM. Compared with it, GraalVM starts faster and occupies less memory.
According to the document description, mvnd has the following advantages over traditional Maven:
- The JVM running the build does not need to be restarted for each build.
- The class loader of Maven plug-in class is cached in multiple builds, and the plug-in jars will only be read and parsed once.
- The native code generated by JIT in JVM will be preserved. JIT compilation takes less time than Maven. During repeated builds, JIT optimized code is immediately available. This applies not only to code from the Maven plug-in and Maven kernel, but also to all code from the JDK itself.
By default, mvnd uses multiple CPU cores to build modules in parallel. The number of cores used is determined by the formula math max(Runtime.getRuntime(). Available processors () - 1, 1). If your source tree does not support parallel builds, pass - T1 on the command line to serialize your builds.
- At the same time, the official has given the dynamic diagram of the operation on the 24 nuclear machine:
Github address: Portal
install
- Download address: Portal
The latest version is 0.7.1;
- After downloading, unzip and install
- Modify profile
Find mvnd. Exe in the conf folder of the extracted root directory Properties configuration file, configure maven The value of settings property is maven configuration file settings XML file path. Note: this setting The storage location of XML files is unlimited.
- Configure environment variables
Copy the bin directory path, open the system settings, the latest version of win10 in the system / about / advanced system settings / environment variables Configure system environment variables under
Confirm and return.
test
- Whether the environment variables are configured successfully
D:\>mvnd -version mvnd native client 0.7.1-windows-amd64 (97c587c11383a67b5bd0ff8388bd94c694b91c1e) Terminal: org.jline.terminal.impl.jansi.win.JansiWinSysTerminal [WARN] [WARN] Some problems were encountered while building the effective settings [WARN] Unrecognised tag: 'url' (position: START_TAG seen ...<!-- \u914d\u7f6e JDK \u7248\u672c -->\r\n <url>... @307:14) @ D:\APP\apache-maven-3.8.2\conf\settings.xml, line 307, column 14 [WARN] Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739) Maven home: D:\APP\mvnd-0.7.1-windows-amd64\mvn Java version: 1.8.0_281, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_281\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
- view help
$ mvnd --help
- mvn packaging test
# mvn packaging command mvn clean package -Dmaven.test.skip=true # results of enforcement [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.405 s [INFO] Finished at: 2021-12-29T11:18:05+08:00 [INFO] ------------------------------------------------------------------------
- mvnd packaging test
# Execute package command mvnd clean package -Dmaven.test.skip=true # results of enforcement [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.278 s (Wall Clock) [INFO] Finished at: 2021-12-29T11:19:40+08:00 [INFO] ------------------------------------------------------------------------
It's a big gap. I'm surprised 😁😁😁. If you have a better plan, you can discuss it in the message area below to learn and make progress together.