// thread locals are evil (I'm talking to you - org.codehaus.plexus.DefaultPlexusContainer#lookupRealm!)
Thread t = new Thread(new Runnable() {
@Override
public void run() {
System.out.println("Invoking projects in " + outDir);
MavenCli maven = new MavenCli();
resultPointer[0] = maven.doMain(new String[] { "clean", "package", "-f", "archetypes-test-pom.xml" }, outDir, System.out, System.out);
System.out.println("result: " + resultPointer[0]);
}
});
t.start();
t.join();