这里我有我的Maven Mojo:
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.shared.invoker.*;
import java.util.Collections;
@Mojo(name = "run")
public class RunMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException {
InvocationRequest request = new DefaultInvocationRequest();
request.setGoals(Collections.singletonList("myplugin:mygoal"));
// need to set parameters to pass to the goal
Invoker invoker = new DefaultInvoker();
try {
invoker.execute(request);
} catch (MavenInvocationException e) {
e.printStackTrace();
}
}
}
我需要在pom.xml中定义插件时调用第二个Mojo传递一些参数,如下所示。
<build>
<plugins>
<plugin>
<artifactId>myPlugin</artifactId>
<groupId>myGroupId</groupId>
<version>myVersion</version>
<configuration>
<param1>value1</param1>
<param2>value2</param2>
<param3>value3</param3>
</configuration>
</plugin>
</plugins>
</build>
任何解决方案?提前谢谢。