Skip to content

Commit

Permalink
Merge branch 'master' into prevent-cpp-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mai93 committed Mar 29, 2024
2 parents 0fa85d7 + cc2760e commit 1fb6123
Show file tree
Hide file tree
Showing 139 changed files with 4,665 additions and 650 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v2024.03.26
===========
* Fix "No such target" errors on incremental sync #6262
* Reduced the logging level for the stack traces produced when resolving external artifacts. #6310
* (rebase) Support embedded go_proto_library #6030
* Improved error message for an unsupported workspace type #6257

v2024.03.12
===========
* fix(plugin_dev): Alert users they need the DevKit plugin to work on the codebase #6198
Expand Down
105 changes: 63 additions & 42 deletions WORKSPACE.bzlmod
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ http_archive(
)

# The plugin api for intellij_ce_2023_2. This is required to build IJwB and run integration tests.
IC_233_SHA = "ffa6c0f98bbf67286eefb8bfad0026029edcd334463fffc17f369d9a90156992"
IC_233_SHA = "c7c4064ef95f58503ecb0d1bcebc6d9e04587adaf407da085497e8b37b788125"

IC_233_URL = "https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2023.3.5/ideaIC-2023.3.5.zip"
IC_233_URL = "https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIC/2023.3.6/ideaIC-2023.3.6.zip"

http_archive(
name = "intellij_ce_2023_3",
Expand All @@ -84,9 +84,9 @@ http_archive(
)

# The plugin api for intellij_ce_2024_1. This is required to build IJwB and run integration tests.
IC_241_SHA = "0a18e02b611562b4e81f2f5af570975c153874154ad17fdb026eae3b6818e422"
IC_241_SHA = "1b2e9ea16b9f8bcfbfab0c67b082b2e42906b5b7ec83d5520cc3e719e5e1cff0"

IC_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIC/241.14494.17-EAP-SNAPSHOT/ideaIC-241.14494.17-EAP-SNAPSHOT.zip"
IC_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIC/241.14494.158-EAP-SNAPSHOT/ideaIC-241.14494.158-EAP-SNAPSHOT.zip"

http_archive(
name = "intellij_ce_2024_1",
Expand Down Expand Up @@ -160,9 +160,9 @@ http_archive(
url = IU_232_URL,
)

IU_233_SHA = "8ba41bcdb40d64c9257467fe4f7f999b666494cc10cdce8db894d91c0b16905d"
IU_233_SHA = "ba40dbd0347a86567f2e916271dac2532cb7e8f512a31cbb63552f563ba5de24"

IU_233_URL = "https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIU/2023.3.5/ideaIU-2023.3.5.zip"
IU_233_URL = "https://www.jetbrains.com/intellij-repository/releases/com/jetbrains/intellij/idea/ideaIU/2023.3.6/ideaIU-2023.3.6.zip"

http_archive(
name = "intellij_ue_2023_3",
Expand All @@ -171,9 +171,9 @@ http_archive(
url = IU_233_URL,
)

IU_241_SHA = "6b5df17f4a28844fd02fa500404308660f46f3dc72496f12f6c2eee8b95f4392"
IU_241_SHA = "b60cb31bdd4f65f6885aa7da8dc2c65485e041cec2406b140e875b5040f2a051"

IU_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/241.14494.17-EAP-SNAPSHOT/ideaIU-241.14494.17-EAP-SNAPSHOT.zip"
IU_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/idea/ideaIU/241.14494.158-EAP-SNAPSHOT/ideaIU-241.14494.158-EAP-SNAPSHOT.zip"

http_archive(
name = "intellij_ue_2024_1",
Expand Down Expand Up @@ -257,9 +257,9 @@ http_archive(
url = CLION_233_URL,
)

CLION_241_SHA = "55c9130a6b6fda96a9e45766392ee7b2322d66c1d66e2ef89be38227fbbbcb96"
CLION_241_SHA = "5f64009afc5bbbfbe2b46aba5c9cd7571891827b5e4ece94c3614c5cfe7964b8"

CLION_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/clion/clion/241.14494.27-EAP-SNAPSHOT/clion-241.14494.27-EAP-SNAPSHOT.zip"
CLION_241_URL = "https://www.jetbrains.com/intellij-repository/snapshots/com/jetbrains/intellij/clion/clion/241.14494.154-EAP-SNAPSHOT/clion-241.14494.154-EAP-SNAPSHOT.zip"

http_archive(
name = "clion_2024_1",
Expand All @@ -276,9 +276,9 @@ java_import(
)
"""

DEVKIT_233_SHA = "225165191a515ac97c30dad96889d80c88129ce6bf069b9401da6a4c04a123b4"
DEVKIT_233_SHA = "4ed75336c016ed6f66856c95259140018aef62c376ac1bdb1a7e0b96c670ca43"

DEVKIT_233_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/DevKit/233.14808.24/DevKit-233.14808.24.zip"
DEVKIT_233_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/DevKit/233.15026.17/DevKit-233.15026.17.zip"

http_archive(
name = "devkit_2023_3",
Expand All @@ -287,9 +287,9 @@ http_archive(
url = DEVKIT_233_URL,
)

DEVKIT_241_SHA = "8a886ef1f1b2c68ad5352bf503551cea1d2c1c61d76ffc2c875c229674a69cde"
DEVKIT_241_SHA = "5fb34141dd8c75ff44dffcda845f22aa31f6c4cf0641eae18e08190eb7cdacd5"

DEVKIT_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/DevKit/241.14494.120/DevKit-241.14494.120.zip"
DEVKIT_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/DevKit/241.14494.158/DevKit-241.14494.158.zip"

http_archive(
name = "devkit_2024_1",
Expand Down Expand Up @@ -391,23 +391,9 @@ http_archive(
url = PYTHON_PLUGIN_233_URL,
)

http_archive(
name = "python_2023_1",
build_file_content = _PYTHON_CE_BUILD_FILE,
sha256 = "825c30d2cbcce405fd18fddf356eb1f425607e9c780f8eff95d21ac23f8d90fd",
url = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/231.8770.65/PythonCore-231.8770.65.zip",
)
PYTHON_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/241.14494.158/PythonCore-241.14494.158.zip"

http_archive(
name = "python_2023_2",
build_file_content = _PYTHON_CE_BUILD_FILE,
sha256 = "e744349f353568c18a9e11ec5e3a205f62bbdc1b65c9abc96783c479fe2aa51b",
url = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/232.9921.47/PythonCore-232.9921.47.zip",
)

PYTHON_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/241.14494.127/PythonCore-241.14494.127.zip"

PYTHON_PLUGIN_241_SHA = "41d941d9198078df72583297ca643c2c465a58fa478beda595e18f79fccb7dca"
PYTHON_PLUGIN_241_SHA = "3953f517290b1d8ceb504940c2980959c7040ab87752b8e0a36a75ef92aae3ad"

http_archive(
name = "python_2024_1",
Expand Down Expand Up @@ -492,9 +478,9 @@ http_archive(
url = GO_PLUGIN_232_URL,
)

GO_PLUGIN_233_SHA = "369c8acf0cc8a4dc28d2b859d389cd5a0375a14faba4a690ad91c57b2af7362e"
GO_PLUGIN_233_SHA = "6ec43880bfbedaead564def4b9f40baa13de4167d7d7c7c0522f7e7c5dd77a77"

GO_PLUGIN_233_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.jetbrains.plugins.go/233.14808.21/org.jetbrains.plugins.go-233.14808.21.zip"
GO_PLUGIN_233_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.jetbrains.plugins.go/233.15026.9/org.jetbrains.plugins.go-233.15026.9.zip"

http_archive(
name = "go_2023_3",
Expand All @@ -503,9 +489,9 @@ http_archive(
url = GO_PLUGIN_233_URL,
)

GO_PLUGIN_241_SHA = "b43ac565ce70fd68f502446ecec9546ddf748a77ac0df8d76a1c67213b354661"
GO_PLUGIN_241_SHA = "9150eb33b223c115b21a181a2a0aeb9dd89829f0aed95e976c430a6ca9d03eea"

GO_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.jetbrains.plugins.go/241.14494.127/org.jetbrains.plugins.go-241.14494.127.zip"
GO_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.jetbrains.plugins.go/241.14494.158/org.jetbrains.plugins.go-241.14494.158.zip"

http_archive(
name = "go_2024_1",
Expand Down Expand Up @@ -593,9 +579,9 @@ http_archive(
url = SCALA_PLUGIN_233_URL,
)

SCALA_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.intellij.scala/2024.1.11/org.intellij.scala-2024.1.11.zip"
SCALA_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.intellij.scala/2024.1.12/org.intellij.scala-2024.1.12.zip"

SCALA_PLUGIN_241_SHA = "e74febc21300db05f3697d55d79b017d80f7278a584d3bceebf07f1c8caf1d13"
SCALA_PLUGIN_241_SHA = "b28d565ee84cc1c39cf4b62eec685d3523934404422cb1426f4dffb496b98a50"

http_archive(
name = "scala_2024_1",
Expand All @@ -612,9 +598,9 @@ java_import(
)
"""

TOML_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.toml.lang/241.14494.33/org.toml.lang-241.14494.33.zip"
TOML_PLUGIN_241_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/org.toml.lang/241.14494.150/org.toml.lang-241.14494.150.zip"

TOML_PLUGIN_241_SHA = "356f480cb508dee613b98c71de1f0e1b871ebc5a33294199be483353523ff317"
TOML_PLUGIN_241_SHA = "f2ad603910c59b6f2b3623e52af9256f7b560ecf17f9f80b4fbc3060ee59aeee"

# TOML required by Python since 241.13688.18
http_archive(
Expand Down Expand Up @@ -706,13 +692,14 @@ new_git_repository(
)

# LICENSE: The Apache Software License, Version 2.0
rules_scala_version = "a42f009ded929070d5c412284c50ba08f0f9e8b8"
rules_scala_version = "8f255cd1fecfe4d43934b161b3edda58bdb2e8f4"

http_archive(
name = "io_bazel_rules_scala",
sha256 = "9a23058a36183a556a9ba7229b4f204d3e68c8c6eb7b28260521016b38ef4e00",
strip_prefix = "rules_scala-6.4.0",
url = "https://github.com/bazelbuild/rules_scala/releases/download/v6.4.0/rules_scala-v6.4.0.tar.gz",
sha256 = "14797e907c5614387452c42412d755ad7e343ea12540a53da1430be3301c8b4b",
strip_prefix = "rules_scala-%s" % rules_scala_version,
type = "zip",
url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip" % rules_scala_version,
)

load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")
Expand Down Expand Up @@ -774,3 +761,37 @@ grpc_java_repositories()

# Register custom java 17 toolchain
register_toolchains("//:custom_java_17_toolchain_definition")

# Dependency needed for Go test library
http_archive(
name = "bazel_gazelle",
sha256 = "29218f8e0cebe583643cbf93cae6f971be8a2484cdcfa1e45057658df8d54002",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz",
],
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

# gRPC is used to generate Go from proto in the aspect tests, in
# //aspect/testing/tests/src/com/google/idea/blaze/aspect/go/...
go_repository(
name = "org_golang_google_grpc",
build_file_proto_mode = "disable",
importpath = "google.golang.org/grpc",
sum = "h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk=",
version = "v1.27.1",
)

load("@io_bazel_rules_go//tests:grpc_repos.bzl", "grpc_dependencies")

grpc_dependencies()

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.19.3")

gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bzlmod")
48 changes: 38 additions & 10 deletions aspect/build_dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,36 @@ def declares_android_resources(target, ctx):
Returns:
True if the target has resource files and an android provider.
"""
if AndroidIdeInfo not in target:
if _get_android_provider(target) == None:
return False
return hasattr(ctx.rule.attr, "resource_files") and len(ctx.rule.attr.resource_files) > 0

def _get_android_provider(target):
if hasattr(android_common, "AndroidIdeInfo"):
if android_common.AndroidIdeInfo in target:
return target[android_common.AndroidIdeInfo]
else:
return None
elif hasattr(target, "android"):
# Backwards compatibility: supports android struct provider
legacy_android = getattr(target, "android")

# Transform into AndroidIdeInfo form
return struct(
aar = legacy_android.aar,
java_package = legacy_android.java_package,
manifest = legacy_android.manifest,
idl_source_jar = getattr(legacy_android.idl.output, "source_jar", None),
idl_class_jar = getattr(legacy_android.idl.output, "class_jar", None),
defines_android_resources = legacy_android.defines_resources,
idl_import_root = getattr(legacy_android.idl, "import_root", None),
idl_generated_java_files = getattr(legacy_android.idl, "generated_java_files", []),
resource_jar = legacy_android.resource_jar,
signed_apk = legacy_android.apk,
apks_under_test = legacy_android.apks_under_test,
)
return None

def declares_aar_import(ctx):
"""
Returns true if the target has aar and is aar_import rule.
Expand Down Expand Up @@ -237,7 +263,7 @@ def _collect_own_java_artifacts(
own_gensrc_files = []
own_src_files = []
own_srcjar_files = []
resource_package = None
resource_package = ""

if must_build_main_artifacts:
# For rules that we do not follow dependencies of (either because they don't
Expand All @@ -261,24 +287,25 @@ def _collect_own_java_artifacts(
own_ide_aar_files.append(rule.attr.aar.files.to_list()[0])

else:
if AndroidIdeInfo in target:
resource_package = target[AndroidIdeInfo].java_package
android = _get_android_provider(target)
if android != None:
resource_package = android.java_package

if generate_aidl_classes:
add_base_idl_jar = False
idl_jar = target[AndroidIdeInfo].idl_class_jar
idl_jar = android.idl_class_jar
if idl_jar != None:
own_jar_files.append(idl_jar)
add_base_idl_jar = True

generated_java_files = target[AndroidIdeInfo].idl_generated_java_files
generated_java_files = android.idl_generated_java_files
if generated_java_files:
own_gensrc_files += generated_java_files
add_base_idl_jar = True

# An AIDL base jar needed for resolving base classes for aidl generated stubs.
if add_base_idl_jar and hasattr(rule.attr, "_android_sdk"):
android_sdk_info = getattr(rule.attr, "_android_sdk")[AndroidSdkInfo]
if add_base_idl_jar and hasattr(rule.attr, "_android_sdk") and hasattr(android_common, "AndroidSdkInfo"):
android_sdk_info = getattr(rule.attr, "_android_sdk")[android_common.AndroidSdkInfo]
own_jar_depsets.append(android_sdk_info.aidl_lib.files)

# Add generated java_outputs (e.g. from annotation processing)
Expand Down Expand Up @@ -614,10 +641,11 @@ def _get_ide_aar_file(target, ctx):
The function builds a minimalistic .aar file that contains resources and the
manifest only.
"""
full_aar = target[AndroidIdeInfo].aar
android = _get_android_provider(target)
full_aar = android.aar
if full_aar:
resource_files = _collect_resource_files(ctx)
resource_map = _build_ide_aar_file_map(target[AndroidIdeInfo].manifest, resource_files)
resource_map = _build_ide_aar_file_map(android.manifest, resource_files)
aar = ctx.actions.declare_file(full_aar.short_path.removesuffix(".aar") + "_ide/" + full_aar.basename)
_package_ide_aar(ctx, aar, resource_map)
return aar
Expand Down
4 changes: 2 additions & 2 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def collect_go_info(target, ctx, semantics, ide_info, ide_info_file, output_grou
library_labels = [stringify_label(ctx.rule.attr.library.label)]
elif getattr(ctx.rule.attr, "embed", None) != None:
for library in ctx.rule.attr.embed:
if library.intellij_info.kind == "go_source":
if library.intellij_info.kind == "go_source" or library.intellij_info.kind == "go_proto_library":
l = library.intellij_info.output_groups["intellij-sources-go-outputs"].to_list()
sources += l
generated += [f for f in l if not f.is_source]
Expand Down Expand Up @@ -833,7 +833,7 @@ def _collect_android_ide_info(target, ctx, semantics, ide_info, ide_info_file, o
consistent functionality with the previous condition of the presence of the .android legacy
provider.
"""
if ctx.rule.kind not in ["android_library", "android_binary"]:
if ctx.rule.kind not in ["android_library", "android_binary", "kt_android_library"]:
return False

android_semantics = semantics.android if hasattr(semantics, "android") else None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load(
"//aspect/testing/rules:intellij_aspect_test_fixture.bzl",
"intellij_aspect_test_fixture",
)

proto_library(
name = "fooproto_proto",
srcs = ["fooserver.proto"],
visibility = ["//visibility:public"],
deps = ["@com_google_protobuf//:empty_proto"],
)

go_proto_library(
name = "fooproto_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "github.com/bazelbuild/intellij/examples/go/with_proto/proto",
proto = ":fooproto_proto",
visibility = ["//visibility:public"],
)

go_library(
name = "proto",
srcs = ["translators.go"],
embed = [":fooproto_go_proto"],
importpath = "github.com/bazelbuild/intellij/examples/go/with_proto/proto",
visibility = ["//visibility:public"],
)

intellij_aspect_test_fixture(
name = "simple_fixture",
deps = [":proto"],
)

java_test(
name = "GoTest",
srcs = ["GoTest.java"],
data = [":simple_fixture"],
deps = [
"//aspect/testing:BazelIntellijAspectTest",
"//aspect/testing:guava",
"//aspect/testing/rules:IntellijAspectTest",
"//aspect/testing/rules:intellij_aspect_test_fixture_java_proto",
"//intellij_platform_sdk:test_libs",
"//proto:intellij_ide_info_java_proto",
"@junit//jar",
],
)
Loading

0 comments on commit 1fb6123

Please sign in to comment.