How does maven work?
Intro
Apache Maven is a tool for building and managing any Java-based project. It’s based on the concept of a Project Object Model (POM).
For every project you have to manage a pom.xml file. This file contains information about the project and configuration used by Maven to build the project. Everything for your Maven build is defined within this POM file.
Main Goals of Maven
- Making the build process unified
- Providing project information
Based on your pom configuration Maven knows how to build your project. With the project information it is capable of downloading the defined dependencies from the maven repository and bundling them with your application.
How does a Maven Build work?
Maven has three build lifecycles:
- default (project deployment)
- clean (project cleaning)
- site (creates project’s site documentation)
All lifecycles consist of different build phases. The default lifecycle for example consist of these build phases:
- validate
- compile
- test
- package
- verify
- install
- deploy
You can define different goals for each build phase in your pom.xml file. Goals perform the action required to make the build. The Java class files which define a goal are called Mojo (Maven plain Old Java Object). Each Mojo is an executable goal which can be configured within the pom.xml file. A Maven Plugin on the other contains one or more Mojos.
On the command line you can say which of these lifecycles you want to execute. You can even specify which build phase or which goal you want to start. Based on your configuration Maven the figures out what actions need to be performed.
For more information have a look at their website: Welcome to Apache Maven
还没有评论,来说两句吧...