How Maven executes

How Maven executes

Maven abstracts and defines the build process, which is called the build lifecycle. The life cycle consists of multiple phases, and each phase is linked to one or more goals. Goal is the smallest unit that defines tasks in maven. Goals are divided into two categories. One is phase-bound, that is, when a certain phase is executed, the goal will be triggered. The other is not bound, which is a separate task. It is equivalent to the target in ant.

1. Build in phases,
for example:
mvn clean
mvn compile
mvn test
mvn package
indicates that maven will execute to a certain phase of a certain life cycle (phase),
this phase and all the goals (goals) bound to the previous phase will be executed, Each phase will bind maven's default goal or no goal, or a custom goal.
You can also skip certain phases by passing in parameters, for example:

mvn install -Dmaven.test.skip=true


1. Building
this type of goal with a goal is a goal without a bound phase, but this type of goal usually has an execution premise, that is, the project must be executed to a certain phase,
then executing this goal will actually trigger maven to execute the premise requirements. phase.
For example, jetty:run is a non-binding phase goal, and its premise is test-compile, which is formulated by the code logic of the plugin

/**
 * @goal run
 * @requiresDependencyResolution runtime
 * @execute phase="test-compile"
 * @description Runs jetty6 directly from a maven project
 */
public class Jetty6RunMojo extends AbstractJettyRunMojo
{
    ...
}

two. Maven lifecycle, phase overview
Maven presets three Lifecycles, each of which includes the following Phases.

  1. Clean Lifecycle
    • pre-clean
    • clean
    • post-clean
  2. Default Lifecycle
    • validate
    • initialize
    • generate-sources
    • process-sources
    • generate-resources
    • process-resources
    • compile
    • process-classes
    • generate-test-sources
    • process-test-sources
    • process-test-resources
    • test-compile
    • process-test-classes
    • test
    • prepare-package
    • package
    • pre-integration-test
    • integration-test
    • post-integration-test
    • verify
    • install
    • deploy
  3. Site Lifecycle
    • pre-site
    • site
    • post-site
    • site-deploy

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326112810&siteId=291194637