stdout.start();
Thread stderr = new StreamRedirectThread(process.getErrorStream(), System.err);
stderr.setDaemon(true);
stderr.start();
stdout.join();
stderr.join();
int exitCode = process.waitFor();
if (exitCode != 0) {
throw new IOException(MessageFormat.format(
"Cache builder returns unexpected exit code: {0}",
exitCode));