1

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

4

1 に答える 1

2

はい、これは実際に可能であり、次のように@paramを使用して xml パラメーターと同じ名前の静的フィールドに注釈を付けることによって実現されます。

/**
 * Package name - this is injected from the 'packageName' xml element
 * @parameter
 */
private static String packageName;

/**
 * WSDL File Location, populated from the 'wsdlFile' xml element
 * @parameter
 */
private static String wsdlFile;

public void execute() throws MojoExecutionException, MojoFailureException {
    //do stuff here with packageName and wsdlFile.
}

PS: Checkstyle には @goal と @parameter に問題があります。//CSOFF: TreeWalker を使用して checkstyle をオフにして、このクラスを完全に無効にする必要がありました。

于 2011-12-02T21:17:42.923 に答える