Spread the love

In this post you will learn the complete tutorial of Apache Maven build tool

What is Maven ?

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.

It simplifies the build process like ANT. But it is too much advanced than ANT.

Why do we need Maven

Need to add multiple dependencies or jars to projects manually

Need to create correct project structure Building and deploying the projects

In short what Maven can do?

  • Maven makes project build easy by gathering all jars
  • It gives a uniform environment for build process • Mavenprovidescompleteprojectinformation
  • Maven can be easily upgraded

What maven can do?

  • Builds
  • Document
  • Reporting
  • Dependencies
  • SCMs
  • Releases
  • Distribution

History of Maven

  • Maven began its life in the Jakarta Alexandria project in 2001.
  • The Alexandria project is now defunct
  • There was no way to build easily using Ant Scripts in those days
  • A model for a project so that you could look everything that is related to the project
  • A standard directory structure so you didn’t have to go fishing around for libraries, sources and documentation

What is a Build Tool

A tool which helps in build process

Build tools basically does the following

  • It Generates source code automatically
  • Creates the documentations from the source code
  • It will also compile the source code (converting to byte code) packages the compiled code into jars
  • Automatically installs code in local or remote repository

Ant vs Maven

Ant

Maven

Doesn’t follow any convention

Follows the convention

It is a procedural build tool

It is a declarative build tool

It is a tool box

It is a Framework

Used as a Build Tool

Used as a Project Management Tool

No Life Cycle

Has Life Cycle

Scripts are not re usable

Maven Plugins are re usable

System Requirements

  • Need to have JDK 1.7 or latest versions i.e java -version Java Installation
  • Download from  http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • Set JAVA_HOME variable
  • In Windows —> set JAVA_HOME= C:\Program Files\Java\jdk1.8.0_65
  • In MAC —> export JAVA_HOME=/Library/Java/Home
  • In Linux —> export JAVA_HOME=/usr/local/java-current

 

Maven Installation on Windows

STEPS

FOR WINDOWS OS

MAVEN DOWNLOAD

https://maven.apache.org/download.cgi

Download zip file and extract files

SET MAVEN_HOME, MAVEN and MAVEN_OPTS

set MAVEN_HOME=D:\apache-maven-3.5.2 set MAVEN=%MAVEN_HOME%\bin
set MAVEN_OPTS=-Xms256m -Xmx512m

ADD MAVEN to PATH variable

Append MAVEN to PATH variable

VALIDATION

mvn -v —> It should output your maven version

Maven Installation on MAC

STEPS

FOR WINDOWS OS

MAVEN DOWNLOAD

https://maven.apache.org/download.cgi

Download tar.gz file and extract files

SET MAVEN_HOME, MAVEN and MAVEN_OPTS

export MAVEN_HOME=<downloaded-path>/apache-maven-3.5.2 set MAVEN=$MAVEN_HOME/bin
set MAVEN_OPTS=-Xms256m -Xmx512m

ADD MAVEN to PATH variable

export $PATH=$PATH:$MAVEN

VALIDATION

mvn -v —> It should output your maven version

Maven Installation on Linux

STEPS

FOR WINDOWS OS

MAVEN DOWNLOAD

https://maven.apache.org/download.cgi

Download tar.gz file and extract files

SET MAVEN_HOME, MAVEN and MAVEN_OPTS

export MAVEN_HOME=<downloaded-path>/apache-maven-3.5.2 set MAVEN=$MAVEN_HOME/bin
set MAVEN_OPTS=-Xms256m -Xmx512m

ADD MAVEN to PATH variable

export $PATH=$PATH:$MAVEN

VALIDATION

mvn -v —> It should output your maven version

 

 

Related Posts

blog

Apache Kafka Commands Cheat sheet

Spread the loveKafka Topics List existing topics bin/kafka-topics.sh –zookeeper localhost:2181 –list Purge a topic bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –config retention.ms=1000 … wait a minute … bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –delete-config retention.ms
Read more…

blog

Practical Guide for Web Development in 2018

Spread the loveWelcome to my practical guide  for web development in 2018 in terms of  technology and career. Before we start I just want to  mention a few things, you don’t need to learn  everything that
Read more…

blog

Azure Tutorial from Scratch | Introduction to Azure Clouds

Spread the loveIn Azure Tutorial from Scratch, I will give you the in and outs of Azure architecture and also more details on the following DataCenter Network (N/w) services Computes/Virtual Machines/Hosts/Machines PrivateNetwork (n/w) Services In this
Read more…