use of com.google.idea.blaze.base.bazel.BuildSystem 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, BuildSystem buildSystem) {
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(project, taskName, Task.Type.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;
}
WorkspaceRoot workspaceRoot = WorkspaceRoot.fromProject(project);
SaveUtil.saveAllFiles();
BlazeBuildListener.EP_NAME.extensions().forEach(e -> e.buildStarting(project));
BuildInvoker buildInvoker = buildSystem.getBuildInvoker(project, context);
ShardedTargetsResult shardedTargets = BlazeBuildTargetSharder.expandAndShardTargets(project, context, workspaceRoot, projectView, projectData.getWorkspacePathResolver(), targets, buildInvoker, SyncStrategy.SERIAL);
if (shardedTargets.buildResult.status == BuildResult.Status.FATAL_ERROR) {
return null;
}
BlazeBuildOutputs buildOutputs = BlazeIdeInterface.getInstance().build(project, context, workspaceRoot, projectData.getBlazeVersionData(), buildInvoker, projectView, shardedTargets.shardedTargets, projectData.getWorkspaceLanguageSettings(), ImmutableSet.of(OutputGroup.COMPILE), BlazeInvocationContext.OTHER_CONTEXT);
refreshFileCachesAndNotifyListeners(context, buildOutputs, project);
if (buildOutputs.buildResult.status != BuildResult.Status.SUCCESS) {
context.setHasError();
}
return null;
}
});
}
use of com.google.idea.blaze.base.bazel.BuildSystem in project intellij by bazelbuild.
the class BlazeBuildService method buildProject.
public void buildProject() {
if (!Blaze.isBlazeProject(project)) {
return;
}
ProjectViewSet projectView = ProjectViewManager.getInstance(project).getProjectViewSet();
BlazeProjectData projectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData();
if (projectView == null || projectData == null) {
return;
}
ScopedFunction<List<TargetExpression>> targets = context -> {
try {
return SyncProjectTargetsHelper.getProjectTargets(project, context, projectView, projectData.getWorkspacePathResolver(), projectData.getWorkspaceLanguageSettings()).getTargetsToSync();
} catch (SyncCanceledException e) {
context.setCancelled();
return null;
} catch (SyncFailedException e) {
context.setHasError();
return null;
}
};
buildTargetExpressions(project, projectView, projectData, targets, new NotificationScope(project, "Make", "Make project", "Make project completed successfully", "Make project failed"), "Make project", buildSystem);
// In case the user touched a file, but didn't change its content. The user will get a false
// positive for class file out of date. We need a way for the user to suppress the false
// message. Clicking the "build project" link should at least make the message go away.
project.putUserData(PROJECT_LAST_BUILD_TIMESTAMP_KEY, System.currentTimeMillis());
}
Aggregations