Search in sources :

Example 1 with MavenConsole

use of org.jetbrains.idea.maven.project.MavenConsole in project intellij-community by JetBrains.

the class MavenRunner method runBatch.

public boolean runBatch(List<MavenRunnerParameters> commands, @Nullable MavenGeneralSettings coreSettings, @Nullable MavenRunnerSettings runnerSettings, @Nullable final String action, @Nullable ProgressIndicator indicator) {
    LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed());
    if (commands.isEmpty())
        return true;
    MavenConsole console;
    AccessToken accessToken = ReadAction.start();
    try {
        if (myProject.isDisposed())
            return false;
        console = createConsole();
    } finally {
        accessToken.finish();
    }
    try {
        int count = 0;
        for (MavenRunnerParameters command : commands) {
            if (indicator != null) {
                indicator.setFraction(((double) count++) / commands.size());
            }
            MavenExecutor executor;
            accessToken = ReadAction.start();
            try {
                if (myProject.isDisposed())
                    break;
                executor = createExecutor(command, coreSettings, runnerSettings, console);
            } finally {
                accessToken.finish();
            }
            executor.setAction(action);
            if (!executor.execute(indicator)) {
                updateTargetFolders();
                return false;
            }
        }
        updateTargetFolders();
    } finally {
        console.finish();
    }
    return true;
}
Also used : AccessToken(com.intellij.openapi.application.AccessToken) MavenConsole(org.jetbrains.idea.maven.project.MavenConsole)

Example 2 with MavenConsole

use of org.jetbrains.idea.maven.project.MavenConsole in project intellij-community by JetBrains.

the class MavenRunner method run.

public void run(final MavenRunnerParameters parameters, final MavenRunnerSettings settings, final Runnable onComplete) {
    FileDocumentManager.getInstance().saveAllDocuments();
    final MavenConsole console = createConsole();
    try {
        final MavenExecutor[] executor = new MavenExecutor[] { createExecutor(parameters, null, settings, console) };
        ProgressManager.getInstance().run(new Task.Backgroundable(myProject, executor[0].getCaption(), true) {

            public void run(@NotNull ProgressIndicator indicator) {
                try {
                    try {
                        if (executor[0].execute(indicator)) {
                            if (onComplete != null)
                                onComplete.run();
                        }
                    } catch (ProcessCanceledException ignore) {
                    }
                    executor[0] = null;
                    updateTargetFolders();
                } finally {
                    console.finish();
                }
            }

            @Nullable
            public NotificationInfo getNotificationInfo() {
                return new NotificationInfo("Maven", "Maven Task Finished", "");
            }

            public boolean shouldStartInBackground() {
                return settings.isRunMavenInBackground();
            }

            public void processSentToBackground() {
                settings.setRunMavenInBackground(true);
            }

            public void processRestoredToForeground() {
                settings.setRunMavenInBackground(false);
            }
        });
    } catch (Exception e) {
        console.printException(e);
        console.finish();
        MavenLog.LOG.warn(e);
    }
}
Also used : Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) MavenConsole(org.jetbrains.idea.maven.project.MavenConsole) Nullable(org.jetbrains.annotations.Nullable) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

MavenConsole (org.jetbrains.idea.maven.project.MavenConsole)2 AccessToken (com.intellij.openapi.application.AccessToken)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Nullable (org.jetbrains.annotations.Nullable)1