Maven plugin MOJO API in term of parameters

2019-07-26 04:21发布

问题:

From my understanding
the MOJO relative to the compile goal of the maven-compiler-plugin
defines its own parameters,just like any other MOJO plugins.

For example it should have a parameter defined somewhat like the following:

/** @parameter default-value="${project.build.sourceDirectory}" */
private String sDir; 

So these parameters definitions represent a kind of API for the MOJO,
that we can set in various way, mainly from the execution tag.

Please,correct me if I'm wrong.

My question is: Where can I filed the API fefinition of the standard maven plugin, in term of those parameters?

回答1:

A MOJO (or be more accurate) a goal of a plugin can define the parameter as it likes (or what the plugin author has in mind). Yes this means it's is a kind of an API which is accessed via the pom.xml via the configuration tag of the plugin or sometimes via command line (in case of special goals).

For every plugin you can find the documentation online like for example for the maven-compiler-plugin where you can find here the appropriate parameters:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html

Any of the plugins which are located in the groupId: org.apache.maven.plugins you can find it via this overview:

https://maven.apache.org/plugins/

and you can access the linke goals on the page where you find the list of available goals a plugin has and if you go to the link you will find all the parameters.

Apart from that you should take a look here:

  • https://maven.apache.org/developers/mojo-api-specification.html
  • https://maven.apache.org/plugin-tools/maven-plugin-tools-annotations/index.html

For things which can be used in the defaultValue you can take a look here:

  • https://maven.apache.org/ref/3.1.1/maven-core/apidocs/org/apache/maven/plugin/PluginParameterExpressionEvaluator.html