Snippets

Dermot Butterfield Install the latest version of Maven on Linux

Created by Dermot Butterfield last modified
#!/bin/bash

# identify the latest version of maven
latest=$(curl http://www-us.apache.org/dist/maven/maven-3/ | tac | sed -ne 's/[^0-9]*\(\([0-9]\.\)\{0,3\}[0-9]\).*/\1/p' | head -1)

# download it
wget http://www-us.apache.org/dist/maven/maven-3/$latest/binaries/apache-maven-$latest-bin.tar.gz

# unpack it
sudo tar -zxf apache-maven-$latest-bin.tar.gz -C /usr/local/

# create a symlink to it
sudo ln -s /usr/local/apache-maven-$latest/bin/mvn /usr/bin/mvn

# confirm successful installation
echo "You have installed `mvn -v`"

Comments (1)