Skip to content

Instantly share code, notes, and snippets.

@a-thomas
Created October 25, 2012 11:41
Show Gist options
  • Save a-thomas/3952140 to your computer and use it in GitHub Desktop.
Save a-thomas/3952140 to your computer and use it in GitHub Desktop.
Maven Invoker API
InvocationRequest request = new DefaultInvocationRequest();
File pom = new File("MY_PROJECT/pom.xml");
request.setPomFile(pom);
File baseDir = new File("MY_PROJECT");
request.setBaseDirectory(baseDir);
ArrayList<String> goals = new ArrayList<String>();
goals.add("clean");
goals.add("install");
request.setGoals(goals);
request.setShowErrors(true);
DefaultInvoker invoker = new DefaultInvoker();
String mavenHome = System.getenv("MAVEN_HOME");
invoker.setMavenHome(new File(mavenHome));
InvocationResult result;
try {
result = invoker.execute(request);
} catch (MavenInvocationException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment