This is some thing I wanted to do. My initial requirement was to run a maven plugin within a run time of another plugin. So i found the way of running the maven plugin via java code.
Use Case
I wanted to integrate running soapui projects within integration tests in a WSO2 product run time. What I did was to have a separate pom.xml with the plugin configuration that I wanted to run and call it within a test case. The test case is executed by the maven surefire plugin.
Here is the sample code snipet.
Use Case
I wanted to integrate running soapui projects within integration tests in a WSO2 product run time. What I did was to have a separate pom.xml with the plugin configuration that I wanted to run and call it within a test case. The test case is executed by the maven surefire plugin.
Here is the sample code snipet.
InvocationRequest request = new DefaultInvocationRequest();
request.setPomFile( new File(FrameworkPathUtil.getSystemResourceLocation() + "artifacts" +
File.separator + "AS" + File.separator + "soapprojects" +
File.separator + "pom" + File.separator + "pom.xml") );
request.setGoals(Arrays.asList("clean", "install"));
Invoker invoker = new DefaultInvoker();
invoker.setMavenHome(new File("/home/waruna/apache-maven-3.0.5"));
invoker.execute( request );