Apache Maven is a software project management and comprehension tool. IT is commonly used to manage a project’s build, reporting and documentation from a central repository such as Git, CVS, etc.
Installation of Maven is pretty simple. The procedure is as follows:
- Install latest version of Java SDK (yum install java-1.8.0-openjdk-devel -y). The command “java -version” will display the current version of Java installed.
- Navigate to the “/opt” folder.
- Download the compressed copy of Maven. It can be downloaded by using the command : “wget http://www-eu.apache.org/dist/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz“. If this copy is not available, get the latest available.
- This will download the file “apache-maven-3.5.3-bin.tar.gz” in the /opt folder.
- Decompress the downloaded file using the command “tar -xvf apache-maven-3.5.3-bin.tar.gz“, which will create a folder named “apache-maven-3.3.9” and contents in it.
- Rename the folder “apache-maven-3.5.3” to “maven” using the command “mv apache-maven-3.5.3/ /opt/maven“.
- Run the command “ln -s /opt/maven/bin/mvn /usr/bin/mvn” which will enable users to access the mvn binary without typing the complete path.
- Create the following file using a text editor using the command “vi /etc/profile.d/maven.sh“, that will setup the required environment variables when a user logs-in to the host. The content of this file should be as follows:
export PATH MAVEN_HOME
- Make the file executable by running the command “chmod +x /etc/profile.d/maven.sh“.
- Set the environment variables permanently by running the command “source /etc/profile.d/maven.sh“
To test the installation by checking the version of Maven installed by running the command “mvn –version” from any folder in the host.