MAVEN

Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation. It simplifies the build process like ANT. But it is too much advanced than ANT.

What it does?

Maven simplifies the above mentioned problems. It does mainly following tasks:-

i)It makes a project easy to build.

ii)It provides uniform build process (maven project can be shared by all the maven projects).

iii)It provides project information (log document, cross referenced sources, mailing list, dependency list, unit test reports etc.).

iv)It is easy to migrate for new features of Maven.

 (1).Apache Maven helps to manage:-

 Builds

 Documentation

 SCMs

 Releases

 Distribution

(2).What is Build Tool?

A build tool takes care of everything for building a process.It does the following:-

i)Generates source code (if auto-generated code is used)

ii)Generates documentation from source code

iii)Compiles source code

iv)Packages compiled code into JAR of ZIP file

v)Installs the packaged code in local repository, server repository, or central repository

(3).Difference between Ant and Maven:-

 Ant and Maven both are build tools provided by Apache. The main purpose of these technologies is to ease the build process of a project. There are many differences between ant and maven that are given below:-

Ant

i). Ant doesn’t has formal conventions, so we need to provide information of the project structure in build.xml file.

ii). Ant is procedural, you need to provide information about what to do and when to do through code. You need to provide order.

iii).There is no life cycle in Ant.

iv).It is a tool box.

v).It is mainly a build tool.

vi).It is less preferred than Maven.

vii).The ant scripts are not reusable.

Maven

Maven has a convention to place source code, compiled code etc. So we don’t need to provide information about the project structure in pom.xml file. Maven is declarative, everything you define in the pom.xml file.

i).There is life cycle in Maven.

ii).It is mainly a project management tool.

iii).It is a framework.

iv).The maven plugins are reusable.

v).It is more preferred than Ant.

(4).Maven Repository:-

A maven repository is a directory of packaged JAR file with pom.xml file. Maven searches for dependencies in the repositories. There are 3 types of maven repositories:-

 Local Repository

Central Repository

Remote Repository

Maven searches for the dependencies in the following order:

Local repository then Central repository then Remote repository.

Maven Local Repository

Maven local repository is located in your local system. It is created by the maven when you run any maven command.

 By default, maven local repository is %USER_HOME%/.m2 directory. For example: C:\Users\.m2.

 Maven Central Repository

Maven central repository is located on the web. It has been created by the apache maven community itself.

The path of central repository is: http://repo1.maven.org/maven2/.

The central repository contains a lot of common libraries that can be viewed by this url http://search.maven.org/#browse.

Maven Remote Repository

Maven remote repository is located on the web. Most of libraries can be missing from the central repository such as JBoss library etc, so we need to define remote repository in pom.xml file.

(5).Maven pom.xml file:-

 POM is an acronym for Project Object Model. The pom.xml file contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc.Maven reads the pom.xml file, then executes the goal.

project:- It is the root element of pom.xml file.

modelVersion :-It is the sub element of project. It specifies the modelVersion.It should be set to 4.0.0.

groupId :-It is the sub element of project. It specifies the id for the project group.artifactId :-It is the sub element of project. It specifies the id for the artifact (project). An artifact is something that is either produced or used by a project. Examples of artifacts produced by Maven for a project include: JARs, source and binary distributions, and WARs.

version :-It is the sub element of project. It specifies the version of the artifact under given group.

(6).System Requirements:-

 Maven is Java based tool, so the very first requirement is to have JDK installed on your machine.

JDK

1.5 or above.

(7).Default life cycle Phases:-

◾validate – validate the project is correct and all necessary information is available

◾compile – compile the source code of the project

◾test – test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed

◾package – take the compiled code and package it in its distributable format, such as a JAR.

◾integration-test – process and deploy the package if necessary into an environment where integration tests can be run

◾verify – run any checks to verify the package is valid and meets quality criteria

◾install – install the package into the local repository, for use as a dependency in other projects locally

◾Deploy – done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.



Categories: maven

Tags: , , , ,

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: