linux下maven-3.5.4安装

#!/bin/bash
# linux maven安装

package_dir=/opt/tools
install_dir=/opt

#########################

# 下载maven的tar包
[ -d ${package_dir} ] || mkdir -pv ${package_dir}
cd ${package_dir} && wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz

# 解压
tar xf ${package_dir}/apache-maven-3.5.4-bin.tar.gz -C ${install_dir}/
[ -L ${install_dir}/maven ] &&  rm -f ${install_dir}/maven
ln -s ${install_dir}/apache-maven-3.5.4 ${install_dir}/maven

# 添加环境变量
echo -e "export MAVEN_HOME=${install_dir}/maven\nPATH=\$PATH:\$MAVEN_HOME/bin" > /etc/profile.d/maven.sh
cat /etc/profile.d/maven.sh
#export MAVEN_HOME=/opt/maven
#PATH=$PATH:$MAVEN_HOME/bin

source /etc/profile.d/maven.sh

# 测试
echo $MAVEN_HOME
mvn -version
相关文章
相关标签/搜索