Skip to content

Commit

Permalink
fix: Sync fails with Unrecognized option: --aspects_parameters for Ba… (
Browse files Browse the repository at this point in the history
#6653)

* fix: Sync fails with Unrecognized option: --aspects_parameters for Bazel 5

closes #6650

* fix aswb build
  • Loading branch information
tpasternak authored Aug 20, 2024
1 parent 1bfda0e commit ba01cc1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,10 @@ public String getName() {
protected Optional<String> getAspectFlag() {
return Optional.empty();
}

@Override
protected Boolean supportsAspectsParameters() {
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ protected AspectStrategy(boolean aspectSupportsDirectDepsTrimming) {

protected abstract Optional<String> 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.
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -62,6 +64,11 @@ public Optional<String> getAspectFlag() {
return Optional.of(aspectFlag);
}

@Override
protected Boolean supportsAspectsParameters() {
return supportsAspectParameters;
}

@Override
public String getName() {
return "AspectStrategySkylarkBazel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,10 @@ public String getName() {
protected Optional<String> getAspectFlag() {
return Optional.empty();
}

@Override
protected Boolean supportsAspectsParameters() {
return true;
}
}
}

0 comments on commit ba01cc1

Please sign in to comment.