use of org.moe.idea.maven.MOEMavenBuildTask in project moe-ide-integration by multi-os-engine.
the class MOEGradleRunner method buildProject.
private void buildProject(MOEGradleInvocationResult result) {
final Stopwatch stopwatch = Stopwatch.createUnstarted();
stopwatch.start();
String errorMessage = null;
try {
LOG.debug("Start build process");
final org.moe.idea.compiler.MOEGradleRunner gradleRunner = new org.moe.idea.compiler.MOEGradleRunner(runConfig);
final boolean isDebug = runConfig.getActionType().equals("Debug");
boolean isMaven = ModuleUtils.isMOEMavenModule(runConfig.module());
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(runConfig.getProject());
if (!isMaven) {
final GeneralCommandLine commandLine = gradleRunner.construct(isDebug, false);
final OSProcessHandler handler = new OSProcessHandler(commandLine);
handler.setShouldDestroyProcessRecursively(true);
handler.addProcessListener(new ProcessAdapter() {
@Override
public void onTextAvailable(ProcessEvent event, Key outputType) {
if (ProcessOutputTypes.STDERR.equals(outputType)) {
toolWindow.error(event.getText());
} else if (ProcessOutputTypes.STDOUT.equals(outputType)) {
toolWindow.log(event.getText());
}
}
});
handler.startNotify();
// Start and wait
handler.waitFor();
int returnCode = handler.getProcess().exitValue();
// Show on failure
if (returnCode != 0) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
errorMessage = "Multi-OS Engine module build failed";
}
} else {
MOEMavenBuildTask mavenTask = new MOEMavenBuildTask(runConfig, "Building " + runConfig.moduleName(), true);
boolean res = mavenTask.runTask();
if (!res) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
errorMessage = "Multi-OS Engine module build failed";
}
}
if (errorMessage == null) {
result.setBuildSuccessful(true);
} else {
result.setBuildSuccessful(false);
result.setErrorMessage(errorMessage);
}
} catch (Exception e) {
result.setBuildSuccessful(false);
result.setErrorMessage(String.format("Error while building %s .%n", e.getMessage()));
} finally {
stopwatch.stop();
}
}
use of org.moe.idea.maven.MOEMavenBuildTask in project moe-ide-integration by multi-os-engine.
the class MOECompileTask method execute.
@Override
public boolean execute(CompileContext context) {
RunConfiguration c = context.getCompileScope().getUserData(CompileStepBeforeRun.RUN_CONFIGURATION);
if (!(c instanceof MOERunConfiguration)) {
return true;
}
final MOERunConfiguration runConfig = (MOERunConfiguration) c;
isOpenDialog = runConfig.getOpenDeploymentTargetDialog();
canceled = false;
runConfig.setCanceled(canceled);
final MOEToolWindow toolWindow = MOEToolWindow.getInstance(runConfig.getProject());
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
@Override
public void run() {
toolWindow.clear();
if (isOpenDialog) {
DeviceChooserDialog dialog = new DeviceChooserDialog(runConfig.module(), runConfig);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
canceled = true;
runConfig.setCanceled(canceled);
}
isOpenDialog = false;
}
}
});
try {
while (isOpenDialog) {
Thread.sleep(100);
}
boolean isMaven = ModuleUtils.isMOEMavenModule(runConfig.module());
// Start progress
ProgressIndicator progress = context.getProgressIndicator();
context.getProgressIndicator().pushState();
progress.setText("Building MOE application");
if (canceled) {
toolWindow.balloon(MessageType.INFO, "BUILD CANCELED");
return true;
}
if (!isMaven) {
final CompileThread compileThread = new CompileThread(runConfig, context);
compileThread.start();
context.addMessage(CompilerMessageCategory.INFORMATION, "Building " + runConfig.moduleName(), null, -1, -1);
// Wait for completion
while (compileThread.isAlive() && !progress.isCanceled()) {
compileThread.join(1000);
}
if (compileThread.isAlive() && progress.isCanceled()) {
compileThread.interrupt();
compileThread.join(1000);
}
// Re-throw error
if (compileThread.throwable != null) {
throw compileThread.throwable;
}
// Show on failure
if (compileThread.returnCode != 0) {
if (!compileThread.canceled) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
context.addMessage(CompilerMessageCategory.ERROR, "Multi-OS Engine module build failed", null, -1, -1, toolWindow.getNavigatable());
} else {
toolWindow.balloon(MessageType.INFO, "BUILD CANCELED");
}
return false;
}
} else {
MOEMavenBuildTask mavenTask = new MOEMavenBuildTask(runConfig, "Building " + runConfig.moduleName(), true);
boolean result = mavenTask.runTask();
if (!result) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
context.addMessage(CompilerMessageCategory.ERROR, "Multi-OS Engine module build failed", null, -1, -1, toolWindow.getNavigatable());
return false;
}
}
} catch (Throwable t) {
toolWindow.balloon(MessageType.ERROR, "BUILD FAILED");
LOG.error("Failed to compile module", t);
context.addMessage(CompilerMessageCategory.ERROR, "Multi-OS Engine module build failed, an internal error occurred", null, -1, -1);
return false;
} finally {
context.getProgressIndicator().popState();
}
return true;
}
Aggregations