Maven - Build Lifecycle

来源:互联网 发布:屠龙大陆翅膀进阶数据 编辑:程序博客网 时间:2024/06/04 01:26


Introduction to the Build Lifecycle 


关键点:

Maven is based around the central concept of a build lifecycle. What this means is that the process for building and distributing a particular artifact (project) is clearly defined. thePOM will ensure they get the results they desired.

There are three built-in build lifecycles: default, clean and site.

The default lifecycle handles your project deployment, theclean lifecycle handles project cleaning, while the site lifecycle handles the creation of your project's site documentation.

A Build Lifecycle is Made Up of Phases.

The default lifecycle comprises of the following phases:


  • 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. These tests should not require the code be packaged or deployed
  • package - take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test - process and deploy the package if necessary into an environment where integration tests can be run
  • verify - run any checks to verify the package is valid and meets quality criteria
  • install - install the package into the local repository, for use as a dependency in other projects locally
  • deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

A Build Phase is Made Up of Plugin Goals.

A plugin goal represents a specific task. It may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation. If a goal is bound to one or more build phases, that goal will be called in all those phases.

A build phase can also have zero or more goals bound to it.  If a build phase has no goals bound to it, that build phase will not execute. But if it has one or more goals bound to it, it will execute all those goals.


Setting Up Your Project

Packaging

Set the packaging for your project via the equally named POM element <packaging>.

Setting packaging value means bind default goal to particular phrase.

Some of the valid packaging values are jar, war, ear andpom.

If no packaging value has been specified, it will default to jar.

Particular packaging value represents that particular list of goals to bind to a particular phase.

Some packaging values need to include a particular plugin in the <build> section of your POM and specify<extensions>true</extensions> for that plugin.

Plugins

The second way to add goals to phases is to configure plugins in your project.







0 0
原创粉丝点击