Maven - Manual installation on Linux or MacOS

This article explains the steps to manually install a specific version of maven downloaded directly from maven website or internal artificatory of an organisation.

Create a directory for installation:

mkdir -p $HOME/tools/maven

Download the binary:

From https://maven.apache.org/download.cgi download latest static binary eg: apache-maven-3.9.11-bin.tar.gz to $HOME/tools/maven directory

Extract and rename the binary:

find $HOME/tools/maven -type f -name apache-maven-*.tar.gz | xargs -I {} mv {} $HOME/tools/maven/apache-maven-bin.tar.gz

tar -xvzf $HOME/tools/maven/apache-maven-bin.tar.gz -C $HOME/tools/maven

find $HOME/tools/maven -type d -name apache-maven-* | xargs -I {} mv {} $HOME/tools/maven/apache-maven

Make files executable:

chmod a+rwx -R $HOME/tools/maven/*

Identify the shell type:

echo $SHELL

Configure PATH:

Add the following lines to $HOME/.bash_profile or $HOME/.bashrc or $HOME/.zprofile and restart system for the changes to take effect

export MAVEN_HOME=$HOME/tools/maven/apache-maven

export PATH=$MAVEN_HOME/bin:$PATH

Temporarily use source to load the changes without restart:

source $HOME/.bash_profile

or

source $HOME/.zprofile

Verify maven installation:

mvn -v

Comments

Popular posts from this blog

Export/Backup Ollama Model

JSON with curl and jq

Import self signed in Linux for Chrome / Chromium headless testing