Skip to content

Commit

Permalink
Merge branch 'master' into upgrade-all
Browse files Browse the repository at this point in the history
  • Loading branch information
mai93 committed Oct 9, 2024
2 parents 7c97f25 + ea47578 commit 40ef157
Show file tree
Hide file tree
Showing 42 changed files with 2,357 additions and 2,061 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ common --android_sdk=@androidsdk//:sdk
# Required for CLion integration tests on windows
startup --windows_enable_symlinks
build --enable_runfiles
common --incompatible_use_plus_in_repo_names
# common --incompatible_use_plus_in_repo_names # reenable after this is fixed https://github.com/protocolbuffers/protobuf/issues/18546
10 changes: 10 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
v2024.10.08
===========
Bug Fixes
* CLion Virtual Include Fixes #6759
* Fixes for Query Sync (ready to use): #6833, #6834, #6835, #6841
* [fix] Confirm if user wants to reimport instead of disallowing it #6839
Features
* Implement JUnit5 support and parameterize tests #4473
* [feature] Recognize WORKSPACE.bzlmod files #6853

v2024.09.24
===========
Bug Fixes
Expand Down
8 changes: 4 additions & 4 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,9 @@ http_archive(
url = CLION_242_URL,
)

CLION_243_SHA = "b2b61d44c5a501e3209577b9164d56e6148020133ce4709f79c0be3a3cd17032"
CLION_243_SHA = "2f60f3206a3ac73b3a398df4fa6dc4343b42e835dab99c338d38b2f988fb47db"

CLION_243_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/clion/clion/243.16718.30-EAP-SNAPSHOT/clion-243.16718.30-EAP-SNAPSHOT.zip"
CLION_243_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/clion/clion/243.18137.40-EAP-SNAPSHOT/clion-243.18137.40-EAP-SNAPSHOT.zip"

