将参数从 mojo 传递到自定义生命周期
我编写了一个自定义 Maven 插件,它扩展了 axis2 wsdl2java 插件,其概念是创建自定义生命周期,其中 wsdl2java 插件在执行我的自定义插件的目标之前执行。
调用自定义生命周期的代码如下。
lifecycle.xml
<lifecycles>
<lifecycle>
<id>custom-lifecycle</id>
<phases>
<phase>
<id>invoke</id>
<executions>
<execution>
<goals>
<goal>
org.apache.axis2:axis2-wsdl2code-maven-plugin:wsdl2code
</goal>
</goals>
<configuration>
<packageName>com.foo.myservice</packageName>
<wsdlFile>src/main/wsdl/myservice.wsdl</wsdlFile>
</configuration>
</execution>
</executions>
</phase>
</phases>
</lifecycle>
</lifecycles>
我的 Mojo 是
/**
*
* @goal process
* @execute lifecycle="custom-lifecycle" phase="invoke"
*/
public class SampleMojo extends AbstractMojo
{
public void execute()
throws MojoExecutionException
{
//Code
}
}
问题:我想从我的自定义插件传递 wsdl2java 插件的参数(即packagename、wsdlFile)。
是否可以将参数从我的 Mojo 发送到自定义生命周期?如果是的话该怎么办呢?
提前致谢
Aadhya
i have written a custom maven plugin which extends the axis2 wsdl2java plugin with the concept of creating custom lifecycle where the wsdl2java plugin is executed before goal of my custom plugin is executed.
The code for invoking the custom lifecycle is as follows.
lifecycle.xml
<lifecycles>
<lifecycle>
<id>custom-lifecycle</id>
<phases>
<phase>
<id>invoke</id>
<executions>
<execution>
<goals>
<goal>
org.apache.axis2:axis2-wsdl2code-maven-plugin:wsdl2code
</goal>
</goals>
<configuration>
<packageName>com.foo.myservice</packageName>
<wsdlFile>src/main/wsdl/myservice.wsdl</wsdlFile>
</configuration>
</execution>
</executions>
</phase>
</phases>
</lifecycle>
</lifecycles>
My Mojo is
/**
*
* @goal process
* @execute lifecycle="custom-lifecycle" phase="invoke"
*/
public class SampleMojo extends AbstractMojo
{
public void execute()
throws MojoExecutionException
{
//Code
}
}
Problem:I want to pass the parameters of wsdl2java plugin (i.e,packagename,wsdlFile) from my custom plugin.
Is it possible to send the parameters from my Mojo to custom lifecycle? If so how to do it?
Thanks in Advance
Aadhya
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这确实是可以的,是通过用@param注释与xml参数同名的static字段来实现的,如下:
PS:Checkstyle有@问题goal 和 @parameter - 我必须使用 //CSOFF: TreeWalker 关闭 checkstyle 以完全禁用该类。
Yes, this is indeed possible, and is achieved by annotating static fields with the same name as the xml parameter with @param as follows:
PS: Checkstyle has a problem with @goal and @parameter - I had to turn off checkstyle using //CSOFF: TreeWalker to disable it completely for this class.