在pom.xml中,有一段指定maven插件的配置:
<plugin>
...
<configuration>
<param1>true</param1>
...
<param10>value</param1>
</configuration>
</plugn>
如何检索所有可能的参数并对指定插件的值进行限制?换句话说,我需要检索param1,param2 ... param10的名称。
我有IntelliJ,但没有提示。
目前我上网并阅读该插件的文档。但我认为,这不是最好的选择。
答案 0 :(得分:2)
您可以通过指定detail
属性来使用goal
目标。
例如,获取maven编译器插件的完整描述:
mvn help:describe -Dplugin = org.apache.maven.plugins:maven-compiler-plugin -Ddetail
如果您想获得有关插件特定目标的文档,可以使用目标值指定compile
属性。
例如,要获得maven编译器插件的help:describe
Description: Displays a list of the attributes for a Maven Plugin and/or
goals (aka Mojo - Maven plain Old Java Object).
Implementation: org.apache.maven.plugins.help.DescribeMojo
Language: java
Available parameters:
artifactId
User property: artifactId
The Maven Plugin artifactId to describe.
Note: Should be used with groupId parameter.
cmd
User property: cmd
A Maven command like a single goal or a single phase following the Maven
command line:
mvn [options] [<goal(s)>] [<phase(s)>]
detail (Default: false)
User property: detail
This flag specifies that a detailed (verbose) list of goal (Mojo)
information should be given.
goal
User property: goal
The goal name of a Mojo to describe within the specified Maven Plugin. If
this parameter is specified, only the corresponding goal (Mojo) will be
described, rather than the whole Plugin.
groupId
User property: groupId
The Maven Plugin groupId to describe.
Note: Should be used with artifactId parameter.
medium (Default: true)
User property: medium
This flag specifies that a medium list of goal (Mojo) information should
be given.
minimal (Default: false)
User property: minimal
This flag specifies that a minimal list of goal (Mojo) information should
be given.
output
User property: output
Optional parameter to write the output of this help in a given file,
instead of writing to the console.
Note: Could be a relative path.
plugin
User property: plugin
The Maven Plugin to describe. This must be specified in one of three
ways:
1. plugin-prefix, i.e. 'help'
2. groupId:artifactId, i.e. 'org.apache.maven.plugins:maven-help-plugin'
3. groupId:artifactId:version, i.e.
'org.apache.maven.plugins:maven-help-plugin:2.0'
version
User property: version
The Maven Plugin version to describe.
Note: Should be used with groupId/artifactId parameters.
目标的完整描述:
mvn help:describe -Dplugin = org.apache.maven.plugins:maven-compiler-plugin -Dgoal = compile -Ddetail
以下是Maven帮助插件描述目标的官方文档:
http://maven.apache.org/plugins/maven-help-plugin/describe-mojo.html
你当然可以通过插件获得它:
mvn help:describe -Dplugin = org.apache.maven.plugins:maven-help-plugin -Ddetail -Dgoal = describe
您将获得输出:
{{1}}
以下是一些使用它的例子:
http://maven.apache.org/plugins/maven-help-plugin/examples/describe-configuration.html
答案 1 :(得分:1)
如果你想以编程方式进行,那就是答案。
此信息作为元数据存储在插件jar文件(注释和配置文件)中。但不是那么容易,因为值控件可以在插件代码中实现。
然而,您应该能够创建一个程序来检查插件jar提取的有用信息,如参数名称和类型。
查看Maven API文档,了解搜索插件参数的位置。
作为一个注释,我认为Eclipse ide已经自动完成了pom.xml文件中的插件参数,因此您需要的代码应该可以在源代码中找到...