diff --git a/aswb/tests/unittests/com/google/idea/blaze/android/sync/aspects/strategy/RenderResolveOutputGroupProviderTest.java b/aswb/tests/unittests/com/google/idea/blaze/android/sync/aspects/strategy/RenderResolveOutputGroupProviderTest.java index b3cdd21eaed..cc78c525025 100644 --- a/aswb/tests/unittests/com/google/idea/blaze/android/sync/aspects/strategy/RenderResolveOutputGroupProviderTest.java +++ b/aswb/tests/unittests/com/google/idea/blaze/android/sync/aspects/strategy/RenderResolveOutputGroupProviderTest.java @@ -141,5 +141,10 @@ public String getName() { protected Optional getAspectFlag() { return Optional.empty(); } + + @Override + protected Boolean supportsAspectsParameters() { + return true; + } } } diff --git a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategy.java b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategy.java index fda55f4af09..a7f39a259a5 100644 --- a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategy.java +++ b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategy.java @@ -95,6 +95,8 @@ protected AspectStrategy(boolean aspectSupportsDirectDepsTrimming) { protected abstract Optional getAspectFlag(); + protected abstract Boolean supportsAspectsParameters(); + /** * Add the aspect to the build and request the given {@code OutputGroup}s. This method should only * be called once. @@ -111,7 +113,7 @@ public final void addAspectAndOutputGroups( outputGroups.stream() .flatMap(g -> getOutputGroups(g, activeLanguages, directDepsOnly).stream()) .collect(toImmutableList()); - if (optimize_building_jars.isEnabled()){ + if (optimize_building_jars.isEnabled() && supportsAspectsParameters()){ builder .addBlazeFlags(getAspectFlag().map(List::of).orElse(List.of())) .addBlazeFlags("--aspects_parameters=optimize_building_jars=enabled") diff --git a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyBazel.java b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyBazel.java index 59cbcf69c3b..f5d78c8cea2 100644 --- a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyBazel.java +++ b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyBazel.java @@ -27,6 +27,7 @@ /** Aspect strategy for Bazel, where the aspect is situated in an external repository. */ public class AspectStrategyBazel extends AspectStrategy { private final String aspectFlag; + Boolean supportsAspectParameters; static final class Provider implements AspectStrategyProvider { @Override @@ -54,6 +55,7 @@ public AspectStrategyBazel(BlazeVersionData versionData) { } else { aspectFlag = "--aspects=@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect"; } + supportsAspectParameters = versionData.bazelIsAtLeastVersion(6, 0, 0); } @Override @@ -62,6 +64,11 @@ public Optional getAspectFlag() { return Optional.of(aspectFlag); } + @Override + protected Boolean supportsAspectsParameters() { + return supportsAspectParameters; + } + @Override public String getName() { return "AspectStrategySkylarkBazel"; diff --git a/base/tests/unittests/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyTest.java b/base/tests/unittests/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyTest.java index 7ac6eead17a..815631d24cf 100644 --- a/base/tests/unittests/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyTest.java +++ b/base/tests/unittests/com/google/idea/blaze/base/sync/aspects/strategy/AspectStrategyTest.java @@ -217,5 +217,10 @@ public String getName() { protected Optional getAspectFlag() { return Optional.empty(); } + + @Override + protected Boolean supportsAspectsParameters() { + return true; + } } }