Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Maven from Java?

I want to execute Maven command from Java for development of a plugin. I tried maven-embedder but looks like it is now not supported. Is someone aware of some other tool which can be used?

like image 779
ajjain Avatar asked Feb 28 '11 12:02

ajjain


1 Answers

A simple invocation API : maven-invoker.

Project documentation : http://maven.apache.org/shared/maven-invoker/

Usage : http://maven.apache.org/shared/maven-invoker/usage.html

InvocationRequest request = new DefaultInvocationRequest(); request.setPomFile( new File( "/path/to/pom.xml" ) ); request.setGoals( Arrays.asList( "clean", "install" ) );  Invoker invoker = new DefaultInvoker(); invoker.execute( request ); 
like image 188
user3254289 Avatar answered Sep 22 '22 12:09

user3254289