Apache Maven

Topics related to Apache Maven:

Getting started with Apache Maven

As described by its official Start Guide:

Maven is an attempt to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices.

Maven is essentially a project management and comprehension tool and as such provides a way to help with managing:

  • Builds
  • Documentation
  • Reporting
  • Dependencies
  • Version Control
  • Releases
  • Distribution

Hence, supporting developers across many phases of the whole Software Development Life Cycle (SDLC).

This philosophy is part of Maven in its core: i.e., the word maven means accumulator of knowledge (in Yiddish).

Maven is about the application of patterns in order to achieve an infrastructure which displays the characteristics of visibility, reusability, maintainability, and comprehensibility.

  • Maven was born of the very practical desire to make several projects work in the same way, as stated by the official Maven philosophy statement.
  • Developers could freely move between projects, knowing clearly how they all worked by understanding how one of them worked
  • The same idea extends to testing, generating documentation, generating metrics and reports, and deploying

Maven Assembly Plugin

POM - Project Object Model

Eclipse integration

Maven Surefire Plugin

Maven Tomcat Plugin

Create a Maven Plugin

A Maven plugin is a JAR containing a maven/plugins.xml that describes the plugin metadata. This file is generated by the maven-plugin-plugin.

Maven Build Cycle

Perform a Release

Note: Make sure to use maven release plugin 2.5 or later to avoid maven related issues. The Release Process

mvn release:clean

The above command will perform the below : delete the release descriptor (release.properties) delete any backup POM files

mvn release:prepare

Next part of the Release process is Preparing the Release; this will: perform some checks – there should be no uncommitted changes and the project should depend on no SNAPSHOT dependencies change the version of the project in the pom file to a full release number (remove SNAPSHOT suffix) – in our example – 0.0.1 run the project test suites commit and push the changes create the tag out of this non-SNAPSHOT versioned code increase the version of the project in the pom – in our example – 0.0.2-SNAPSHOT commit and push the changes

mvn release:perform

The latter part of the Release process is Performing the Release; this will: checkout release tag from SCM build and deploy released code This second step of the process relies on the output of the Prepare step – the release.properties.

Access Maven informations in code

Generate FIXME/TODO reports using the taglist-maven-plugin

Maven EAR plugin

Maven install in window

how to install maven in window 7 Steps:

  1. download the maven form https://maven.apache.org/download.cgi (poffice website) 2.unzip the maven binary folder and save into any floder (good : save in the program files in c drive )
  2. Check environment variable value open command prompt and type echo %java_home% its should display path of the jdk like : C:\Program Files\Java\jdk1.8.0_102 if not displayed set the environment variable java_home

Set the environment variables using system m2_home : set the path of the folder where its stored maven_home : same as above set the path Adding to PATH: Add the unpacked distribution’s bin directory to your user PATH environment variable path:%m2_home%\bin

To verify open the command prompt and type mvn -version should display this message Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T04:57:37-07:00) Maven home: /opt/apache-maven-3.3.3 Java version: 1.8.0_45, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac

some time it will not display because mvn folder not running with the admin access make running as administrator