[英]Install maven to any linux system using bash script
有什么可能的方法可以使用 bash 脚本在任何 linux 机器上安装 maven 吗?
Yes you can install mvn with bash script, example below是的,您可以使用 bash 脚本安装 mvn,示例如下
mvn_version=${mvn_version:-3.8.5}
url="http://www.mirrorservice.org/sites/ftp.apache.org/maven/maven-3/${mvn_version}/binaries/apache-maven-${mvn_version}-bin.tar.gz"
install_dir="/opt/maven"
mkdir ${install_dir}
curl -fsSL ${url} | tar zx --strip-components=1 -C ${install_dir}
cat << EOF > /etc/profile.d/maven.sh
#!/bin/sh
export MAVEN_HOME=${install_dir}
export M2_HOME=${install_dir}
export M2=${install_dir}/bin
export PATH=${install_dir}/bin:$PATH
EOF
source /etc/profile.d/maven.sh
echo maven installed to ${install_dir}
mvn --version
you need to add source /etc/profile.d/maven.sh to ~/.bash_profile or basrch您需要将source /etc/profile.d/maven.sh添加到 ~/.bash_profile 或 basrch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.