Maven Reading series: The life cycle of Maven

Source: Internet
Author: User

The life cycle of MAVEN is abstract, that is, the life cycle does not do any actual work, the actual task is done by the plug-in, similar to the template method in the design pattern.

Two or three sets of life cycles

MAVEN has three separate life cycles, clean, default, and site, respectively. Each life cycle contains phases (phase), stages are sequential, and later phases depend on the previous phases.

1, Clean life cycle : Cleanup project, including three phase.

1) Pre-clean: Work to be done before performing the cleanup

2) Clean: Cleans up the last build generated file

3) Post-clean: Work to be done after the cleanup is performed

2, the default life cycle : building projects, the important phase are as follows.

1) Validate: Verify that the project is correct and that all required resources are available.
2) Compile: Compile the source code of the project.
3) Test: Use the appropriate unit test framework for testing the compiled source code. These tests do not need to be packaged and deployed.
4) Package: Packages compiled code into a ready-to-publish format, such as a jar.
5) Integration-test: If necessary, package processing and publishing to an environment capable of integration testing.
6) Verify: Run all checks to verify that the package is valid and meets the quality standards.
7) Install: Installs the package to the MAVEN local repository and can be used by other projects as dependencies.
8) Deploy: Execute in an integrated or release environment, copy the final version of the package to a remote repository, so that other developers or projects can be shared.

3, Site life cycle : Establish and publish Project site, phase as follows

1) Pre-site: Work to be done before building the project site

2) Site: Generate Project Site documentation

3) Post-site: Work to be done after building the project site

4) Site-deploy: Publish the project site to the server

Iii. command line and life cycle

Each life cycle is independent and dependent on the stage of a life cycle.

Examples are as follows:

1. MVN Clean

Call the clean phase of the clean life cycle to actually perform the Pre-clean and clean phases

2, MVN test

Call the test phase of the default life cycle, actually executing test and all previous stages

3. MVN clean Install

Call the clean phase of the clean life cycle and the install phase of default to actually perform Pre-clean and Clean,install and all previous stages

Iv. M2eclipse and life cycle

1. M2eclipse Preset mvn command

Right-click Maven Project or Pom.xml file >run as to see the preset mvn command

2. Custom MVN command

Single-hit Maven Build ..., custom command mvn clean install:

Once the definition is complete, click Maven Build to see the defined commands:


Maven Reading series: The life cycle of Maven

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.