mvnd 从入门到大型系统实战,居然比maven快这么多

简介

mvnd 是参考 gradle和 takari新出的一款基于 maven的但比它更快的构建工具;

更多介绍, 查看官网: github.com/apache/mave…

安装

下载mvnd

进入 github.com/apache/mave…

我下载了 mvnd-0.7.1-windows-amd64.zip

下载完毕后,找一个路径,解压即可

配置

配置 JDK

因为 mvnd 依赖于 jdk 启动,所以我们需要首先配置jdk

我们先来看一下错误日志

> mvnd clean

Exception in thread "main" java.lang.IllegalStateException: Could not get value for Environment.JAVA_HOME from any of the following sources: value: java.home, environment variable JAVA_HOME, property java.home in E:\workspace\traffic_stat_backend.mvn\mvnd.properties, property java.home in C:\Users\Administrator.m2\mvnd.properties, property java.home in D:\Java\mvnd-0.7.1-windows-amd64\conf\mvnd.properties, system property java.home
        at org.mvndaemon.mvnd.client.DaemonParameters$EnvValue.couldNotgetValue(DaemonParameters.java:596)
        at org.mvndaemon.mvnd.client.DaemonParameters$EnvValue.lambda$orFail$8(DaemonParameters.java:573)
        at org.mvndaemon.mvnd.client.DaemonParameters$EnvValue.get(DaemonParameters.java:606)
        at org.mvndaemon.mvnd.client.DaemonParameters$EnvValue.asPath(DaemonParameters.java:629)
        at org.mvndaemon.mvnd.client.DaemonParameters.javaHome(DaemonParameters.java:140)
        at org.mvndaemon.mvnd.client.DaemonConnector.connect(DaemonConnector.java:99)
        at org.mvndaemon.mvnd.client.DefaultClient.execute(DefaultClient.java:272)
        at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:118)
复制代码

异常告诉我们在配置文件java.home和环境变量JAVA_HOME找不到

那么我们就基于此错误进行一些配置。方式很简单,我这里列出了两种方案,我们只需要选择最合适自己的一种方式即可

第一种就是基于环境变量的方式

第二种是基于 mvnd 的配置文件方式

1、环境变量法

注意: mvnd 需要环境变量 JAVA_HOME否则会报错

具体配置方式,我这里就不列出了。

2、配置文件法

在某些情况,我们需要在环境变量中配置jdk11或者更高的,而mvnd需要jdk1.8的怎么办?

遇到这种情况,我们就可以采用第二种方式,具体操作请看下面说明

我们还可以选择在 mvnd-0.7.1-windows-amd64\conf 目录下手动指定 jdk 的路径

首先我们打开 mvnd.properties 文件

找到 java.home所在行,大概在149行的位置,我们首先把注释()取消掉,然后在路径处填入jdk路径即可

mvnd 从入门到大型系统实战,居然比maven快这么多

修改完毕后,我们再次执行命令,我们可以看到成功执行了

mvnd clean
复制代码

mvnd 从入门到大型系统实战,居然比maven快这么多

修改完保存后我们来测试

设置mvnd环境变量

设置mvnd环境变量后,可以让我们在任何目录下使用mvnd命令,具体配置就不列出了。

设置mvnd内置的maven配置

目录 \mvn下就是mvnd内置的maven, 和平时使用的maven没区别

所以我们配置maven时, 直接修改 \mvn\conf下的 settings.xml即可

具体配置, 和maven一样

指定 settings.xml

注意:mvnd 中,并不会直接使用 mvnd\mvn\conf下的 settings.xml配置,我们需要手动进行执行配置文件路径

首先我们打开 mvnd\conf\mvnd.properties文件

然后在最下方,找到 maven.settings 配置项

我们将此配置项注释取消,然后把我们 mvnd\mvn\conf\settings.xml 的绝对路径填入即可

具体请看图片

mvnd 从入门到大型系统实战,居然比maven快这么多

大型大屏系统实战

本次实战项目拥有14个工程,下面我们来看看使用 mvn 和 mvnd 执行耗时吧

声明:本次测试仅代表个人实际开发过程中使用记录,并不专业,但也有一定的参考性能

测试前置条件

每次测试所有工程都处于安装状态(即执行了mvn clean install)命令后

settings.xml 为同配置方式

系统性能

此次测试机器是公司真实开发机器,以及负载情况也是真实的

mvnd 从入门到大型系统实战,居然比maven快这么多

mvnd 从入门到大型系统实战,居然比maven快这么多

测试目标

