Maven plug-in (2)

Maven life cycle requirements for the construction of the overall architecture, and specific work by providing plug-ins, Maven provides a set of default plug-in to complete the general clean-up, initialization, compile, test, package, integration testing, validation, deployment and site generation and so on.

Maven is not in a closed mechanism design, it also provides great convenience, it is still flexible and scalable, which can be configured by the user or the existing plug-ins to write your own plug-ins to customize the build behavior.

A, Maven plugins What?
Access Maven plug-in home page, you can see Maven plugin: https: //maven.apache.org/plugins/index.html

(Supplement Maven Plugin Home Pictures)

How to view Maven plug-in details:
1, Method One: Maven plug-in home page, click on the corresponding plug-in link. In compiler Example:
      As shown below, the profile comprising a plug, Goals instructions, instructions for use, sample.

      (Supplement maven plugin Home compiler plug-in help page screenshot)

2. Method Two: Use the help plug
    mvn help: describe -Dplugin = org.apache.maven.plugins: maven-surefire-plugin: 3.0.0-M2 -Ddetail
    view help surefire plug by plug-ins help. 3.0.0 specify which surefire version number. -Ddetail specified output details.
   

    More brief invocation:
    mvn Help: DESCRIBE -Dplugin = org.apache.maven.plugins: Maven-the Surefire plugin-
    mvn Help: DESCRIBE -Dplugin = Compiler

 

Second, the correspondence between the plug and the life cycle

All stages of the life cycle (Phase) + essentially plug which is used to complete the operation Goals.

1, Maven default definition of each life cycle stage (Phase) corresponds to a plug-and Goals.

Complier to plug an example:

(1) compiler: compile bind to compile stage.

(2) compiler: testCompile bound to test-compile phase.

(Supplement maven compiler plugin Home Help screenshot)

 

Such as:

    mvn clean

         mvn command specifies that the stage is the implementation of pre-clean, clean two-stage task. mvn command actually calls the background of these two phases corresponding to the difference: Goals.

    mvn maven-clean-plugin:2.4.1:clean

         

        

 

2, can also be based on project needs, a custom plug-in POM + Goals need to perform life cycle stages. Such as:

  (Supplement https://blog.csdn.net/lk142500/article/details/93387210 in the screenshot)


Second, regarding the configuration of the plug
1, the command line may be performed, configuration specifies plug, such as: the install mvn to true -Dmaven.test =
2, may be defined in the POM configuration plug
   (1) a plug-in global configuration parameters . Regardless of the implementation of this plug-in which Phase, this configuration is valid.

               (Supplement https://blog.csdn.net/lk142500/article/details/93387210 in the screenshot)

   (2) In addition to configuring the global parameters for the plug, a plug-in can also configure task-specific parameters. This configuration is valid only if the specified plug-in performs the specified tasks.

               (Supplement https://blog.csdn.net/lk142500/article/details/93387210 in the screenshot)   

 

Guess you like

Origin www.cnblogs.com/yickel/p/12011732.html