maven打包慢,使用maven-mvnd 打包可以快一半

maven打包打包系统包时,因子工程模块很多,打包越来越慢。。

今天试试mavend,比maven打包更快的包。

打包后,发现时间比原来的,缩短了

 

打开 https://github.com/apache/maven-mvnd/releases 找到想要的包linux

下载

# mkdir -p /app/mvnd

# cd /app/mvnd

# wget https://github.com/apache/maven-mvnd/releases/download/1.0-m6/maven-mvnd-1.0-m6-m39-linux-amd64.zip

 

解压

 

# cd /app/mvnd
# unzip maven-mvnd-1.0-m6-m39-linux-amd64.zip
# vi maven-mvnd-1.0-m6-m39-linux-amd64/conf/mvnd.properties
找到 maven.settings,放开注解,将settings.xml配置上
maven.settings=/app/system/settings.xml

 

 

环境变量配置etc

增加mavend的配置增加到配置中

 

# vi /etc/profile
在文件末尾增加如下配置
# vi harbor.yml
export MAVEN_HOME_D=/app/mvnd/maven-mvnd-1.0-m6-m39-linux-amd64
export PATH=${MAVEN_HOME_D}/bin:${PATH}

 

 

测试

查看版本


[root@host-252 system]# mvnd -v
Apache Maven Daemon (mvnd) 1.0-m6 linux-amd64 native client (47d4c6b9c399079d91312bb8ae35d1d76e7fd97a)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.linux.LinuxNativePty
Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Maven home: /app/mvnd/maven-mvnd-1.0-m6-m39-linux-amd64/mvn
Java version: 1.8.0_271, vendor: Oracle Corporation, runtime: /usr/lib/java/jdk1.8.0_271/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"

这是maven
[root@host-252 system]# mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/lib/mvn/apache-maven-3.6.3
Java version: 1.8.0_271, vendor: Oracle Corporation, runtime: /usr/lib/java/jdk1.8.0_271/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-1160.el7.x86_64", arch: "amd64", family: "unix"
[root@host-252 system]# 

 

mvn打包命令修改

之前打包命令,直接修改mvn 为mvnd
mvn clean install -DskipTests=true -s $CURRENT_PATH/settings.xml
修改为
mvnd clean install -DskipTests=true -s $CURRENT_PATH/settings.xml

发现编辑打包的速度,快乐1/2左右。

 

打包命令修改

#!/bin/bash
CODE_PATH="code"
PROJECT_NAME="mygod-biz"
GIT_ADDR="$GIT_URL/$PROJECT_NAME.git"
JAVA_HOME=$JAVA_17HOME

OLD_PATH=`pwd`
LINK_PATH=`readlink $0`
[ "x" = "x$LINK_PATH" ] && CURRENT_PATH=`dirname $0`
[ "x" != "x$LINK_PATH" ] && CURRENT_PATH=`dirname $LINK_PATH`
cd $CURRENT_PATH
CURRENT_PATH=`pwd`

#判断文件夹是否存在 -d
if [[ ! -d $CURRENT_PATH/$CODE_PATH/$PROJECT_NAME ]]; then
 mkdir -p $CURRENT_PATH/$CODE_PATH
 cd $CURRENT_PATH/$CODE_PATH
 git clone $GIT_ADDR
 cd $CURRENT_PATH/$CODE_PATH/$PROJECT_NAME
 git checkout $PROJECT_BRANCH
fi
cd $CURRENT_PATH/$CODE_PATH/$PROJECT_NAME
git checkout $PROJECT_BRANCH
git pull
mvnd clean install -DskipTests=true -s $CURRENT_PATH/settings.xml

 

执行命令

 命令修改前后打包时间对比

修改前

mvn clean install -DskipTests=true -s $CURRENT_PATH/settings.xml

 

修改后

mvnd clean install -DskipTests=true -s $CURRENT_PATH/settings.xml

 

 

结论:确实快了不少。

 

 

 

posted on 2023-07-08 10:50  陈惟鲜的博客  阅读(878)  评论(0编辑  收藏  举报

导航