java project management - Maven
This article introduce java project management and comprehension tool - Maven
Based on the concept of project object Model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.
Build LifeCycle
Maven build is based around the concept of build lifecycle, which means the process for building and distributing a particular artifact(project) is clearly defined.
There are 3 built-in build lifecycles:
default
handles your project deploymentclean
handles project cleaningsite
handles the creation of project’s web site
phase
Each build lifecycle is defined by a different list of build phases, a build phase represents a stage in the lifecycle.
The default
build lifecycle:
- validate
- initialize
- generate-sources
- process-sources
- generate-resources
- process-resources
- compile
- process-classes post-process the generated files from compilation, for example to do bytecode enhancement on java classes.
- test-compile
- test
- package
- verify
- install install hte built artifact into local repo
- deploy deploy the built artifact into remote repo
Plugin
Maven is a plugin execution framework, all work is done by plugins.
Core plugins:
- clean
- compiler
- deploy
- install
- surefire run the junit tests in an isolated classloader
plugin goals
A build phase is made up of plugin goals. In pom declaring the plugin goals bound to the build phase to carry out the responsibility
- show all goals of a plugin
mvn help:describe -Dplugin=versions
Maven Dependency plugin
The dependency plugin provides the capability to manipulate artifacts
Versions Maven Plugin
manage the versions of artifacts in a project’s POM
update project version
mvn build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion} versions:commit
display dependency updates
mvn versions:display-dependency-updates
update dependencies
mvn versions:use-latest-releases