@Nullable @Override public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException { RunProfile profile = myEnvironment.getRunProfile(); if (profile instanceof AntRunConfiguration) { AntRunConfiguration antRunConfiguration = (AntRunConfiguration)profile; AntBuildTarget target = antRunConfiguration.getTarget(); if (target == null) return null; ProcessHandler processHandler = ExecutionHandler .executeRunConfiguration(antRunConfiguration, myEnvironment.getDataContext(), new ArrayList<BuildFileProperty>(), new AntBuildListener() { @Override public void buildFinished(int state, int errorCount) { } }); if (processHandler == null) return null; return new DefaultExecutionResult(null, processHandler); } return null; }
private static void runBuild(final ProgressIndicator progress, @NotNull final AntBuildMessageView errorView, @NotNull final AntBuildFile buildFile, @NotNull final AntBuildListener antBuildListener, @NotNull GeneralCommandLine commandLine) { final Project project = buildFile.getProject(); final long startTime = System.currentTimeMillis(); LocalHistory.getInstance().putSystemLabel(project, AntBundle.message("ant.build.local.history.label", buildFile.getName())); final JUnitProcessHandler handler; try { handler = JUnitProcessHandler.runCommandLine(commandLine); } catch (final ExecutionException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ExecutionErrorDialog.show(e, AntBundle.message("could.not.start.process.erorr.dialog.title"), project); } }); antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0); return; } processRunningAnt(progress, handler, errorView, buildFile, startTime, antBuildListener); handler.waitFor(); }
private void triggerCleanAll(final Project project) { final HybrisProjectSettings yProjectSettings = HybrisProjectSettingsComponent.getInstance(project).getState(); final File platformDir = new File(project.getBasePath() + "/" + yProjectSettings.getHybrisDirectory() + PLATFORM_MODULE_PREFIX); final VirtualFile vfPlatformDir = VfsUtil.findFileByIoFile(platformDir, true); final VirtualFile vfBuildFile = VfsUtil.findRelativeFile(vfPlatformDir, HybrisConstants.ANT_BUILD_XML); if (vfBuildFile == null) { return; } final PsiFile psiBuildFile = PsiManager.getInstance(project).findFile(vfBuildFile); if (psiBuildFile == null) { return; } final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project); final AntBuildFileBase antBuildFile = antConfiguration.getAntBuildFile(psiBuildFile); if (antBuildFile != null) { ExecutionHandler.runBuild( antBuildFile, antCleanAll, null, getDataContext(project), Collections.emptyList(), AntBuildListener.NULL ); } }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) return; for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { final String name = buildFile.getPresentableName(); if (name != null && myBuildName.equals(name)) { String[] targets = myTargets.length == 1 && DEFAULT_TARGET_NAME.equals(myTargets[0]) ? ArrayUtil.EMPTY_STRING_ARRAY : myTargets; ExecutionHandler.runBuild((AntBuildFileBase)buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); return; } } }
public void actionPerformed(AnActionEvent e) { ExecutionHandler.runBuild( myAntBuildMessageView.getBuildFile(), myAntBuildMessageView.getTargets(), myAntBuildMessageView, e.getDataContext(), Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); }
@Override public void actionPerformed(AnActionEvent e) { Pair<AntBuildFileBase, AntDomTarget> antTarget = findAntTarget(e); if (antTarget == null) return; ExecutionHandler.runBuild( antTarget.first, new String[] {antTarget.second.getName().getValue() }, null, e.getDataContext(), Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); }
/** * @param antBuildListener should not be null. Use {@link com.intellij.lang.ant.config.AntBuildListener#NULL} */ public static void runBuild(final AntBuildFileBase buildFile, String[] targets, @Nullable final AntBuildMessageView buildMessageViewToReuse, final DataContext dataContext, List<BuildFileProperty> additionalProperties, @NotNull final AntBuildListener antBuildListener) { runBuildImpl(buildFile, targets, buildMessageViewToReuse, dataContext, additionalProperties, antBuildListener, true); }
@Nullable private static ProcessHandler runBuild(final ProgressIndicator progress, @NotNull final AntBuildMessageView errorView, @NotNull final AntBuildFileBase buildFile, @NotNull final AntBuildListener antBuildListener, @NotNull GeneralCommandLine commandLine) { final Project project = buildFile.getProject(); final long startTime = System.currentTimeMillis(); LocalHistory.getInstance().putSystemLabel(project, AntBundle.message("ant.build.local.history.label", buildFile.getName())); final JUnitProcessHandler handler; try { handler = JUnitProcessHandler.runCommandLine(commandLine); } catch (final ExecutionException e) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { ExecutionErrorDialog.show(e, AntBundle.message("could.not.start.process.error.dialog.title"), project); } }); antBuildListener.buildFinished(AntBuildListener.FAILED_TO_RUN, 0); return null; } processRunningAnt(progress, handler, errorView, buildFile, startTime, antBuildListener); return handler; }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) return; for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { final String name = buildFile.getPresentableName(); if (name != null && myBuildName.equals(name)) { String[] targets = myTargets.length == 1 && DEFAULT_TARGET_NAME.equals(myTargets[0]) ? ArrayUtil.EMPTY_STRING_ARRAY : myTargets; ExecutionHandler.runBuild((AntBuildFileBase)buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); return; } } }
private static void processRunningAnt(final ProgressIndicator progress, final JUnitProcessHandler handler, final AntBuildMessageView errorView, final AntBuildFile buildFile, final long startTime, final AntBuildListener antBuildListener) { final Project project = buildFile.getProject(); final StatusBar statusbar = WindowManager.getInstance().getStatusBar(project); if (statusbar != null) { statusbar.setInfo(AntBundle.message("ant.build.started.status.message")); } final CheckCancelTask checkCancelTask = new CheckCancelTask(progress, handler); checkCancelTask.start(0); final OutputParser parser = OutputParser2.attachParser(project, handler, errorView, progress, buildFile); handler.addProcessListener(new ProcessAdapter() { public void processTerminated(ProcessEvent event) { final long buildTime = System.currentTimeMillis() - startTime; checkCancelTask.cancel(); parser.setStopped(true); final OutputPacketProcessor dispatcher = handler.getErr().getEventsDispatcher(); errorView.buildFinished(progress != null && progress.isCanceled(), buildTime, antBuildListener, dispatcher); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (project.isDisposed()) { return; } errorView.removeProgressPanel(); ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.MESSAGES_WINDOW); if (toolWindow != null) { // can be null if project is closed toolWindow.activate(null, false); } } }, ModalityState.NON_MODAL); } }); handler.startNotify(); }
private void runSelection(final DataContext dataContext) { if (!canRunSelection()) { return; } final AntBuildFileBase buildFile = getCurrentBuildFile(); if (buildFile != null) { final TreePath[] paths = myTree.getSelectionPaths(); final String[] targets = getTargetNamesFromPaths(paths); ExecutionHandler.runBuild(buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); } }
public void actionPerformed(AnActionEvent e) { DataContext dataContext = e.getDataContext(); Project project = e.getProject(); if (project == null) return; for (final AntBuildFile buildFile : AntConfiguration.getInstance(project).getBuildFiles()) { final String name = buildFile.getPresentableName(); if (name != null && myBuildName.equals(name)) { String[] targets = myTargets.length == 1 && DEFAULT_TARGET_NAME.equals(myTargets[0]) ? ArrayUtil.EMPTY_STRING_ARRAY : myTargets; ExecutionHandler.runBuild((AntBuildFileBase)buildFile, targets, null, dataContext, Collections.<BuildFileProperty>emptyList(), AntBuildListener.NULL); return; } } }
void buildFinished(boolean isProgressAborted, long buildTimeInMilliseconds, @NotNull final AntBuildListener antBuildListener, OutputPacketProcessor dispatcher) { final boolean aborted = isProgressAborted || myIsAborted; final String message = getFinishStatusText(aborted, buildTimeInMilliseconds); dispatcher.processOutput(new Printable() { @Override public void printOn(Printer printer) { if (!myProject.isDisposed()) { // if not disposed addCommand(new FinishBuildCommand(message)); final StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); if (statusBar != null) { statusBar.setInfo(message); } } } }); //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { public void run() { if (!myIsOutputPaused) { new OutputFlusher().doFlush(); } final AntBuildFileBase buildFile = myBuildFile; if (buildFile != null) { if (getErrorCount() == 0 && buildFile.isViewClosedWhenNoErrors()) { close(); } else if (getErrorCount() > 0) { myTreeView.scrollToFirstError(); } else { myTreeView.scrollToStatus(); } } else { myTreeView.scrollToLastMessage(); } VirtualFileManager.getInstance().asyncRefresh(new Runnable() { public void run() { antBuildListener.buildFinished(aborted ? AntBuildListener.ABORTED : AntBuildListener.FINISHED_SUCCESSFULLY, getErrorCount()); } }); } }); }