From b3cb63429a0bee5b760e4f5b6a375d81d85b23d9 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Thu, 14 Nov 2024 18:17:23 +0100 Subject: [PATCH] Revert "fix: Support bazel 8 and `--noenable_workspace` mode (#6990)" (#6997) This reverts commit fc3990b0673175bdec7b100b93c44efb3baff9f4. We have to wait until bazel8 rc3 --- .../BazelInvokingIntegrationTestRunner.java | 6 ++--- .../strategy/AspectRepositoryProvider.java | 25 +++++++------------ .../aspects/strategy/AspectStrategyBazel.java | 5 +--- .../sync/aspects/strategy/OverrideFlags.java | 23 ----------------- .../BazelFastBuildAspectStrategy.java | 5 +--- .../hotswap/JavaClasspathAspectStrategy.java | 8 +++--- 6 files changed, 17 insertions(+), 55 deletions(-) delete mode 100644 base/src/com/google/idea/blaze/base/sync/aspects/strategy/OverrideFlags.java diff --git a/aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/BazelInvokingIntegrationTestRunner.java b/aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/BazelInvokingIntegrationTestRunner.java index 9d6a68b1393..d2a69301d20 100644 --- a/aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/BazelInvokingIntegrationTestRunner.java +++ b/aspect/testing/tests/src/com/google/idea/blaze/aspect/integration/BazelInvokingIntegrationTestRunner.java @@ -22,7 +22,7 @@ import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy; import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategy.OutputGroup; import com.google.idea.blaze.base.sync.aspects.strategy.AspectStrategyBazel; -import com.google.idea.blaze.base.sync.aspects.strategy.OverrideFlags; +import com.google.idea.blaze.base.sync.aspects.strategy.AspectRepositoryProvider; import java.io.File; import java.nio.file.Paths; import java.util.Collection; @@ -55,12 +55,12 @@ public static void main(String[] a) throws Exception { aspectStrategyBazel.getAspectFlag().get(), String.format( "%s=%s/%s/aspect", - OverrideFlags.overrideRepositoryFlag(false), + AspectRepositoryProvider.OVERRIDE_REPOSITORY_FLAG, System.getenv("TEST_SRCDIR"), System.getenv("TEST_WORKSPACE")), String.format( "%s=%s/%s/aspect_template", - OverrideFlags.overrideRepositoryTemplateFlag(false), + AspectRepositoryProvider.OVERRIDE_REPOSITORY_TEMPLATE_FLAG, System.getenv("TEST_SRCDIR"), System.getenv("TEST_WORKSPACE")) ); diff --git a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectRepositoryProvider.java b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectRepositoryProvider.java index 11bc9f3834b..dcee540b6fc 100644 --- a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectRepositoryProvider.java +++ b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/AspectRepositoryProvider.java @@ -1,7 +1,5 @@ package com.google.idea.blaze.base.sync.aspects.strategy; -import com.google.idea.blaze.base.model.BlazeProjectData; -import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.project.Project; @@ -13,6 +11,8 @@ public interface AspectRepositoryProvider { ExtensionPointName EP_NAME = ExtensionPointName.create("com.google.idea.blaze.AspectRepositoryProvider"); + String OVERRIDE_REPOSITORY_FLAG = "--override_repository=intellij_aspect"; + String OVERRIDE_REPOSITORY_TEMPLATE_FLAG = "--override_repository=intellij_aspect_template"; Optional aspectDirectory(); @@ -41,24 +41,17 @@ static Optional findAspectTemplateDirectory() { } static Optional[] getOverrideFlags(Project project) { - - Optional projectData = - Optional.ofNullable(BlazeProjectDataManager.getInstance(project)) - .flatMap(it -> Optional.ofNullable(it.getBlazeProjectData())); - boolean useInjectedRepository = projectData - .map(it -> it.getBlazeVersionData().bazelIsAtLeastVersion(8, 0, 0)) - .orElse(false); //fall back to false, as override_repository is available for all bazel versions - return new Optional[]{ - getOverrideFlagForAspectDirectory(useInjectedRepository), - getOverrideFlagForProjectAspectDirectory(project, useInjectedRepository), + return new Optional[] { + getOverrideFlagForAspectDirectory(), + getOverrideFlagForProjectAspectDirectory(project), }; } - private static Optional getOverrideFlagForAspectDirectory(boolean useInjectedRepository) { - return findAspectDirectory().map(it -> OverrideFlags.overrideRepositoryFlag(useInjectedRepository) + "=" + it.getPath()); + private static Optional getOverrideFlagForAspectDirectory() { + return findAspectDirectory().map(it -> OVERRIDE_REPOSITORY_FLAG + "=" + it.getPath()); } - private static Optional getOverrideFlagForProjectAspectDirectory(Project project, boolean useInjectedRepository) { - return getProjectAspectDirectory(project).map(it -> OverrideFlags.overrideRepositoryTemplateFlag(useInjectedRepository) + "=" + it.getPath()); + private static Optional getOverrideFlagForProjectAspectDirectory(Project project) { + return getProjectAspectDirectory(project).map(it -> OVERRIDE_REPOSITORY_TEMPLATE_FLAG + "=" + it.getPath()); } } 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 a1f0aa34db6..38f7305e85b 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 @@ -58,10 +58,7 @@ public Optional aspectTemplateDirectory() { @VisibleForTesting public AspectStrategyBazel(BlazeVersionData versionData) { super(/* aspectSupportsDirectDepsTrimming= */ true); - boolean useInjectedRepository = versionData.bazelIsAtLeastVersion(8, 0, 0); - if (useInjectedRepository) { - aspectFlag = "--aspects=@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect"; - } else if (versionData.bazelIsAtLeastVersion(6, 0, 0)) { + if (versionData.bazelIsAtLeastVersion(6, 0, 0)) { aspectFlag = "--aspects=@@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect"; } else { aspectFlag = "--aspects=@intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect"; diff --git a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/OverrideFlags.java b/base/src/com/google/idea/blaze/base/sync/aspects/strategy/OverrideFlags.java deleted file mode 100644 index a9e30ed8410..00000000000 --- a/base/src/com/google/idea/blaze/base/sync/aspects/strategy/OverrideFlags.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.google.idea.blaze.base.sync.aspects.strategy; - -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; - -public class OverrideFlags { - @Contract(pure = true) - static @NotNull String newRepositoryFlag(boolean useInjectedRepository) { - if (useInjectedRepository) { - return "--inject_repository"; - } else { - return "--override_repository"; - } - } - - public static @NotNull String overrideRepositoryFlag(boolean useInjectedRepository) { - return String.format("%s=intellij_aspect", newRepositoryFlag(useInjectedRepository)); - } - - public static @NotNull String overrideRepositoryTemplateFlag(boolean useInjectedRepository) { - return String.format("%s=intellij_aspect_template", newRepositoryFlag(useInjectedRepository)); - } -} diff --git a/java/src/com/google/idea/blaze/java/fastbuild/BazelFastBuildAspectStrategy.java b/java/src/com/google/idea/blaze/java/fastbuild/BazelFastBuildAspectStrategy.java index ad3f987e221..9c021042383 100644 --- a/java/src/com/google/idea/blaze/java/fastbuild/BazelFastBuildAspectStrategy.java +++ b/java/src/com/google/idea/blaze/java/fastbuild/BazelFastBuildAspectStrategy.java @@ -32,10 +32,7 @@ final class BazelFastBuildAspectStrategy extends FastBuildAspectStrategy { @Override protected List getAspectFlags(BlazeVersionData versionData, Project project) { String intellijAspectFile; - boolean useInjectedRepository = versionData.bazelIsAtLeastVersion(8, 0, 0); - if(useInjectedRepository) { - intellijAspectFile = "--aspects=@intellij_aspect//:fast_build_info_bundled.bzl%fast_build_info_aspect"; - } else if (versionData.bazelIsAtLeastVersion(6, 0, 0)) { + if (versionData.bazelIsAtLeastVersion(6, 0, 0)) { intellijAspectFile = "--aspects=@@intellij_aspect//:fast_build_info_bundled.bzl%fast_build_info_aspect"; } else { intellijAspectFile = "--aspects=@intellij_aspect//:fast_build_info_bundled.bzl%fast_build_info_aspect"; diff --git a/java/src/com/google/idea/blaze/java/run/hotswap/JavaClasspathAspectStrategy.java b/java/src/com/google/idea/blaze/java/run/hotswap/JavaClasspathAspectStrategy.java index 2ed73abdfb3..8ab97499b3f 100644 --- a/java/src/com/google/idea/blaze/java/run/hotswap/JavaClasspathAspectStrategy.java +++ b/java/src/com/google/idea/blaze/java/run/hotswap/JavaClasspathAspectStrategy.java @@ -25,6 +25,7 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -60,12 +61,9 @@ public boolean isApplicable(BlazeVersionData versionData) { @Override public ImmutableList getBuildFlags(BlazeVersionData versionData, Project project) { String intellijAspect; - boolean useInjectedRepository = versionData.bazelIsAtLeastVersion(8, 0, 0); - if (useInjectedRepository) { - intellijAspect = "--aspects=@intellij_aspect//:java_classpath.bzl%java_classpath_aspect"; - } else if (versionData.bazelIsAtLeastVersion(6, 0, 0)) { + if (versionData.bazelIsAtLeastVersion(6, 0, 0)) { intellijAspect = "--aspects=@@intellij_aspect//:java_classpath.bzl%java_classpath_aspect"; - } else { // #bazel5 we are going to drop bazel 5 support in Feb 2025 + } else { intellijAspect = "--aspects=@intellij_aspect//:java_classpath.bzl%java_classpath_aspect"; }