Introduction
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. While Maven can be installed via Aptitude, we want to avoid doing that on the Raspberry Pi 2 because it has a dependency on OpenJDK, which we want to avoid. Maven and Oracle JDK 7 (or higher) is a requirement for building Hadoop. This post will outline the steps you need to perform, to install Maven on the Raspberry Pi 2.
Obtaining the Binaries
Maven is kind enough to release the binaries for the project.
Before executing any of the following commands, navigate to a temporary folder.
First, let’s download and extract the binaries:
wget http://apache.mirrors.pair.com/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz tar xf apache-maven-3.3.3-bin.tar.gz rm apache-maven-3.3.3-bin.tar.gz
Installing the Binaries
Next we’ll move the binaries that we had extracted to the /opt/
directory.
sudo mv apache-maven-3.3.3 /opt/ sudo ln -s /opt/apache-maven-3.3.3/ /opt/maven
Now let’s modify the /etc/profile
file to include an update to the PATH
variable so the system can find the Maven executables.
sudo nano /etc/profile
Add the following lines to the top of the file:
MAVEN_HOME=/opt/maven export MAVEN_HOME
Find where PATH
is defined or updated and add the following to the end:
:$MAVEN_HOME/bin
Your PATH will be similar to:
PATH=$PATH:$MAVEN_HOME/bin
Complete Script (minus /etc/profile updates)
#!/bin/bash mkdir -p $HOME/tmp cd $HOME/tmp wget http://apache.mirrors.pair.com/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz tar xf apache-maven-3.3.3-bin.tar.gz rm apache-maven-3.3.3-bin.tar.gz sudo mv $HOME/tmp/apache-maven-3.3.3 /opt/ sudo ln -s /opt/apache-maven-3.3.3/ /opt/maven