【发布时间】:2020-07-20 16:25:01
【问题描述】:
我创建了一个自定义的 maven 插件,并想在代码中读取目标的名称。
@Mojo(name="wite-to-file")
@Mojo(name="write-to-file")
public class CustomPlugin{
public void execute(){
Annotation[] annotations = this.getClass().getAnnotations();
annotations[0].toString() // this does not return the value of the Mojo.
}
}
When maven plugin's execute method gets called, Is there a way to access the current goal name? or the name of the Mojo?
I tried annotations but could not read the value of Mojo.
【问题讨论】:
-
我猜你也需要扩展
AbstractMojo类。 -
扩展到
AbstractMojo是正确的,但为什么需要获取目标名称?你已经通过@Mojo(name="...")定义了它?
标签: java maven maven-plugin