for (final File file : getSource().getFiles()) {
final List<String> command = buildCommand(file.getAbsolutePath());
getProject().getLogger().info("Running thrift: " + command);
if (!out.isDirectory()) {
if (!out.mkdirs()) {
throw new GradleException("Could not create thrift output directory: " + out);
}
}
final CountDownLatch latch = new CountDownLatch(2);
final Process p = new ProcessBuilder(command)
.start();
new SlurpThread(latch, p.getInputStream(), System.out).start();
new SlurpThread(latch, p.getErrorStream(), System.err).start();
if (p.waitFor() != 0) {
latch.countDown();
throw new GradleException(thriftExecutable() + " command failed");
}
latch.await();
}
}