Skip to content

Instantly share code, notes, and snippets.

@colinbowern
Last active September 26, 2017 20:01
Show Gist options
  • Save colinbowern/c4b4a3165ea56a7a7a3402e03c8d9a7a to your computer and use it in GitHub Desktop.
Save colinbowern/c4b4a3165ea56a7a7a3402e03c8d9a7a to your computer and use it in GitHub Desktop.
Install Maven from command-line on Ubuntu
#!/bin/sh
wget --no-cookies --timestamping http://www-us.apache.org/dist/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz --directory /tmp
# Decompress package into /opt
if [ ! -d "/opt/maven" ]; then
mkdir /opt/maven
fi
tar zxvf /tmp/apache-maven-3.5.0-bin.tar.gz --directory /opt/maven
# Update path references in system profile and make it ddefault
echo 'export M2_HOME=/opt/maven/apache-maven-3.5.0' > /etc/profile.d/maven.sh
echo 'export PATH=$PATH:$M2_HOME/bin' >> /etc/profile.d/maven.sh
chmod +x /etc/profile.d/maven.sh
# Reload system profile
. /etc/profile
mvn -version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment