Search in sources :

Example 6 with Task

use of com.google.idea.blaze.base.toolwindow.Task in project intellij by bazelbuild.

the class BlazeAndroidRunConfigurationRunner method executeBeforeRunTask.

@Override
public boolean executeBeforeRunTask(ExecutionEnvironment env) {
    final Project project = env.getProject();
    BlazeUserSettings settings = BlazeUserSettings.getInstance();
    return Scope.root(context -> {
        context.push(new ProblemsViewScope(project, settings.getShowProblemsViewOnRun())).push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(settings.getShowBlazeConsoleOnRun()).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.ContextType.BeforeRunTask, true)).build()).push(new ToolWindowScope.Builder(project, new Task(project, "Build apk", Task.Type.BEFORE_LAUNCH)).setPopupBehavior(settings.getShowBlazeConsoleOnRun()).setIssueParsers(BlazeIssueParser.defaultIssueParsers(project, WorkspaceRoot.fromProject(project), ContextType.BeforeRunTask)).build()).push(new IdeaLogScope());
        BlazeAndroidRunContext runContext = env.getCopyableUserData(RUN_CONTEXT_KEY);
        if (runContext == null) {
            IssueOutput.error("Could not find run context. Please try again").submit(context);
            return false;
        }
        BlazeAndroidDeviceSelector.DeviceSession deviceSession = env.getCopyableUserData(DEVICE_SESSION_KEY);
        ApkBuildStep buildStep = runContext.getBuildStep();
        ScopedTask<Void> buildTask = new ScopedTask<Void>(context) {

            @Override
            protected Void execute(BlazeContext context) {
                buildStep.build(context, deviceSession);
                return null;
            }
        };
        try {
            ListenableFuture<Void> buildFuture = ProgressiveTaskWithProgressIndicator.builder(project, String.format("Executing %s apk build", Blaze.buildSystemName(project))).submitTaskWithResult(buildTask);
            Futures.getChecked(buildFuture, ExecutionException.class);
        } catch (ExecutionException e) {
            context.setHasError();
        } catch (CancellationException e) {
            context.setCancelled();
        } catch (Exception e) {
            LOG.error(e);
            return false;
        }
        return context.shouldContinue();
    });
}
Also used : IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ScopedTask(com.google.idea.blaze.base.scope.ScopedTask) Task(com.google.idea.blaze.base.toolwindow.Task) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) ToolWindowScope(com.google.idea.blaze.base.scope.scopes.ToolWindowScope) ExecutionException(com.intellij.execution.ExecutionException) CancellationException(java.util.concurrent.CancellationException) ScopedTask(com.google.idea.blaze.base.scope.ScopedTask) Project(com.intellij.openapi.project.Project) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeUserSettings(com.google.idea.blaze.base.settings.BlazeUserSettings) ProblemsViewScope(com.google.idea.blaze.base.scope.scopes.ProblemsViewScope) CancellationException(java.util.concurrent.CancellationException) ExecutionException(com.intellij.execution.ExecutionException)

Example 7 with Task

use of com.google.idea.blaze.base.toolwindow.Task in project intellij by bazelbuild.

the class FastBuildConfigurationRunner method executeBeforeRunTask.

@Override
public boolean executeBeforeRunTask(ExecutionEnvironment env) {
    if (!canRun(env.getRunProfile())) {
        return true;
    }
    Project project = env.getProject();
    BlazeCommandRunConfiguration configuration = BlazeCommandRunConfigurationRunner.getBlazeConfig(env.getRunProfile());
    BlazeCommandRunConfigurationCommonState handlerState = (BlazeCommandRunConfigurationCommonState) configuration.getHandler().getState();
    checkState(configuration.getSingleTarget() != null);
    Label label = (Label) configuration.getSingleTarget();
    String binaryPath = handlerState.getBlazeBinaryState().getBlazeBinary() != null ? handlerState.getBlazeBinaryState().getBlazeBinary() : Blaze.getBuildSystemProvider(project).getBinaryPath(project);
    SaveUtil.saveAllFiles();
    FastBuildService buildService = FastBuildService.getInstance(project);
    Future<FastBuildInfo> buildFuture = null;
    FocusBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getShowBlazeConsoleOnRun();
    FocusBehavior problemsViewFocus = BlazeUserSettings.getInstance().getShowProblemsViewOnRun();
    BlazeContext context = BlazeContext.create().push(new ToolWindowScope.Builder(project, new Task(project, "Fast Build " + label.targetName(), Task.Type.FAST_BUILD)).setPopupBehavior(consolePopupBehavior).setIssueParsers(BlazeIssueParser.defaultIssueParsers(project, WorkspaceRoot.fromProject(project), ContextType.RunConfiguration)).build()).push(new ProblemsViewScope(project, problemsViewFocus)).push(new IdeaLogScope()).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), ContextType.RunConfiguration, /* linkToBlazeConsole= */
    true)).build()).push(new FastBuildLogDataScope());
    try {
        buildFuture = buildService.createBuild(context, label, binaryPath, handlerState.getBlazeFlagsState().getFlagsForExternalProcesses());
        FastBuildInfo fastBuildInfo = buildFuture.get();
        env.getCopyableUserData(BUILD_INFO_KEY).set(fastBuildInfo);
        env.getCopyableUserData(BLAZE_CONTEXT).set(context);
        return true;
    } catch (InterruptedException e) {
        buildFuture.cancel(/* mayInterruptIfRunning= */
        true);
        Thread.currentThread().interrupt();
    } catch (CancellationException e) {
        ExecutionUtil.handleExecutionError(env.getProject(), env.getExecutor().getToolWindowId(), env.getRunProfile(), new RunCanceledByUserException());
    } catch (FastBuildException e) {
        if (!(e instanceof BlazeBuildError)) {
            // no need to log blaze build errors; they're expected
            logger.warn(e);
        }
        ExecutionUtil.handleExecutionError(env, new ExecutionException(e));
    } catch (java.util.concurrent.ExecutionException e) {
        logger.warn(e);
        if (e.getCause() instanceof FastBuildIncrementalCompileException) {
            handleJavacError(env, project, label, buildService, (FastBuildIncrementalCompileException) e.getCause());
        } else {
            ExecutionUtil.handleExecutionError(env, new ExecutionException(e.getCause()));
        }
    }
    // Fall-through for all exceptions. If no exception was thrown, we return from the try{} block.
    context.endScope();
    return false;
}
Also used : BlazeCommandRunConfigurationCommonState(com.google.idea.blaze.base.run.state.BlazeCommandRunConfigurationCommonState) Task(com.google.idea.blaze.base.toolwindow.Task) Label(com.google.idea.blaze.base.model.primitives.Label) FastBuildService(com.google.idea.blaze.java.fastbuild.FastBuildService) RunCanceledByUserException(com.intellij.execution.RunCanceledByUserException) FastBuildLogDataScope(com.google.idea.blaze.java.fastbuild.FastBuildLogDataScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) FastBuildException(com.google.idea.blaze.java.fastbuild.FastBuildException) ExecutionException(com.intellij.execution.ExecutionException) BlazeCommandRunConfiguration(com.google.idea.blaze.base.run.BlazeCommandRunConfiguration) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) FastBuildIncrementalCompileException(com.google.idea.blaze.java.fastbuild.FastBuildIncrementalCompileException) FocusBehavior(com.google.idea.blaze.base.settings.BlazeUserSettings.FocusBehavior) Project(com.intellij.openapi.project.Project) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) FastBuildInfo(com.google.idea.blaze.java.fastbuild.FastBuildInfo) ProblemsViewScope(com.google.idea.blaze.base.scope.scopes.ProblemsViewScope) CancellationException(java.util.concurrent.CancellationException) BlazeBuildError(com.google.idea.blaze.java.fastbuild.FastBuildException.BlazeBuildError)

Example 8 with Task

use of com.google.idea.blaze.base.toolwindow.Task in project intellij by bazelbuild.

the class SyncPhaseCoordinator method queueUpdateTask.

private void queueUpdateTask(UpdatePhaseTask task, @Nullable ToolWindowScope syncToolWindowScope, BlazeSyncParams params) {
    synchronized (this) {
        if (pendingUpdateTask != null) {
            // there's already a pending job, no need to kick off another one
            pendingUpdateTask = UpdatePhaseTask.combineTasks(pendingUpdateTask, task);
            return;
        }
        pendingUpdateTask = task;
    }
    Task toolWindowTask;
    boolean startTaskOnScopeBegin;
    if (syncToolWindowScope == null) {
        toolWindowTask = new Task(params.title(), Task.Type.BLAZE_SYNC);
        startTaskOnScopeBegin = true;
    } else {
        toolWindowTask = syncToolWindowScope.getTask();
        syncToolWindowScope.setFinishTaskOnScopeEnd(false);
        startTaskOnScopeBegin = false;
    }
    ProgressiveTaskWithProgressIndicator.builder(project, "Syncing Project").setExecutor(singleThreadedExecutor).submitTaskLater(indicator -> Scope.root(context -> {
        UpdatePhaseTask updateTask = getAndClearPendingTask();
        setupScopes(updateTask.syncParams(), context, indicator, SyncPhase.PROJECT_UPDATE, toolWindowTask, startTaskOnScopeBegin);
        updateProjectAndFinishSync(updateTask, context);
    }));
}
Also used : ProblemsViewScope(com.google.idea.blaze.base.scope.scopes.ProblemsViewScope) ModuleFinder(com.google.idea.blaze.base.sync.projectstructure.ModuleFinder) BuildResult(com.google.idea.blaze.base.sync.aspects.BuildResult) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) Future(java.util.concurrent.Future) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) Map(java.util.Map) SaveUtil(com.google.idea.blaze.base.util.SaveUtil) AppExecutorUtil(com.intellij.util.concurrency.AppExecutorUtil) Task(com.google.idea.blaze.base.toolwindow.Task) Logger(com.intellij.openapi.diagnostic.Logger) Module(com.intellij.openapi.module.Module) Blaze(com.google.idea.blaze.base.settings.Blaze) ImmutableSet(com.google.common.collect.ImmutableSet) Predicate(java.util.function.Predicate) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) Instant(java.time.Instant) GuardedBy(javax.annotation.concurrent.GuardedBy) Collectors.joining(java.util.stream.Collectors.joining) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) Executors(java.util.concurrent.Executors) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ProjectTargetData(com.google.idea.blaze.base.model.ProjectTargetData) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) FocusBehavior(com.google.idea.blaze.base.settings.BlazeUserSettings.FocusBehavior) ServiceManager(com.intellij.openapi.components.ServiceManager) ImportSection(com.google.idea.blaze.base.projectview.section.sections.ImportSection) AutoValue(com.google.auto.value.AutoValue) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) BlazeProjectDataManagerImpl(com.google.idea.blaze.base.sync.data.BlazeProjectDataManagerImpl) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) ToolWindowScope(com.google.idea.blaze.base.scope.scopes.ToolWindowScope) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) NotificationScope(com.google.idea.blaze.base.scope.scopes.NotificationScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) TimedEvent(com.google.idea.blaze.base.scope.scopes.TimingScopeListener.TimedEvent) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ContextType(com.google.idea.blaze.base.command.BlazeInvocationContext.ContextType) PerformanceWarningScope(com.google.idea.blaze.base.scope.scopes.PerformanceWarningScope) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) SyncStats(com.google.idea.blaze.base.logging.utils.SyncStats) ProgressIndicatorScope(com.google.idea.blaze.base.scope.scopes.ProgressIndicatorScope) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ImmutableList(com.google.common.collect.ImmutableList) Scope(com.google.idea.blaze.base.scope.Scope) BlazeDataStorage(com.google.idea.blaze.base.sync.data.BlazeDataStorage) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) Project(com.intellij.openapi.project.Project) Nullable(javax.annotation.Nullable) BlazeLibraryCollector(com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector) BlazeImportSettingsManager(com.google.idea.blaze.base.settings.BlazeImportSettingsManager) BlazeImportSettings(com.google.idea.blaze.base.settings.BlazeImportSettings) SyncFailedException(com.google.idea.blaze.base.sync.SyncScope.SyncFailedException) BlazeUserSettings(com.google.idea.blaze.base.settings.BlazeUserSettings) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) ConcurrencyUtil(com.google.idea.common.util.ConcurrencyUtil) BlazeIssueParser(com.google.idea.blaze.base.issueparser.BlazeIssueParser) EventLoggingService(com.google.idea.blaze.base.logging.EventLoggingService) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ProgressiveTaskWithProgressIndicator(com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) Task(com.google.idea.blaze.base.toolwindow.Task)

Example 9 with Task

