in plugin/src/main/java/com/uber/okbuck/core/manager/BuckFileManager.java [57:86]
public void writeToBuckFile(
List<Rule> rules, File buckFile, Multimap<String, String> extraLoadStatements) {
if (!rules.isEmpty()) {
Multimap<String, String> loadStatements = getLoadStatements(rules);
loadStatements.putAll(extraLoadStatements);
File parent = buckFile.getParentFile();
if (!parent.exists() && !parent.mkdirs()) {
throw new IllegalStateException("Couldn't create dir: " + parent);
}
try (OutputStream fos = new FileOutputStream(buckFile);
BufferedOutputStream os = new BufferedOutputStream(fos)) {
GeneratedHeader.template().render(os);
if (!loadStatements.isEmpty()) {
LoadStatements.template(writableLoadStatements(loadStatements)).render(os);
}
for (int index = 0; index < rules.size(); index++) {
// Don't add a new line before the first rule
if (index != 0) {
os.write(NEWLINE);
}
rules.get(index).render(os);
}
} catch (IOException e) {
throw new IllegalStateException("Couldn't create the buck file", e);
}
}
}