diff --git a/base/src/com/google/idea/blaze/base/sync/BlazeBuildParams.java b/base/src/com/google/idea/blaze/base/sync/BlazeBuildParams.java index 14bde24af50..22868cdb967 100644 --- a/base/src/com/google/idea/blaze/base/sync/BlazeBuildParams.java +++ b/base/src/com/google/idea/blaze/base/sync/BlazeBuildParams.java @@ -36,6 +36,7 @@ public static BlazeBuildParams fromProject(Project project) { .setBlazeBinaryPath(provider.getSyncBinaryPath(project)) .setBlazeBinaryType(binaryType) .setParallelizeBuilds(parallelizeRemoteSyncs.getValue() && binaryType.isRemote) + .setInfoOnly(false) .build(); } @@ -43,6 +44,10 @@ public static BlazeBuildParams fromProject(Project project) { public abstract BuildBinaryType blazeBinaryType(); + public abstract boolean infoOnly(); + + public abstract Builder toBuilder(); + /** * Whether batched build invocations are run in parallel, when possible (only when building * remotely). @@ -61,6 +66,8 @@ public abstract static class Builder { public abstract Builder setBlazeBinaryType(BuildBinaryType value); + public abstract Builder setInfoOnly(boolean value); + // not public; derived from BuildBinaryType abstract Builder setParallelizeBuilds(boolean parallelizeBuilds); diff --git a/base/src/com/google/idea/blaze/base/sync/SyncPhaseCoordinator.java b/base/src/com/google/idea/blaze/base/sync/SyncPhaseCoordinator.java index 92bffc53bac..0c91498e3f3 100644 --- a/base/src/com/google/idea/blaze/base/sync/SyncPhaseCoordinator.java +++ b/base/src/com/google/idea/blaze/base/sync/SyncPhaseCoordinator.java @@ -362,6 +362,10 @@ void runSync(BlazeSyncParams params, boolean singleThreaded, BlazeContext contex projectState != null ? BuildPhaseSyncTask.runBuildPhase(project, params, projectState, buildId, context) : BlazeSyncBuildResult.builder().build(); + //If we have partial success we'll run the build again this time only with intellij-info-java + if (projectState != null && syncResultFromBuildPhase(buildResult, context) == SyncResult.PARTIAL_SUCCESS) { + buildResult = syncInfoOnly(params, context, buildId, projectState, buildResult); + } UpdatePhaseTask task = UpdatePhaseTask.builder() .setStartTime(startTime) @@ -389,6 +393,25 @@ void runSync(BlazeSyncParams params, boolean singleThreaded, BlazeContext contex } } + private BlazeSyncBuildResult syncInfoOnly(BlazeSyncParams params, BlazeContext context, + int buildId, SyncProjectState projectState, BlazeSyncBuildResult buildResult) { + final BlazeSyncParams infoOnlySyncParams = params.toBuilder().setBlazeBuildParams( + params.blazeBuildParams().toBuilder().setInfoOnly(true).build() + ).build(); + final BlazeSyncBuildResult infoOnlySyncResult = BuildPhaseSyncTask + .runBuildPhase(project, infoOnlySyncParams, projectState, buildId, context); + /* + * updateResult should be used the other way around [ olderRun.updateResult(newerRun) ] + * since that is used to remove stale/old artifacts from targets which boths runs "saw" + * In our case both runs are sequential without artifacts changing. + * The second run only has IDE-INFO files + * For every target the first run was able to process it has all the data (first run does IDE-INFO and Resolve) + * What happens when we updateResult as below is that we basically just add the IDE-INFO files + * of the broken targets from the second run into the first run + */ + return infoOnlySyncResult.updateResult(buildResult); + } + private void queueUpdateTask(UpdatePhaseTask task) { synchronized (this) { if (pendingUpdateTask != null) { diff --git a/base/src/com/google/idea/blaze/base/sync/aspects/BlazeIdeInterfaceAspectsImpl.java b/base/src/com/google/idea/blaze/base/sync/aspects/BlazeIdeInterfaceAspectsImpl.java index e2eab60ed1f..cdc00268f55 100644 --- a/base/src/com/google/idea/blaze/base/sync/aspects/BlazeIdeInterfaceAspectsImpl.java +++ b/base/src/com/google/idea/blaze/base/sync/aspects/BlazeIdeInterfaceAspectsImpl.java @@ -373,7 +373,9 @@ private static BlazeBuildOutputs runBuildForTargets( aspectStrategy.addAspectAndOutputGroups( builder, - ImmutableList.of(OutputGroup.INFO, OutputGroup.RESOLVE), + buildParams.infoOnly() ? + ImmutableList.of(OutputGroup.INFO): + ImmutableList.of(OutputGroup.INFO, OutputGroup.RESOLVE), activeLanguages, onlyDirectDeps);