use of com.google.idea.blaze.base.toolwindow.Task in project intellij by bazelbuild.

the class BlazeBuildService method buildTargetExpressions.

private static void buildTargetExpressions(Project project, ProjectViewSet projectView, BlazeProjectData projectData, ScopedFunction<List<TargetExpression>> targetsFunction, NotificationScope notificationScope, String taskName) {
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        // this never being called *and* relied on PROJECT_LAST_BUILD_TIMESTAMP_KEY being set
        return;
    }
    FocusBehavior problemsViewFocus = BlazeUserSettings.getInstance().getShowProblemsViewOnRun();
    // go/futurereturn-lsc
    @SuppressWarnings("unused") Future<?> possiblyIgnoredError = ProgressiveTaskWithProgressIndicator.builder(project, "Building targets").submitTaskWithResult(new ScopedTask<Void>() {

        @Override
        public Void execute(BlazeContext context) {
            Task task = new Task(taskName, Task.Type.BLAZE_MAKE);
            context.push(new ToolWindowScope.Builder(project, task).setIssueParsers(BlazeIssueParser.defaultIssueParsers(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.ContextType.Sync)).build()).push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.ContextType.Sync, true)).build()).push(new ProblemsViewScope(project, problemsViewFocus)).push(new IdeaLogScope()).push(new TimingScope("Make", EventType.BlazeInvocation)).push(notificationScope);
            List<TargetExpression> targets = targetsFunction.execute(context);
            if (targets == null) {
                return null;
            }
            BlazeBuildParams buildParams = BlazeBuildParams.fromProject(project);
            WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
            SaveUtil.saveAllFiles();
            BlazeBuildListener.EP_NAME.extensions().forEach(e -> e.buildStarting(project));
            ShardedTargetsResult shardedTargets = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, buildParams, projectView, projectData.getWorkspacePathResolver(), targets);
            if (shardedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
                return null;
            }
            BlazeBuildOutputs buildOutputs = BlazeIdeInterface.getInstance().build(project, context, workspaceRoot, projectData.getBlazeVersionData(), buildParams, projectView, projectData.getBlazeInfo(), shardedTargets.shardedTargets, projectData.getWorkspaceLanguageSettings(), ImmutableSet.of(OutputGroup.COMPILE));
            refreshFileCachesAndNotifyListeners(context, buildOutputs, project);
            if (buildOutputs.buildResult.status != BuildResult.Status.SUCCESS) {
                context.setHasError();
            }
            return null;
        }
    });
}
Also used : BlazeIdeInterface(com.google.idea.blaze.base.sync.aspects.BlazeIdeInterface) ProblemsViewScope(com.google.idea.blaze.base.scope.scopes.ProblemsViewScope) ImmutableCollection(com.google.common.collect.ImmutableCollection) ScopedFunction(com.google.idea.blaze.base.scope.ScopedFunction) BuildResult(com.google.idea.blaze.base.sync.aspects.BuildResult) ProjectViewManager(com.google.idea.blaze.base.projectview.ProjectViewManager) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) Future(java.util.concurrent.Future) ScopedTask(com.google.idea.blaze.base.scope.ScopedTask) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) BlazeBuildParams(com.google.idea.blaze.base.sync.BlazeBuildParams) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) SaveUtil(com.google.idea.blaze.base.util.SaveUtil) Task(com.google.idea.blaze.base.toolwindow.Task) BlazeBuildOutputs(com.google.idea.blaze.base.sync.aspects.BlazeBuildOutputs) Blaze(com.google.idea.blaze.base.settings.Blaze) ImmutableSet(com.google.common.collect.ImmutableSet) BlazeProjectDataManager(com.google.idea.blaze.base.sync.data.BlazeProjectDataManager) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) List(java.util.List) FocusBehavior(com.google.idea.blaze.base.settings.BlazeUserSettings.FocusBehavior) ServiceManager(com.intellij.openapi.components.ServiceManager) FileCaches(com.google.idea.blaze.base.filecache.FileCaches) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) ApplicationManager(com.intellij.openapi.application.ApplicationManager) ToolWindowScope(com.google.idea.blaze.base.scope.scopes.ToolWindowScope) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) NotificationScope(com.google.idea.blaze.base.scope.scopes.NotificationScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SyncCanceledException(com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException) Lists(com.google.common.collect.Lists) OutputGroup(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup) SyncProjectTargetsHelper(com.google.idea.blaze.base.sync.SyncProjectTargetsHelper) Project(com.intellij.openapi.project.Project) BlazeBuildTargetSharder(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder) Nullable(javax.annotation.Nullable) Key(com.intellij.openapi.util.Key) FutureCallback(com.google.common.util.concurrent.FutureCallback) SyncFailedException(com.google.idea.blaze.base.sync.SyncScope.SyncFailedException) Futures(com.google.common.util.concurrent.Futures) Label(com.google.idea.blaze.base.model.primitives.Label) BlazeUserSettings(com.google.idea.blaze.base.settings.BlazeUserSettings) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeIssueParser(com.google.idea.blaze.base.issueparser.BlazeIssueParser) ProgressiveTaskWithProgressIndicator(com.google.idea.blaze.base.async.executor.ProgressiveTaskWithProgressIndicator) BlazeInvocationContext(com.google.idea.blaze.base.command.BlazeInvocationContext) ShardedTargetsResult(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) BlazeBuildParams(com.google.idea.blaze.base.sync.BlazeBuildParams) ShardedTargetsResult(com.google.idea.blaze.base.sync.sharding.BlazeBuildTargetSharder.ShardedTargetsResult) ScopedTask(com.google.idea.blaze.base.scope.ScopedTask) Task(com.google.idea.blaze.base.toolwindow.Task) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) ExperimentScope(com.google.idea.blaze.base.experiments.ExperimentScope) FocusBehavior(com.google.idea.blaze.base.settings.BlazeUserSettings.FocusBehavior) BlazeBuildOutputs(com.google.idea.blaze.base.sync.aspects.BlazeBuildOutputs) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) IdeaLogScope(com.google.idea.blaze.base.scope.scopes.IdeaLogScope) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) ProblemsViewScope(com.google.idea.blaze.base.scope.scopes.ProblemsViewScope) List(java.util.List)

