use of com.google.idea.blaze.base.scope.scopes.IdeaLogScope in project intellij by bazelbuild.
the class BlazeBuildService method buildTargetExpressions.
@VisibleForTesting
void buildTargetExpressions(Project project, List<TargetExpression> targets, ProjectViewSet projectViewSet, NotificationScope notificationScope) {
if (targets.isEmpty() || projectViewSet == null) {
return;
}
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (blazeProjectData == null) {
return;
}
// go/futurereturn-lsc
@SuppressWarnings("unused") Future<?> possiblyIgnoredError = ProgressiveTaskWithProgressIndicator.builder(project).setTitle("Building targets").submitTaskWithResult(new ScopedTask<Void>() {
@Override
public Void execute(BlazeContext context) {
context.push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.Sync, true)).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope()).push(new TimingScope("Make", EventType.BlazeInvocation)).push(notificationScope);
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
SaveUtil.saveAllFiles();
ShardedTargetsResult shardedTargets = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, projectViewSet, blazeProjectData.workspacePathResolver, targets);
if (shardedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
return null;
}
BuildResult buildResult = BlazeIdeInterface.getInstance().compileIdeArtifacts(project, context, workspaceRoot, projectViewSet, blazeProjectData.blazeVersionData, blazeProjectData.workspaceLanguageSettings, shardedTargets.shardedTargets);
FileCaches.refresh(project);
if (buildResult.status != BuildResult.Status.SUCCESS) {
context.setHasError();
}
return null;
}
});
}
use of com.google.idea.blaze.base.scope.scopes.IdeaLogScope in project intellij by bazelbuild.
the class BlazeJavaRunProfileState method startProcess.
@Override
protected ProcessHandler startProcess() throws ExecutionException {
Project project = configuration.getProject();
BlazeCommand.Builder blazeCommand;
BlazeTestUiSession testUiSession = useTestUi() ? TestUiSessionProvider.getInstance(project).getTestUiSession(configuration.getTarget()) : null;
if (testUiSession != null) {
blazeCommand = getBlazeCommandBuilder(project, configuration, testUiSession.getBlazeFlags(), executorType);
setConsoleBuilder(new TextConsoleBuilderImpl(project) {
@Override
protected ConsoleView createConsole() {
return SmRunnerUtils.getConsoleView(project, configuration, getEnvironment().getExecutor(), testUiSession);
}
});
} else {
blazeCommand = getBlazeCommandBuilder(project, configuration, ImmutableList.of(), executorType);
}
addConsoleFilters(new BlazeTargetFilter(project, true), new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.NonSync, false));
List<String> command = HotSwapUtils.canHotSwap(getEnvironment()) ? getBashCommandsToRunScript(blazeCommand) : blazeCommand.build().toList();
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
return new ScopedBlazeProcessHandler(project, command, workspaceRoot, new ScopedBlazeProcessHandler.ScopedProcessHandlerDelegate() {
@Override
public void onBlazeContextStart(BlazeContext context) {
context.push(new IssuesScope(project, BlazeUserSettings.getInstance().getShowProblemsViewForRunAction())).push(new IdeaLogScope());
}
@Override
public ImmutableList<ProcessListener> createProcessListeners(BlazeContext context) {
LineProcessingOutputStream outputStream = LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context));
return ImmutableList.of(new LineProcessingProcessAdapter(outputStream));
}
});
}
use of com.google.idea.blaze.base.scope.scopes.IdeaLogScope in project intellij by bazelbuild.
the class BuildPluginBeforeRunTaskProvider method executeTask.
@Override
public final boolean executeTask(final DataContext dataContext, final RunConfiguration configuration, final ExecutionEnvironment env, Task task) {
if (!canExecuteTask(configuration, task)) {
return false;
}
BlazeConsolePopupBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getSuppressConsoleForRunAction() ? BlazeConsolePopupBehavior.NEVER : BlazeConsolePopupBehavior.ALWAYS;
return Scope.root(context -> {
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
context.push(new ExperimentScope()).push(new IssuesScope(project, true)).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, workspaceRoot, BlazeInvocationContext.NonSync, true)).build()).push(new IdeaLogScope());
BlazeIntellijPluginDeployer deployer = env.getUserData(BlazeIntellijPluginDeployer.USER_DATA_KEY);
if (deployer == null) {
IssueOutput.error("Could not find BlazeIntellijPluginDeployer in env.").submit(context);
return false;
}
deployer.buildStarted();
final ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet();
if (projectViewSet == null) {
IssueOutput.error("Could not load project view. Please resync project").submit(context);
return false;
}
final ScopedTask<Void> buildTask = new ScopedTask<Void>(context) {
@Override
protected Void execute(BlazeContext context) {
String binaryPath = Blaze.getBuildSystemProvider(project).getBinaryPath();
BlazeIntellijPluginConfiguration config = (BlazeIntellijPluginConfiguration) configuration;
ListenableFuture<String> executionRootFuture = BlazeInfoRunner.getInstance().runBlazeInfo(context, binaryPath, workspaceRoot, config.getBlazeFlagsState().getExpandedFlags(), BlazeInfo.EXECUTION_ROOT_KEY);
String executionRoot;
try {
executionRoot = executionRootFuture.get();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
context.setCancelled();
return null;
} catch (ExecutionException e) {
IssueOutput.error(e.getMessage()).submit(context);
context.setHasError();
return null;
}
if (executionRoot == null) {
IssueOutput.error("Could not determine execution root").submit(context);
return null;
}
BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (blazeProjectData == null) {
IssueOutput.error("Could not determine execution root").submit(context);
return null;
}
try (BuildResultHelper buildResultHelper = BuildResultHelper.forFiles(f -> true)) {
BlazeCommand command = BlazeCommand.builder(binaryPath, BlazeCommandName.BUILD).addTargets(config.getTarget()).addBlazeFlags(BlazeFlags.blazeFlags(project, projectViewSet, BlazeCommandName.BUILD, BlazeInvocationContext.NonSync)).addBlazeFlags(config.getBlazeFlagsState().getExpandedFlags()).addExeFlags(config.getExeFlagsState().getExpandedFlags()).addBlazeFlags(buildResultHelper.getBuildFlags()).build();
if (command == null || context.hasErrors() || context.isCancelled()) {
return null;
}
SaveUtil.saveAllFiles();
int retVal = ExternalTask.builder(workspaceRoot).addBlazeCommand(command).context(context).stderr(LineProcessingOutputStream.of(BlazeConsoleLineProcessorProvider.getAllStderrLineProcessors(context))).build().run();
if (retVal != 0) {
context.setHasError();
}
FileCaches.refresh(project);
deployer.reportBuildComplete(new File(executionRoot), buildResultHelper);
return null;
}
}
};
ListenableFuture<Void> buildFuture = ProgressiveTaskWithProgressIndicator.builder(project).setTitle("Executing blaze build for IntelliJ plugin jar").submitTaskWithResult(buildTask);
try {
Futures.getChecked(buildFuture, ExecutionException.class);
} catch (ExecutionException e) {
context.setHasError();
} catch (CancellationException e) {
context.setCancelled();
}
if (context.hasErrors() || context.isCancelled()) {
return false;
}
return true;
});
}
use of com.google.idea.blaze.base.scope.scopes.IdeaLogScope in project intellij by bazelbuild.
the class BlazeAndroidRunConfigurationRunner method executeBeforeRunTask.
@Override
public boolean executeBeforeRunTask(ExecutionEnvironment env) {
final Project project = env.getProject();
BlazeConsolePopupBehavior consolePopupBehavior = BlazeUserSettings.getInstance().getSuppressConsoleForRunAction() ? BlazeConsolePopupBehavior.NEVER : BlazeConsolePopupBehavior.ALWAYS;
return Scope.root(context -> {
context.push(new IssuesScope(project, true)).push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).setPopupBehavior(consolePopupBehavior).addConsoleFilters(new IssueOutputFilter(project, WorkspaceRoot.fromProject(project), BlazeInvocationContext.NonSync, true)).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);
BlazeApkBuildStep buildStep = runContext.getBuildStep();
try {
return buildStep.build(context, deviceSession);
} catch (Exception e) {
LOG.error(e);
return false;
}
});
}
use of com.google.idea.blaze.base.scope.scopes.IdeaLogScope in project intellij by bazelbuild.
the class NewBlazeRuleAction method actionPerformedInBlazeProject.
@Override
protected void actionPerformedInBlazeProject(Project project, AnActionEvent event) {
final VirtualFile virtualFile = event.getData(CommonDataKeys.VIRTUAL_FILE);
if (virtualFile == null) {
return;
}
Scope.root(context -> {
context.push(new ExperimentScope()).push(new BlazeConsoleScope.Builder(project).build()).push(new IssuesScope(project, true)).push(new IdeaLogScope());
NewBlazeRuleDialog newBlazeRuleDialog = new NewBlazeRuleDialog(project, virtualFile);
newBlazeRuleDialog.show();
});
}
Aggregations