private static void runRebar(@Nullable String contentRootPath,
@NotNull String rebarPath,
boolean addDebugInfo,
@NotNull CompileContext context) throws ProjectBuildException {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setWorkDirectory(contentRootPath);
commandLine.setExePath(rebarPath);
commandLine.addParameter("compile");
if (addDebugInfo) {
commandLine.getEnvironment().put("ERL_FLAGS", "+debug_info");
}
Process process;
try {
process = commandLine.createProcess();
} catch (ExecutionException e) {
throw new ProjectBuildException("Failed to run rebar", e);
}
BaseOSProcessHandler handler = new BaseOSProcessHandler(process, commandLine.getCommandLineString(), Charset.defaultCharset());
ProcessAdapter adapter = new ErlangCompilerProcessAdapter(context, NAME, commandLine.getWorkDirectory().getPath()); //TODO provide rebar messages handling
handler.addProcessListener(adapter);
handler.startNotify();
handler.waitFor();
}