Saturday, October 8, 2016

Introduction to maven

What is Maven ?

Maven is a project management tool, based on the concept of a project object model (POM).

Maven was created to solve the lack of standards in Ant.

Maven’s Objectives

Maven’s primary areas of concern are:

  • Providing a uniform build system through a project object model and plugins
  • Providing quality project information from the POM and from the project’s sources
  • Providing guidelines for best practices in software development
    • The maven normal build cycle includes the execution of unit tests.
    • Maven suggests how to layout the structure of the directories of a project.
    • Maven assists in project workflow such as release management and issue tracking.

Introduction to the Build Lifecycle

Maven is based on the concept of a build lifecycle. A lifecycle is a well defined process for building and distributing a project.

There are three built-in build lifecycles:

  • the default lifecycle handles the project build and distribution
  • the clean lifecycle handles project cleaning
  • the site lifecycle handles the creation of documentation of the project
A Build Lifecycle is Made Up of Phases

Each build lifecycles is defined as a list of build phases, where a build phase represents a step in the lifecycle. For example, the main phases of the default lifecycle are:

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.
package - package the compiled code in distributable format, such as a .jar file.
verify - run any checks on results of integration tests to ensure quality criteria are met
install - install the package into the local repository, for use as a dependency in other projects locally
deploy - copy the final package to the remote repository for sharing with other developers and projects.

The lifecycle phases are executed sequentially to complete the default lifecycle.

A Build Phase is Made Up of Plugin Goals

The manner in which a build phase carries out its responsibilities may vary and depends on the plugin goals bound to that build phase. Each phase has zero or more plugin goals bound to it.

  • A goal represents a specific task which contributes to the building and managing of a project.
    • examples of goals include the compile goal in the Compiler plugin or the test goal of the Surefire plugin
  • A plugin is a collection of one or more goals.
    • example of core plugins are: the Jar plugin, the Compiler plugin, the Surefire plugin
    • example of specialized plugins are: the Hibernate3 plugin

No comments :

Post a Comment