mjs*_*mjs 9 maven-2 maven-plugin maven
在Maven文档构建生命周期简介中,display:time描述了输出当前时间的目标.该插件如下:
...
<plugin>
<groupId>com.mycompany.example</groupId>
<artifactId>maven-touch-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-test-resources</phase>
<goals>
<goal>timestamp</goal>
</goals>
</execution>
</executions>
</plugin>
...
Run Code Online (Sandbox Code Playgroud)
我有几个与此插件有关的问题:
例如,foo:bar如何将目标名称更改为?(为什么在XML片段中既没有display也没有time出现?如何从片段中看出它定义了什么目标?)
如何手动运行此目标?(对于类似的结构,相当于mvn display:time有时可行,但这并不一致.)
我怎样才能看出这个目标是否存在?(即列出可用的目标; 这个问题表明这是不可能的.)
Pas*_*ent 11
例如,
foo:bar如何将目标名称更改为?(为什么在XML片段中既没有display也没有time出现?如何从片段中看出它定义了什么目标?)
准确地说,在foo:bar,foo是"插件目标前缀",并bar是"目标".虽然后者源自命名约定(或者可以配置为1),但前者来自BarMojo实现插件逻辑的类的注释.像这样的东西:
/**
* Do the wonderful bar.
* @goal bar
* @requiresProject false
*/
public class BarMojo extends AbstractMojo
{
...
}
Run Code Online (Sandbox Code Playgroud)
更改目标需要修改插件的mojo注释并重建它.
关于您链接到的文档,目标time与XML片段之间明显不匹配,这会将timestamp目标与process-test-resources阶段绑定.这一定是拼写错误.
如何手动运行此目标?(对于类似的构造,相当于mvn display:time有时会起作用,但这不能一致地工作.)
你可以这样称呼它:
mvn com.mycompany.example:maven-touch-plugin:1.0:timestamp
Run Code Online (Sandbox Code Playgroud)
你可以把这个命令缩短加入com.mycompany.example到插件组在你settings.xml(org.apache.maven.plugins和org.codehaus.mojo默认的情况下,声明你想知道它是如何工作的这些插件)
<settings>
...
<pluginGroups>
<pluginGroup>com.mycompany.example</pluginGroup>
</pluginGroups>
</settings>
Run Code Online (Sandbox Code Playgroud)
然后,因为插件名称与${prefix}-maven-plugin或maven-${prefix}-plugin模式匹配,您可以执行:
mvn touch:timestamp
Run Code Online (Sandbox Code Playgroud)
建议遵循约定,但正如我所说,也可以配置前缀.
我怎样才能看出这个目标是否存在?
检查插件文档(从插件源派生)或插件源.
1请注意,Maven Book提到的页面底部也有拼写错误.使用自定义前缀执行插件的方法应该是mvn blah:echo(参见MVNREF-145).
| 归档时间: |
|
| 查看次数: |
2461 次 |
| 最近记录: |