Is it possible to call Maven goals from Java, for instance, can I do the equivalent of:
mvn clean package
from a Java class?
thanks, Ni
This is easy :)
Java code
MavenCli cli = new MavenCli();
cli.doMain(new String[]{"clean", "package"}, "project_dir", System.out, System.out);
Project configuration:
org.apache.maven
maven-embedder
3.1.1
org.eclipse.aether
aether-connector-wagon
0.9.0.M2
org.apache.maven.wagon
wagon-http-lightweight
2.5
Fully working example: https://github.com/mariuszs/maven-cli-example