http_archive(
name = "clion_2024_3",
Expand Down Expand Up @@ -700,9 +700,9 @@ http_archive(
url = SCALA_PLUGIN_242_URL,
)

SCALA_PLUGIN_243_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.intellij.scala/2024.3.4/org.intellij.scala-2024.3.4.zip"
SCALA_PLUGIN_243_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.intellij.scala/2024.3.5/org.intellij.scala-2024.3.5.zip"

SCALA_PLUGIN_243_SHA = "5f80536208756dce375df9d7ed86b09364074371aee720209cb377edad426950"
SCALA_PLUGIN_243_SHA = "2e46a224b046f8bdf04207f67b48b861f29d5431ba4ad611df2056f23b1e4de8"

http_archive(
name = "scala_2024_3",
Expand Down
3,888 changes: 1,907 additions & 1,981 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ scalatest_repositories()

scalatest_toolchain()

load("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")

local_repository(
name = "intellij_aspect_template",
path = "aspect_template"
)
2 changes: 1 addition & 1 deletion aspect/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ filegroup(
"intellij_info_bundled.bzl",
"intellij_info_impl_bundled.bzl",
"java_classpath.bzl",
"java_info.bzl",
"make_variables.bzl",
":BUILD.bazel",
"//aspect/tools:CreateAar",
Expand Down Expand Up @@ -84,6 +83,7 @@ genrule(
outs = ["intellij_info_impl_bundled.bzl"],
cmd = "cat $(SRCS) >$@ && " +
"sed -i -e '/BUNDLED-IGNORE-BEGIN/,/BUNDLED-IGNORE-END/d' $@ && " +
"sed -i -e '/BUNDLED-INCLUDE-BEGIN/,/BUNDLED-INCLUDE-END/{s/^[#][#]//;}' $@ &&" +
"sed -i -e 's,load(\".*/rules_java/,load(\"@rules_java//', $@",
)

Expand Down
2 changes: 1 addition & 1 deletion aspect/fast_build_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ load(
":intellij_info_impl.bzl",
"stringify_label",
)
load(":java_info.bzl", "get_java_info")
load("@intellij_aspect_template//:java_info.bzl", "get_java_info")

_DEP_ATTRS = ["deps", "exports", "runtime_deps", "_java_toolchain"]

Expand Down
4 changes: 3 additions & 1 deletion aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ load(
"to_artifact_location",
)
load(":flag_hack.bzl", "FlagHackInfo")
load(":java_info.bzl", "get_java_info", "java_info_in_target", "java_info_reference")

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

load(
":make_variables.bzl",
"expand_make_variables",
Expand Down
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(":java_info.bzl", "get_java_info", "java_info_in_target")
load("@intellij_aspect_template//:java_info.bzl", "get_java_info", "java_info_in_target")

def _runtime_classpath_impl(target, ctx):
"""The top level aspect implementation function.
Expand Down
9 changes: 0 additions & 9 deletions aspect/java_info.bzl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ java_binary(
srcs = ["BazelInvokingIntegrationTestRunner.java"],
data = [
"//aspect:aspect_files",
"//aspect_template:aspect_files",
],
main_class = "com.google.idea.blaze.aspect.integration.BazelInvokingIntegrationTestRunner",
deps = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ public static void main(String[] a) throws Exception {
"%s=%s/%s/aspect",
AspectRepositoryProvider.OVERRIDE_REPOSITORY_FLAG,
System.getenv("TEST_SRCDIR"),
System.getenv("TEST_WORKSPACE")));
System.getenv("TEST_WORKSPACE")),
String.format(
"%s=%s/%s/aspect_template",
AspectRepositoryProvider.OVERRIDE_REPOSITORY_TEMPLATE_FLAG,
System.getenv("TEST_SRCDIR"),
System.getenv("TEST_WORKSPACE"))
);

if (bazelVersion.isAtLeast(6, 0, 0)
&& !aspectFlags.contains(
Expand Down
33 changes: 33 additions & 0 deletions aspect_template/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
filegroup(
name = "aspect_files",
srcs = [
"WORKSPACE",
"BUILD.bazel",
"java_info.bzl",
"java_info.template.bzl",
],
visibility = ["//visibility:public"],
)

genrule(
name = "generate_java_info_template",
outs = ["java_info.template.bzl"],
srcs = ["java_info.bzl"],
cmd = "cat $(SRCS) >$@ && " +
"sed -i -e '/TEMPLATE-IGNORE-BEGIN/,/TEMPLATE-IGNORE-END/d' $@ && " +
"sed -i -e '/TEMPLATE-INCLUDE-BEGIN/,/TEMPLATE-INCLUDE-END/{s/^[#][#]//;}' $@",
)

genrule(
name = "rename_files",
srcs = ["BUILD.aspect"],
outs = ["BUILD.bazel"],
cmd = "cp $< $@",
)

genrule(
name = "create_workspace_file",
outs = ["WORKSPACE"],
srcs = [],
cmd = r"""echo 'workspace(name = "intellij_aspect_template")' > $@"""
)
Empty file added aspect_template/BUILD.aspect
Empty file.
Empty file added aspect_template/MODULE.bazel
Empty file.
50 changes: 50 additions & 0 deletions aspect_template/java_info.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# TEMPLATE-INCLUDE-BEGIN
###if( $isJavaEnabled == "true" && $bazel8OrAbove == "true" )
##load("@rules_java//java/common:java_info.bzl", "JavaInfo")
###end
# TEMPLATE-INCLUDE-END

def java_info_in_target(target):
# TEMPLATE-IGNORE-BEGIN
return JavaInfo in target
# TEMPLATE-IGNORE-END

# TEMPLATE-INCLUDE-BEGIN
## #if( $isJavaEnabled == "true" )
## return JavaInfo in target
## #else
## return None
## #end
# TEMPLATE-INCLUDE-END

def get_java_info(target):
# TEMPLATE-IGNORE-BEGIN
if JavaInfo in target:
return target[JavaInfo]
else:
return None
# TEMPLATE-IGNORE-END

# TEMPLATE-INCLUDE-BEGIN
## #if( $isJavaEnabled == "true" )
## if JavaInfo in target:
## return target[JavaInfo]
## else:
## return None
## #else
## return None
## #end
# TEMPLATE-INCLUDE-END

def java_info_reference():
# TEMPLATE-IGNORE-BEGIN
return [JavaInfo]
# TEMPLATE-IGNORE-END

# TEMPLATE-INCLUDE-BEGIN
## #if( $isJavaEnabled == "true" )
## return [JavaInfo]
## #else
## return []
## #end
# TEMPLATE-INCLUDE-END
1 change: 1 addition & 0 deletions base/src/META-INF/blaze-base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@
<SyncListener implementation="com.google.idea.blaze.base.command.info.BlazeInfoProvider$Invalidator"/>
<SyncListener implementation="com.google.idea.blaze.base.model.ExternalWorkspaceDataProvider$Invalidator"/>
<SyncListener implementation="com.google.idea.blaze.base.qsync.QuerySyncAsyncFileListener$QuerySyncListener"/>
<SyncListener implementation="com.google.idea.blaze.base.sync.aspects.strategy.SyncAspectTemplateProvider"/>
<SyncPlugin implementation="com.google.idea.blaze.base.lang.buildfile.sync.BuildLangSyncPlugin"/>
<SyncPlugin implementation="com.google.idea.blaze.base.sync.libraries.ExternalLibraryManager$SyncPlugin"/>
<BuildFlagsProvider implementation="com.google.idea.blaze.base.command.BuildFlagsProviderImpl"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public Builder(String binaryPath, BlazeCommandName name, Project project) {
// Tell forge what tool we used to call blaze so we can track usage.
addBlazeFlags(BlazeFlags.getToolTagFlag());

AspectRepositoryProvider.getOverrideFlag(project).ifPresent(this::addBlazeFlags);
Arrays.stream(AspectRepositoryProvider.getOverrideFlags(project)).filter(Optional::isPresent)
.map(Optional::get)
.forEach(this::addBlazeFlags);
}

private ImmutableList<String> getArguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public class ExternalWorkspaceDataProvider {
private final Project project;

private volatile ExternalWorkspaceData externalWorkspaceData;
private ListenableFuture<String> deps;

public ExternalWorkspaceDataProvider(Project project) {
this.project = project;
Expand Down Expand Up @@ -105,13 +104,11 @@ public ListenableFuture<ExternalWorkspaceData> getExternalWorkspaceData(
.getBuildSystem()
.getDefaultInvoker(project, context);

deps = BlazeModRunner.getInstance().getDeps(project, buildInvoker, context, importSettings.getBuildSystem(), blazeFlags);
externalWorkspaceData =
BlazeModRunner.getInstance()
.dumpRepoMapping(
project, buildInvoker, context, importSettings.getBuildSystem(), blazeFlags)
.get();
deps.get();
} catch (InterruptedException | ExecutionException e) {
context.handleExceptionAsWarning(
"Failed to run `blaze mod dump_repo_mapping` (completion of labels from module provided repos will be unavailable)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
import com.google.idea.blaze.base.settings.BlazeUserSettings.FocusBehavior;
import com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException;
import com.google.idea.blaze.base.sync.SyncScope.SyncFailedException;
import com.google.idea.blaze.base.sync.aspects.strategy.AspectRepositoryProvider;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.google.idea.blaze.base.sync.projectview.SyncDirectoriesWarning;
import com.google.idea.blaze.base.sync.status.BlazeSyncStatus;
import com.google.idea.blaze.base.toolwindow.Task;
import com.google.idea.blaze.base.util.SaveUtil;
import com.google.idea.blaze.base.util.TemplateWriter;
import com.google.idea.blaze.common.Context;
import com.google.idea.blaze.common.PrintOutput;
import com.google.idea.blaze.common.PrintOutput.OutputType;
Expand All @@ -61,7 +63,9 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupManager;
import com.intellij.openapi.util.text.StringUtil;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.google.idea.blaze.base.sync.SyncScope.SyncCanceledException;
import com.google.idea.blaze.base.sync.SyncScope.SyncFailedException;
import com.google.idea.blaze.base.sync.aspects.BlazeIdeInterface;
import com.google.idea.blaze.base.sync.aspects.strategy.AspectRepositoryProvider;
import com.google.idea.blaze.base.sync.data.BlazeDataStorage;
import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager;
import com.google.idea.blaze.base.sync.libraries.BlazeLibraryCollector;
Expand Down Expand Up @@ -77,6 +78,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.VirtualFileManager;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Nullable;
Expand Down
4 changes: 4 additions & 0 deletions base/src/com/google/idea/blaze/base/sync/SyncScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ private SyncScope() {}
public static class SyncFailedException extends Exception {
public SyncFailedException() {}

public SyncFailedException(String message) {
super(message);
}

public SyncFailedException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,54 @@
import com.intellij.openapi.project.Project;

import java.io.File;
import java.nio.file.*;
import java.util.Optional;

public interface AspectRepositoryProvider {
ExtensionPointName<AspectRepositoryProvider> 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<File> aspectDirectory(Project project);
Optional<File> aspectDirectory();

static Optional<File> findAspectDirectory(Project project) {
default Optional<File> aspectTemplateDirectory() {
return Optional.empty();
}

static Optional<File> getProjectAspectDirectory(Project project) {
return Optional.ofNullable(project.getBasePath()).map((it) -> Paths.get(it).resolve("aspect").toFile());
}

private static Optional<File> findAspectDirectory() {
return EP_NAME.getExtensionsIfPointIsRegistered().stream()
.map(aspectRepositoryProvider -> aspectRepositoryProvider.aspectDirectory(project))
.map(AspectRepositoryProvider::aspectDirectory)
.filter(Optional::isPresent)
.findFirst()
.orElse(Optional.empty());
}

static Optional<String> getOverrideFlag(Project project) {
return findAspectDirectory(project).map(it -> OVERRIDE_REPOSITORY_FLAG + "=" + it.getPath());
static Optional<File> findAspectTemplateDirectory() {
return EP_NAME.getExtensionsIfPointIsRegistered().stream()
.map(AspectRepositoryProvider::aspectTemplateDirectory)
.filter(Optional::isPresent)
.findFirst()
.orElse(Optional.empty());
}

static Optional<String>[] getOverrideFlags(Project project) {
return new Optional[] {
getOverrideFlagForAspectDirectory(),
getOverrideFlagForProjectAspectDirectory(project),
};
}

private static Optional<String> getOverrideFlagForAspectDirectory() {
return findAspectDirectory().map(it -> OVERRIDE_REPOSITORY_FLAG + "=" + it.getPath());
}

private static Optional<String> getOverrideFlagForProjectAspectDirectory(Project project) {
return getProjectAspectDirectory(project).map(it -> OVERRIDE_REPOSITORY_TEMPLATE_FLAG + "=" + it.getPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ public AspectStrategy getStrategy(BlazeVersionData versionData) {

static final class RepositoryProvider implements AspectRepositoryProvider {
@Override
public Optional<File> aspectDirectory(Project project) {
public Optional<File> aspectDirectory() {
return Optional.ofNullable(PluginManager.getPluginByClass(AspectStrategy.class))
.map((it) -> new File(it.getPath(), "aspect"));
}

@Override
public Optional<File> aspectTemplateDirectory() {
return Optional.ofNullable(PluginManager.getPluginByClass(AspectStrategy.class))
.map((it) -> new File(it.getPath(), "aspect_template"));
}
}

@VisibleForTesting
Expand Down
Loading

0 comments on commit 40ef157

Please sign in to comment.