Skip to content

Commit

Permalink
fixed aspect_template reference in java_classpath aspect (#7265)
Browse files Browse the repository at this point in the history
One intellij_aspect_template reference was left in java_classpath.bzl causing it to fail at runtime. Also, just to make sure the aspects are present, call AspectStorageService.prepare before using them.

(cherry picked from commit 5d1b741)
  • Loading branch information
LeFrosch authored and mai93 committed Jan 31, 2025
1 parent 966488e commit 225a1dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion aspect/java_classpath.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""An aspect which extracts the runtime classpath from a java target."""

load("@intellij_aspect_template//:java_info.bzl", "get_java_info", "java_info_in_target")
load(":java_info.bzl", "get_java_info", "java_info_in_target")

def _runtime_classpath_impl(target, ctx):
"""The top level aspect implementation function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class AspectStorageService(private val project: Project, private val scope: Coro
* Register a [AspectWriter] to provide aspect files.
*/
@Throws(SyncFailedException::class)
fun prepare(parentCtx: BlazeContext) {
val parentScope = parentCtx.getScope(ToolWindowScope::class.java)
fun prepare(parentCtx: BlazeContext?) {
val parentScope = parentCtx?.getScope(ToolWindowScope::class.java)

Scope.push(parentCtx) { ctx ->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
import com.google.idea.blaze.base.run.BlazeCommandRunConfiguration;
import com.google.idea.blaze.base.run.ExecutorType;
import com.google.idea.blaze.base.run.confighandler.BlazeCommandRunConfigurationRunner;
import com.google.idea.blaze.base.sync.SyncScope.SyncFailedException;
import com.google.idea.blaze.base.sync.aspects.BuildResult;
import com.google.idea.blaze.base.sync.aspects.storage.AspectStorageService;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.google.idea.blaze.base.util.SaveUtil;
import com.google.idea.blaze.common.Interners;
Expand Down Expand Up @@ -100,6 +102,12 @@ public static ClassFileManifest.Diff buildManifest(
return null;
}

try {
AspectStorageService.of(project).prepare(null);
} catch (SyncFailedException e) {
throw new ExecutionException("could not prepare aspects", e);
}

SaveUtil.saveAllFiles();
// Explicitly create a local build helper because the logic below assumes the JARs to be present
// locally
Expand Down

0 comments on commit 225a1dc

Please # to comment.