I am able to run maven build with the following code
MavenCli mavenCli = new MavenCli();
int result = mavenCli.doMain(goals.toArray(new String[goals.size()]), pom, System.out, System.out);
Basically result is equal to 0 if build is successful, and 1 otherwise. Is there any way to get the cause of a build failure?