Example 10 with Task

use of com.google.idea.blaze.base.toolwindow.Task in project intellij by bazelbuild.

the class BlazeIdeInterfaceAspectsImpl method build.

@Override
public BlazeBuildOutputs build(Project project, BlazeContext context, WorkspaceRoot workspaceRoot, BlazeVersionData blazeVersion, BlazeBuildParams buildParams, ProjectViewSet projectViewSet, BlazeInfo blazeInfo, ShardedTargetList shardedTargets, WorkspaceLanguageSettings workspaceLanguageSettings, ImmutableSet<OutputGroup> outputGroups) {
    AspectStrategy aspectStrategy = AspectStrategy.getInstance(blazeVersion);
    final Ref<BlazeBuildOutputs> combinedResult = new Ref<>();
    boolean parallelize = buildParams.parallelizeBuilds();
    // The build is a sync iff INFO output group is present
    boolean isSync = outputGroups.contains(OutputGroup.INFO);
    Function<Integer, String> progressMessage = count -> String.format("Building targets for shard %s of %s...", count, shardedTargets.shardCount());
    final ShardedBuildProgressTracker progressTracker = new ShardedBuildProgressTracker(shardedTargets.shardCount());
    BiFunction<List<? extends TargetExpression>, Integer, BuildResult> invocation = (targets, shard) -> Scope.push(context, (childContext) -> {
        setupToolWindow(project, context, childContext, workspaceRoot, "Build shard " + shard, isSync);
        // we use context (rather than childContext) here since the shard state relates
        // to the parent task (which encapsulates all the build shards).
        progressTracker.onBuildStarted(context);
        BlazeBuildOutputs result = runBuildForTargets(project, childContext, workspaceRoot, buildParams, projectViewSet, blazeInfo, workspaceLanguageSettings.getActiveLanguages(), targets, aspectStrategy, outputGroups);
        // TODO(b/216104482) track failures
        progressTracker.onBuildCompleted(context);
        if (!result.buildResult.outOfMemory()) {
            combinedResult.set(combinedResult.isNull() ? result : combinedResult.get().updateOutputs(result));
        }
        return result.buildResult;
    });
    BuildResult buildResult = shardedTargets.runShardedCommand(project, context, progressMessage, invocation, parallelize);
    if (combinedResult.isNull() || buildResult.status == Status.FATAL_ERROR) {
        return BlazeBuildOutputs.noOutputs(buildResult);
    }
    return combinedResult.get();
}
Also used : AdditionalLanguagesHelper(com.google.idea.blaze.base.lang.AdditionalLanguagesHelper) LanguageSupport(com.google.idea.blaze.base.sync.projectview.LanguageSupport) PrefetchService(com.google.idea.blaze.base.prefetch.PrefetchService) BlazeProjectData(com.google.idea.blaze.base.model.BlazeProjectData) BlazeConsoleScope(com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope) BlazeBuildParams(com.google.idea.blaze.base.sync.BlazeBuildParams) Map(java.util.Map) Task(com.google.idea.blaze.base.toolwindow.Task) FileUtil(com.intellij.openapi.util.io.FileUtil) SyncProjectState(com.google.idea.blaze.base.sync.SyncProjectState) Blaze(com.google.idea.blaze.base.settings.Blaze) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Set(java.util.Set) RemoteArtifactPrefetcher(com.google.idea.blaze.base.prefetch.RemoteArtifactPrefetcher) BuildResultHelper(com.google.idea.blaze.base.command.buildresult.BuildResultHelper) PrintOutput(com.google.idea.blaze.base.scope.output.PrintOutput) BlazeArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact) OutputArtifact(com.google.idea.blaze.base.command.buildresult.OutputArtifact) ProjectTargetData(com.google.idea.blaze.base.model.ProjectTargetData) Status(com.google.idea.blaze.base.sync.aspects.BuildResult.Status) ProjectViewSet(com.google.idea.blaze.base.projectview.ProjectViewSet) BlazeInfo(com.google.idea.blaze.base.command.info.BlazeInfo) ToolWindowScope(com.google.idea.blaze.base.scope.scopes.ToolWindowScope) Joiner(com.google.common.base.Joiner) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) BlazeContext(com.google.idea.blaze.base.scope.BlazeContext) StatusOutput(com.google.idea.blaze.base.scope.output.StatusOutput) ArrayList(java.util.ArrayList) NavigatableAdapter(com.intellij.pom.NavigatableAdapter) ArtifactsDiff(com.google.idea.blaze.base.filecache.ArtifactsDiff) Kind(com.google.idea.blaze.base.model.primitives.Kind) Lists(com.google.common.collect.Lists) ArtifactState(com.google.idea.blaze.base.filecache.ArtifactState) Scope(com.google.idea.blaze.base.scope.Scope) BoolExperiment(com.google.idea.common.experiments.BoolExperiment) IssueOutput(com.google.idea.blaze.base.scope.output.IssueOutput) ImmutableSet.toImmutableSet(com.google.common.collect.ImmutableSet.toImmutableSet) TargetIdeInfo(com.google.idea.blaze.base.ideinfo.TargetIdeInfo) LinkedHashSet(java.util.LinkedHashSet) Nullable(javax.annotation.Nullable) ImportRoots(com.google.idea.blaze.base.sync.projectview.ImportRoots) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) BlazeExecutor(com.google.idea.blaze.base.async.executor.BlazeExecutor) AtomicLong(java.util.concurrent.atomic.AtomicLong) Futures(com.google.common.util.concurrent.Futures) BlazeVersionData(com.google.idea.blaze.base.model.BlazeVersionData) BlazeConfigurationHandler(com.google.idea.blaze.base.command.info.BlazeConfigurationHandler) BlazeFlags(com.google.idea.blaze.base.command.BlazeFlags) BlazeInvocationContext(com.google.idea.blaze.base.command.BlazeInvocationContext) BlazeConsoleExperimentManager(com.google.idea.blaze.base.console.BlazeConsoleExperimentManager) BlazeCommand(com.google.idea.blaze.base.command.BlazeCommand) EventType(com.google.idea.blaze.base.scope.scopes.TimingScope.EventType) AutomaticallyDeriveTargetsSection(com.google.idea.blaze.base.projectview.section.sections.AutomaticallyDeriveTargetsSection) Result(com.google.idea.blaze.base.scope.Result) BiFunction(java.util.function.BiFunction) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Logger(com.intellij.openapi.diagnostic.Logger) IntellijIdeInfo(com.google.devtools.intellij.ideinfo.IntellijIdeInfo) BlazeCommandRunner(com.google.idea.blaze.base.command.BlazeCommandRunner) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AspectStrategy(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy) Predicate(java.util.function.Predicate) Collection(java.util.Collection) FutureUtil(com.google.idea.blaze.base.async.FutureUtil) WorkspaceLanguageSettings(com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings) Instant(java.time.Instant) Sets(com.google.common.collect.Sets) BlazeCommandName(com.google.idea.blaze.base.command.BlazeCommandName) Objects(java.util.Objects) IssueOutputFilter(com.google.idea.blaze.base.issueparser.IssueOutputFilter) List(java.util.List) BuildResultHelperProvider(com.google.idea.blaze.base.command.buildresult.BuildResultHelperProvider) WorkspaceRoot(com.google.idea.blaze.base.model.primitives.WorkspaceRoot) TargetKey(com.google.idea.blaze.base.ideinfo.TargetKey) ShardedTargetList(com.google.idea.blaze.base.sync.sharding.ShardedTargetList) Ref(com.intellij.openapi.util.Ref) TargetMap(com.google.idea.blaze.base.ideinfo.TargetMap) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ContextType(com.google.idea.blaze.base.command.BlazeInvocationContext.ContextType) HashMap(java.util.HashMap) Function(java.util.function.Function) HashSet(java.util.HashSet) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ImmutableList(com.google.common.collect.ImmutableList) OutputGroup(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup) Project(com.intellij.openapi.project.Project) RemoteOutputArtifacts(com.google.idea.blaze.base.model.RemoteOutputArtifacts) LanguageClass(com.google.idea.blaze.base.model.primitives.LanguageClass) PerformanceWarning(com.google.idea.blaze.base.scope.output.PerformanceWarning) PrefetchFileSource(com.google.idea.blaze.base.prefetch.PrefetchFileSource) Maps(com.google.common.collect.Maps) ShardedBuildProgressTracker(com.google.idea.blaze.base.sync.sharding.ShardedBuildProgressTracker) Ordering(com.google.common.collect.Ordering) TimingScope(com.google.idea.blaze.base.scope.scopes.TimingScope) BlazeIssueParser(com.google.idea.blaze.base.issueparser.BlazeIssueParser) LocalFileArtifact(com.google.idea.blaze.base.command.buildresult.BlazeArtifact.LocalFileArtifact) ShardedBuildProgressTracker(com.google.idea.blaze.base.sync.sharding.ShardedBuildProgressTracker) TargetExpression(com.google.idea.blaze.base.model.primitives.TargetExpression) Ref(com.intellij.openapi.util.Ref) AspectStrategy(com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ArrayList(java.util.ArrayList) List(java.util.List) ShardedTargetList(com.google.idea.blaze.base.sync.sharding.ShardedTargetList) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

Task (com.google.idea.blaze.base.toolwindow.Task)10 IssueOutputFilter (com.google.idea.blaze.base.issueparser.IssueOutputFilter)9 ToolWindowScope (com.google.idea.blaze.base.scope.scopes.ToolWindowScope)9 BlazeContext (com.google.idea.blaze.base.scope.BlazeContext)8 Project (com.intellij.openapi.project.Project)8 BlazeConsoleScope (com.google.idea.blaze.base.scope.scopes.BlazeConsoleScope)7 WorkspaceRoot (com.google.idea.blaze.base.model.primitives.WorkspaceRoot)6 ProjectViewSet (com.google.idea.blaze.base.projectview.ProjectViewSet)6 ProblemsViewScope (com.google.idea.blaze.base.scope.scopes.ProblemsViewScope)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 BlazeIssueParser (com.google.idea.blaze.base.issueparser.BlazeIssueParser)5 BlazeProjectData (com.google.idea.blaze.base.model.BlazeProjectData)5 IdeaLogScope (com.google.idea.blaze.base.scope.scopes.IdeaLogScope)5 TimingScope (com.google.idea.blaze.base.scope.scopes.TimingScope)5 EventType (com.google.idea.blaze.base.scope.scopes.TimingScope.EventType)5 Blaze (com.google.idea.blaze.base.settings.Blaze)5 Lists (com.google.common.collect.Lists)4 Futures (com.google.common.util.concurrent.Futures)4 BlazeInvocationContext (com.google.idea.blaze.base.command.BlazeInvocationContext)4