Maven Overview – Core Concepts
What is Maven?
Maven is a Build tool used primarily for Java Projects.

How Maven helps us?
Maven helps us with Builds, dependencies, reporting, documentation and Releases

What is POM?
Whenever we create a maven project, we will have POM.xml file. POM stands for Project Object Model. pom.xml contains information about project configurations, dependencies, plugins, goal, dependencies etc.

Maven Build Cycle:
The Project Object Model (POM) has build life cycle. The Build process in maven consists of Build Life cycles, Phases and Goals.
Build life cycle consists of Sequences of phases to be executed and each phase consists of sequence of goals to be executed

Maven Built-in Build Life Cycles:
Maven has 3 Built-in Build Life Cycles,

  • default
  • clean
  • site

Default: default life cycle performs compiling and packaging the product
clean: clean life cycle removes temporary files, .class files etc
site: generated documentation for the project

Phases of Build Life Cycle:
Now we know that, Build life cycle has sequence of phases to be executed. Maven has alot of sequence of phases. Here are some of the important Phases,

  • Validate: Validates the project and checks all the necessary informations are available
  • Compile: Compiles the source code
  • Test: Tests the source code using suitable unit testing framework
  • Package: Compiled code is packaged in a distributable format (ex: jar)
  • Install: Installs the package in local repository
  • Deploy: Copies the package to remote repository

Build Profiles:
Build profiles are used to build projects with different configurations. This helps us to avoid creating multiple POM.xml files with different configurations.
There are 3 types of Build Profiles,

  • Per user
  • Per project
  • Global

Maven Plugins:
There are two types of plugins in maven,

  • Build Plugin: Executed during build and should be declared within tag <build> tag
  • Reporting Plugin: Executed during Site generation and declared within tag <reporting> tag

Maven Repositories:

  • Local Repository
  • Central Repository
  • Remote Repository

Local Repository: 
It is a directory in our local system. When we run maven it will download the dependencies and will keep those dependencies in our system, So we can re-use the same downloaded dependencies for other projects too.

Central Repository:
Central Repository is provided by Maven Community. Maven looks into central repository when it cannot find the dependencies in the Local Repository

Remote Repository:
Remote Repository is the repository in the web server.

External Dependencies:
These dependencies are the one which are not available in the Local Repository or Central or Remote Repository But available in our Hard disk.

SNAPSHOT Dependencies:
These are the dependencies that are still under development. SNAPSHOT dependencies make sure that we have the latest version on every build.

By Sri

One thought on “Maven Overview – Core Concepts”

Leave a Reply

Your email address will not be published. Required fields are marked *