分别使用以下命令执行两次

  1. mvn clean install & mvnd clean install
  2. mvn clean package & mvnd clean package

测试结果

install

> mvn clean install
- 1. 第一次
[INFO] xxx ............................................ SUCCESS [  0.199 s]
[INFO] xxx-admin-core ................................. SUCCESS [  1.794 s]
[INFO] xxx-common ..................................... SUCCESS [  3.103 s]
[INFO] xxx-system ..................................... SUCCESS [  0.489 s]
[INFO] xxx-framework .................................. SUCCESS [  0.758 s]
[INFO] xxx-admin ...................................... SUCCESS [  2.024 s]
[INFO] xxx-admin-backend .............................. SUCCESS [  4.230 s]
[INFO] xxx-eee-itc ............................... SUCCESS [  0.900 s]
[INFO] xxx-eee-hls ............................... SUCCESS [  1.956 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [  5.842 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  5.080 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  5.021 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [  7.080 s]
[INFO] xxx-eee-common ............................ SUCCESS [  5.448 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  5.555 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  49.942 s
[INFO] Finished at: 2022-01-05T10:12:23+08:00
[INFO] ------------------------------------------------------------------------

- 2. 第二次
[INFO] xxx ............................................ SUCCESS [  0.195 s]
[INFO] xxx-admin-core ................................. SUCCESS [  1.857 s]
[INFO] xxx-common ..................................... SUCCESS [  3.161 s]
[INFO] xxx-system ..................................... SUCCESS [  0.519 s]
[INFO] xxx-framework .................................. SUCCESS [  0.738 s]
[INFO] xxx-admin ...................................... SUCCESS [  2.049 s]
[INFO] xxx-admin-backend .............................. SUCCESS [  3.827 s]
[INFO] xxx-eee-itc ............................... SUCCESS [  1.078 s]
[INFO] xxx-eee-hls ............................... SUCCESS [  1.521 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [  6.198 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  5.261 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  6.103 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [  4.787 s]
[INFO] xxx-eee-common ............................ SUCCESS [  5.369 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  5.804 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  48.913 s
[INFO] Finished at: 2022-01-05T10:13:32+08:00
[INFO] ------------------------------------------------------------------------
复制代码
> mvnd clean install

- 1. 第一次
[INFO] xxx ............................................ SUCCESS [  0.005 s]
[INFO] xxx-admin-core ................................. SUCCESS [  0.308 s]
[INFO] xxx-common ..................................... SUCCESS [  1.435 s]
[INFO] xxx-system ..................................... SUCCESS [  0.291 s]
[INFO] xxx-framework .................................. SUCCESS [  0.495 s]
[INFO] xxx-admin ...................................... SUCCESS [  1.391 s]
[INFO] xxx-admin-backend .............................. SUCCESS [ 19.003 s]
[INFO] xxx-eee-itc ............................... SUCCESS [ 19.376 s]
[INFO] xxx-eee-hls ............................... SUCCESS [ 18.461 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [ 12.390 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  0.858 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  0.834 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [ 17.140 s]
[INFO] xxx-eee-common ............................ SUCCESS [ 12.672 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  0.835 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  41.776 s (Wall Clock)
[INFO] Finished at: 2022-01-05T10:17:15+08:00
[INFO] ------------------------------------------------------------------------
    
- 2. 第二次
[INFO] xxx ............................................ SUCCESS [  0.004 s]
[INFO] xxx-admin-core ................................. SUCCESS [  0.310 s]
[INFO] xxx-common ..................................... SUCCESS [  1.573 s]
[INFO] xxx-system ..................................... SUCCESS [  0.298 s]
[INFO] xxx-framework .................................. SUCCESS [  0.418 s]
[INFO] xxx-admin ...................................... SUCCESS [  1.407 s]
[INFO] xxx-admin-backend .............................. SUCCESS [ 19.343 s]
[INFO] xxx-eee-itc ............................... SUCCESS [ 17.165 s]
[INFO] xxx-eee-hls ............................... SUCCESS [ 16.195 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [ 11.439 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  1.213 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  1.127 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [ 17.177 s]
[INFO] xxx-eee-common ............................ SUCCESS [ 12.903 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  1.179 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  40.317 s (Wall Clock)
[INFO] Finished at: 2022-01-05T10:18:38+08:00
[INFO] ------------------------------------------------------------------------
复制代码

package

> mvn clean package
    
- 1. 第一次
[INFO] xxx ............................................ SUCCESS [  0.115 s]
[INFO] xxx-admin-core ................................. SUCCESS [  1.970 s]
[INFO] xxx-common ..................................... SUCCESS [  3.123 s]
[INFO] xxx-system ..................................... SUCCESS [  0.504 s]
[INFO] xxx-framework .................................. SUCCESS [  0.769 s]
[INFO] xxx-admin ...................................... SUCCESS [  2.711 s]
[INFO] xxx-admin-backend .............................. SUCCESS [  3.065 s]
[INFO] xxx-eee-itc ............................... SUCCESS [  0.776 s]
[INFO] xxx-eee-hls ............................... SUCCESS [  0.811 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [  1.110 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  1.733 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  0.844 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [  1.169 s]
[INFO] xxx-eee-common ............................ SUCCESS [  2.295 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  3.024 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  24.509 s
[INFO] Finished at: 2022-01-05T10:21:31+08:00
[INFO] ------------------------------------------------------------------------
    
- 2. 第二次
[INFO] xxx ............................................ SUCCESS [  0.111 s]
[INFO] xxx-admin-core ................................. SUCCESS [  1.981 s]
[INFO] xxx-common ..................................... SUCCESS [  3.235 s]
[INFO] xxx-system ..................................... SUCCESS [  0.507 s]
[INFO] xxx-framework .................................. SUCCESS [  0.790 s]
[INFO] xxx-admin ...................................... SUCCESS [  1.996 s]
[INFO] xxx-admin-backend .............................. SUCCESS [  2.947 s]
[INFO] xxx-eee-itc ............................... SUCCESS [  0.747 s]
[INFO] xxx-eee-hls ............................... SUCCESS [  0.910 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [  0.703 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  1.179 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  1.527 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [  1.405 s]
[INFO] xxx-eee-common ............................ SUCCESS [  1.024 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  2.238 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21.709 s
[INFO] Finished at: 2022-01-05T10:22:14+08:00
[INFO] ------------------------------------------------------------------------
复制代码
> mvnd clean package
    
- 1. 第一次
[INFO] xxx ............................................ SUCCESS [  0.023 s]
[INFO] xxx-admin-core ................................. SUCCESS [  0.393 s]
[INFO] xxx-common ..................................... SUCCESS [  1.507 s]
[INFO] xxx-system ..................................... SUCCESS [  0.294 s]
[INFO] xxx-framework .................................. SUCCESS [  0.417 s]
[INFO] xxx-admin ...................................... SUCCESS [  1.354 s]
[INFO] xxx-admin-backend .............................. SUCCESS [  6.264 s]
[INFO] xxx-eee-itc ............................... SUCCESS [  1.562 s]
[INFO] xxx-eee-hls ............................... SUCCESS [  2.281 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [  2.067 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  1.049 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  0.907 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [  1.516 s]
[INFO] xxx-eee-common ............................ SUCCESS [  2.832 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  0.948 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.251 s (Wall Clock)
[INFO] Finished at: 2022-01-05T10:23:18+08:00
[INFO] ------------------------------------------------------------------------
    
- 2. 第二次
[INFO] xxx ............................................ SUCCESS [  0.001 s]
[INFO] xxx-admin-core ................................. SUCCESS [  0.376 s]
[INFO] xxx-common ..................................... SUCCESS [  1.523 s]
[INFO] xxx-system ..................................... SUCCESS [  0.289 s]
[INFO] xxx-framework .................................. SUCCESS [  0.415 s]
[INFO] xxx-admin ...................................... SUCCESS [  1.474 s]
[INFO] xxx-admin-backend .............................. SUCCESS [  8.787 s]
[INFO] xxx-eee-itc ............................... SUCCESS [  0.729 s]
[INFO] xxx-eee-hls ............................... SUCCESS [  0.678 s]
[INFO] xxx-eee-haiwan ............................ SUCCESS [  5.181 s]
[INFO] xxx-eee-unisee ............................ SUCCESS [  0.751 s]
[INFO] xxx-eee-temperature ....................... SUCCESS [  0.699 s]
[INFO] xxx-eee-schneider ......................... SUCCESS [  0.714 s]
[INFO] xxx-eee-common ............................ SUCCESS [  5.172 s]
[INFO] xxx-eee-statistics ........................ SUCCESS [  0.709 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.856 s (Wall Clock)
[INFO] Finished at: 2022-01-05T10:23:50+08:00
[INFO] ------------------------------------------------------------------------
复制代码

结果

mvnd 比 mvn 快

上一篇:Linux中sed基础


下一篇:python练习-生成100个2位随机正整数