}
else {
setupUserProperties(commandLine, context);
}
final BooleanValueHolder hasErrors = new BooleanValueHolder(false);
try {
final File workingDirectory = new File(FileUtil.toSystemDependentName(workingPath));
if (!workingDirectory.exists()) {
if (!workingDirectory.mkdirs()) throw new IOException("Cannot create directory " + workingPath);
}
final BaseOSProcessHandler handler = new BaseOSProcessHandler(
new ProcessBuilder(commandLine).directory(workingDirectory).start(),
null,
Charset.defaultCharset()
);
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
String[] lines = event.getText().split("\\n");
if (lines.length > 0) {
if (lines[0].matches("Error: : unknown option `-python'.")) {
handler.detachProcess();
handler.removeProcessListener(this);
context.errorHandler("Currently active Haxe toolkit doesn't supports Python target. Please install latest version of Haxe toolkit");
Notifications.Bus.notify(
new Notification("", "Current version of Haxe toolkit doesn't supports Python target", "You can download latest version of Haxe toolkit at <a href='http://haxe.org/download'>haxe.org/download</a> ", NotificationType.WARNING, NotificationListener.URL_OPENING_LISTENER));
return;
}
}
context.handleOutput(lines);
}
@Override
public void processTerminated(ProcessEvent event) {
hasErrors.setValue(event.getExitCode() != 0);
super.processTerminated(event);
}
});
handler.startNotify();
handler.waitFor();
}
catch (IOException e) {
context.errorHandler("process throw exception: " + e.getMessage());
return false;
}
return !hasErrors.getValue();
}