How To Install Apache Maven on Ubuntu Server

Advertisement

Apache Maven is a Build Automation Tool. Alternative technologies is Gradle and sbt as build tools. We published guide on how to install Gradle. Maven needs XML file to build. Gradle and sbt do not rely on XML, but basic concept is like Maven introduced. Maven Needed For Many Big Data Software. Here Are the Steps on How To Install Apache Maven on Ubuntu Server. Maven takes care of two aspects of building software – describing how the software is built and its dependencies. Apache Ant is older and only exceptions need to be written down. Apache Ivy is next step of Apache Ant, Apache Maven, Gradle with dedicated dependency manager and support for Maven repositories. Still we need Maven instead of Ivy for many reasons. Maven projects are configured using a Project Object Model (POM), stored in a pom.xml file like this :

Vim

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

<project>

<!--model version is always4.0.0forMaven2.xPOMs-->

<modelVersion>4.0.0</modelVersion>

<!--project coordinates,i.e.agroup of values which

uniquely identify this project-->

<groupId>com.mycompany.app</groupId>

<artifactId>my-app</artifactId>

<version>1.0</version>

<!--library dependencies-->

<dependencies>

<dependency>

<!--coordinates of the required library-->

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>3.8.1</version>

<!--this dependency is only used forrunning and compiling tests-->

<scope>test</scope>

</dependency>

</dependencies>

</project>

Advertisement

---

Steps To Install Apache Maven on Ubuntu Server

Update, Upgrade and install the software-properties-common package :

Vim

1

2

3

apt update-y

apt upgrade-y

apt install software-properties-common apt-transport-https-y

Add the ‘webupd8team’ PPA repository to the server :

Vim

1

2

sudo add-apt-repository ppa:webupd8team/java-y

apt upgrade

Install the Java 8 installer from the PPA repository :

Vim

1

apt install oracle-java8-installer-y

Accept the Oracle License by choosing the ‘YES’ button. Check the java version :

Vim

1

java-version

Download latest Apache Maven binary code. We are using /opt/apache-maven directory as the Maven home directory and Maben 3.5.3 as example.