Last active
June 1, 2022 19:59
-
-
Save jspw/7c4bea1a8443c2d8aec7b0de545425c8 to your computer and use it in GitHub Desktop.
Install and configure maven 3.8.5 in linux machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# whoami -> MH Shifat | https://github.com/jspw | |
# date -> Tue 31 May 2022 10:29:08 PM +06 | |
LATEST_MAVEN_URL="https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz" | |
printf "Downloading "$MAVEN_FILE_NAME "...\n\n" | |
sudo wget $LATEST_MAVEN_URL | |
MAVEN_FILE_NAME=$(basename $LATEST_MAVEN_URL) | |
printf "Extracting $MAVEN_FILE_NAME ...\n\n" | |
sudo tar -xvf $MAVEN_FILE_NAME | |
MAVEN_DIR_NAME=$(basename $MAVEN_FILE_NAME -bin.tar.gz) | |
printf "Moving $MAVEN_DIR_NAME to /opt/maven\n\n" | |
sudo mv $MAVEN_DIR_NAME /opt/maven | |
JAVA_HOME=$(dirname $( readlink -f $(which java) )) | |
JAVA_HOME=$(realpath "$JAVA_HOME"/../) | |
MAVEN_SH=" | |
export JAVA_HOME=$JAVA_HOME\n | |
export M2_HOME=/opt/maven\n | |
export MAVEN_HOME=/opt/maven\n | |
export PATH=\${M2_HOME}/bin:\${PATH}\n | |
" | |
printf "Creating a file /etc/profile.d/maven.sh\n\n" | |
sudo touch /etc/profile.d/maven.txt | |
sudo echo -e "$MAVEN_SH" > /etc/profile.d/maven.txt | |
sudo mv /etc/profile.d/maven.txt /etc/profile.d/maven.sh | |
printf "Executing permission on /etc/profile.d/maven.sh\n\n" | |
sudo chmod +x /etc/profile.d/maven.sh | |
printf "Reloading profile\n\n" | |
source /etc/profile.d/maven.sh | |
mvn -version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo rm /etc/profile.d/maven.s | |
sudo rm -rf /opt/maven |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment