diff --git a/CHANGELOG b/CHANGELOG index aee587c78f5..05c8d191e05 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index e83a73bd814..431ee757d7e 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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( @@ -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") @@ -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") diff --git a/aspect/build_dependencies.bzl b/aspect/build_dependencies.bzl index 58c0dbe7752..bcfb9b9c531 100644 --- a/aspect/build_dependencies.bzl +++ b/aspect/build_dependencies.bzl @@ -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. @@ -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 @@ -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) @@ -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 diff --git a/aspect/intellij_info_impl.bzl b/aspect/intellij_info_impl.bzl index e1f9c42154b..6e384a93a27 100644 --- a/aspect/intellij_info_impl.bzl +++ b/aspect/intellij_info_impl.bzl @@ -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] @@ -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 diff --git a/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/BUILD b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/BUILD new file mode 100644 index 00000000000..2f17a56ba5d --- /dev/null +++ b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/BUILD @@ -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", + ], +) diff --git a/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/GoTest.java b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/GoTest.java new file mode 100644 index 00000000000..58358f81226 --- /dev/null +++ b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/GoTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.blaze.aspect.go.go_proto_library; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.devtools.intellij.IntellijAspectTestFixtureOuterClass.IntellijAspectTestFixture; +import com.google.devtools.intellij.ideinfo.IntellijIdeInfo.TargetIdeInfo; +import com.google.idea.blaze.BazelIntellijAspectTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + + +/** Tests go_proto_library */ +@RunWith(JUnit4.class) +public class GoTest extends BazelIntellijAspectTest { + @Test + public void testGoTest() throws Exception { + IntellijAspectTestFixture testFixture = loadTestFixture(":simple_fixture"); + TargetIdeInfo target = findTarget(testFixture, ":proto"); + assertThat(target.getKindString()).isEqualTo("go_library"); + assertThat(relativePathsForArtifacts(target.getGoIdeInfo().getSourcesList())) + .contains(testRelative("translators.go")); + assertThat(relativePathsForArtifacts(target.getGoIdeInfo().getSourcesList())) + .contains(testRelative("fooproto_go_proto_/github.com/bazelbuild/intellij/examples/go/with_proto/proto/fooserver.pb.go")); + } +} diff --git a/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/fooserver.proto b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/fooserver.proto new file mode 100644 index 00000000000..ab63c861d34 --- /dev/null +++ b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/fooserver.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; + +package fooproto; + +import "google/protobuf/empty.proto"; + +service FooService { + rpc SayHello (HelloRequest) returns (HelloReply) {} + // This function exists to validate that the well known types (such as google.protobuf.Empty) + // are picked up by the plugin. + // To validate that they are working, navigate to "External Libraries" > "Go Libraries" > + // "github.com/bazelbuild/intellij/examples/go/with_proto/proto/fooserver.pb.go", + // and validate that "google.golang.org/protobuf/types/known/emptypb" is resolved correctly. + rpc EmptyFunction (google.protobuf.Empty) returns (google.protobuf.Empty); +} + +message HelloRequest { + optional string name = 1; +} + +message HelloReply { + optional string message = 1; +} + +message Time { + string value = 1; +} diff --git a/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/translators.go b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/translators.go new file mode 100644 index 00000000000..f79720cb504 --- /dev/null +++ b/aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/translators.go @@ -0,0 +1,11 @@ +package proto + +import ( + "time" +) + +// Time translation functions. + +func ToProtoTime(t time.Time) Time { + return Time{Value: t.Format(time.RFC3339Nano)} +} diff --git a/aswb/src/META-INF/aswb.xml b/aswb/src/META-INF/aswb.xml index 4d1c88a8f3b..63b5e6b5796 100644 --- a/aswb/src/META-INF/aswb.xml +++ b/aswb/src/META-INF/aswb.xml @@ -123,4 +123,8 @@ + + + + diff --git a/aswb/src/com/google/idea/blaze/android/cppimpl/BlazeNdkSupportEnabler.java b/aswb/src/com/google/idea/blaze/android/cppimpl/BlazeNdkSupportEnabler.java index 9657c0ebc17..29cd9527b38 100644 --- a/aswb/src/com/google/idea/blaze/android/cppimpl/BlazeNdkSupportEnabler.java +++ b/aswb/src/com/google/idea/blaze/android/cppimpl/BlazeNdkSupportEnabler.java @@ -32,7 +32,7 @@ import com.google.idea.blaze.base.sync.SyncResult; import com.google.idea.blaze.common.Context; import com.google.idea.blaze.qsync.BlazeProjectListener; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.QuerySyncLanguage; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.TransactionGuard; diff --git a/aswb/src/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemBase.java b/aswb/src/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemBase.java index 08195904ecf..36f5b94a83e 100644 --- a/aswb/src/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemBase.java +++ b/aswb/src/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemBase.java @@ -44,6 +44,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.google.idea.blaze.android.compose.ComposeStatusProvider; import com.google.idea.blaze.android.libraries.UnpackedAars; import com.google.idea.blaze.android.npw.project.BlazeAndroidModuleTemplate; @@ -65,10 +66,13 @@ import com.google.idea.blaze.base.model.primitives.WorkspaceRoot; import com.google.idea.blaze.base.projectview.ProjectViewManager; import com.google.idea.blaze.base.qsync.DependencyTracker; +import com.google.idea.blaze.base.qsync.QuerySync; import com.google.idea.blaze.base.qsync.QuerySyncManager; +import com.google.idea.blaze.base.qsync.QuerySyncProject; import com.google.idea.blaze.base.scope.BlazeContext; import com.google.idea.blaze.base.settings.Blaze; import com.google.idea.blaze.base.settings.BlazeImportSettings.ProjectType; +import com.google.idea.blaze.base.settings.BlazeImportSettingsManager; import com.google.idea.blaze.base.sync.SyncCache; import com.google.idea.blaze.base.sync.data.BlazeDataStorage; import com.google.idea.blaze.base.sync.data.BlazeProjectDataManager; @@ -77,7 +81,11 @@ import com.google.idea.blaze.base.targetmaps.ReverseDependencyMap; import com.google.idea.blaze.base.targetmaps.TransitiveDependencyMap; import com.google.idea.blaze.common.Label; +import com.google.idea.blaze.qsync.BlazeProject; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.deps.ArtifactTracker; +import com.google.idea.blaze.qsync.project.ProjectPath; +import com.google.idea.blaze.qsync.project.ProjectProto; import com.google.idea.common.experiments.BoolExperiment; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -122,6 +130,7 @@ abstract class BlazeModuleSystemBase implements AndroidModuleSystem { protected static final Logger logger = Logger.getInstance(BlazeModuleSystem.class); protected Module module; protected final Project project; + private final ProjectPath.Resolver pathResolver; SampleDataDirectoryProvider sampleDataDirectoryProvider; RenderJarClassFileFinder classFileFinder; final boolean isWorkspaceModule; @@ -130,10 +139,18 @@ abstract class BlazeModuleSystemBase implements AndroidModuleSystem { BlazeModuleSystemBase(Module module) { this.module = module; this.project = module.getProject(); + this.pathResolver = + ProjectPath.Resolver.create( + WorkspaceRoot.fromProject(project).path(), + Path.of( + BlazeImportSettingsManager.getInstance(project) + .getImportSettings() + .getProjectDataDirectory())); classFileFinder = new RenderJarClassFileFinder(module); sampleDataDirectoryProvider = new BlazeSampleDataDirectoryProvider(module); isWorkspaceModule = module.getName().equals(BlazeDataStorage.WORKSPACE_MODULE_NAME); - if (Blaze.getProjectType(project) == ProjectType.QUERY_SYNC) { + if (Blaze.getProjectType(project) == ProjectType.QUERY_SYNC + && !QuerySync.USE_NEW_BUILD_ARTIFACT_MANAGEMENT) { androidExternalLibraryManager = new AndroidExternalLibraryManager( () -> { @@ -565,7 +582,30 @@ public boolean getUsesCompose() { public Collection getDependentLibraries() { if (Blaze.getProjectType(project) == ProjectType.QUERY_SYNC) { - return androidExternalLibraryManager.getExternalLibraries(); + if (QuerySync.USE_NEW_BUILD_ARTIFACT_MANAGEMENT) { + ProjectProto.Project projectProto = + QuerySyncManager.getInstance(project) + .getLoadedProject() + .map(QuerySyncProject::getSnapshotHolder) + .flatMap(BlazeProject::getCurrent) + .map(BlazeProjectSnapshot::project) + .orElse(null); + if (projectProto == null) { + return ImmutableList.of(); + } + ImmutableList matchingModules = + projectProto.getModulesList().stream() + .filter(m -> m.getName().equals(module.getName())) + .collect(ImmutableList.toImmutableList()); + if (matchingModules.isEmpty()) { + return ImmutableList.of(); + } + return Iterables.getOnlyElement(matchingModules).getAndroidExternalLibrariesList().stream() + .map(this::fromProto) + .collect(toImmutableList()); + } else { + return androidExternalLibraryManager.getExternalLibraries(); + } } BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); @@ -609,6 +649,19 @@ public Collection getDependentLibraries() { return libraries.build(); } + private ExternalAndroidLibrary fromProto(ProjectProto.ExternalAndroidLibrary proto) { + return new ExternalLibraryImpl(proto.getName()) + .withLocation(toPathString(proto.getLocation())) + .withManifestFile(toPathString(proto.getManifestFile())) + .withResFolder(new SelectiveResourceFolder(toPathString(proto.getResFolder()), null)) + .withSymbolFile(toPathString(proto.getSymbolFile())) + .withPackageName(proto.getPackageName()); + } + + private PathString toPathString(ProjectProto.ProjectPath projectPath) { + return new PathString(pathResolver.resolve(ProjectPath.create(projectPath))); + } + private static ImmutableList getLibrariesForWorkspaceModule( Project project, BlazeProjectData blazeProjectData) { ArtifactLocationDecoder decoder = blazeProjectData.getArtifactLocationDecoder(); diff --git a/aswb/src/com/google/idea/blaze/android/qsync/AndroidProjectProtoTransform.java b/aswb/src/com/google/idea/blaze/android/qsync/AndroidProjectProtoTransform.java new file mode 100644 index 00000000000..8521b8bdb3c --- /dev/null +++ b/aswb/src/com/google/idea/blaze/android/qsync/AndroidProjectProtoTransform.java @@ -0,0 +1,69 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.blaze.android.qsync; + +import com.google.common.collect.ImmutableList; +import com.google.idea.blaze.android.manifest.ManifestParser; +import com.google.idea.blaze.base.qsync.ProjectProtoTransformProvider; +import com.google.idea.blaze.base.qsync.QuerySyncProject; +import com.google.idea.blaze.common.Context; +import com.google.idea.blaze.exception.BuildException; +import com.google.idea.blaze.qsync.deps.ProjectProtoUpdate; +import com.google.idea.blaze.qsync.deps.ProjectProtoUpdateOperation; +import com.google.idea.blaze.qsync.java.AddAndroidResPackages; +import com.google.idea.blaze.qsync.java.AddDependencyAars; +import com.google.idea.blaze.qsync.project.BuildGraphData; +import com.google.idea.blaze.qsync.project.ProjectProto.Project; +import com.google.idea.blaze.qsync.project.ProjectProtoTransform; +import java.util.List; + +/** A {@link ProjectProtoTransform} that adds android specific information to the project proto. */ +public class AndroidProjectProtoTransform implements ProjectProtoTransform { + + /** + * Provides a {@link ProjectProtoTransform} that adds android specific information to the project + * proto. + */ + public static class Provider implements ProjectProtoTransformProvider { + @Override + public List createTransforms(QuerySyncProject project) { + return ImmutableList.of(new AndroidProjectProtoTransform(project)); + } + } + + private final ImmutableList updateOperations; + + private AndroidProjectProtoTransform(QuerySyncProject project) { + updateOperations = + ImmutableList.of( + new AddDependencyAars( + project.getArtifactTracker()::getStateSnapshot, + project.getBuildArtifactCache(), + project.getProjectDefinition(), + in -> ManifestParser.parseManifestFromInputStream(in).packageName), + new AddAndroidResPackages(project.getArtifactTracker()::getStateSnapshot)); + } + + @Override + public Project apply(Project proto, BuildGraphData graph, Context context) + throws BuildException { + ProjectProtoUpdate update = new ProjectProtoUpdate(proto, graph, context); + for (var op : updateOperations) { + op.update(update); + } + return update.build(); + } +} diff --git a/aswb/tests/unittests/sdkcompat/as223/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java b/aswb/tests/unittests/sdkcompat/as223/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java index 3ff113a9526..1b7194a7e31 100644 --- a/aswb/tests/unittests/sdkcompat/as223/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java +++ b/aswb/tests/unittests/sdkcompat/as223/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java @@ -95,6 +95,7 @@ protected void initTest(Container applicationServices, Container projectServices mockBlazeImportSettings(projectServices); // For Blaze.isBlazeProject. createMocksForAddDependency(applicationServices, projectServices); + project.setBaseDir(new MockVirtualFile("/")); service = new BlazeProjectSystem(project); } diff --git a/aswb/tests/unittests/sdkcompat/as231/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java b/aswb/tests/unittests/sdkcompat/as231/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java index 3ff113a9526..1b7194a7e31 100644 --- a/aswb/tests/unittests/sdkcompat/as231/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java +++ b/aswb/tests/unittests/sdkcompat/as231/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java @@ -95,6 +95,7 @@ protected void initTest(Container applicationServices, Container projectServices mockBlazeImportSettings(projectServices); // For Blaze.isBlazeProject. createMocksForAddDependency(applicationServices, projectServices); + project.setBaseDir(new MockVirtualFile("/")); service = new BlazeProjectSystem(project); } diff --git a/aswb/tests/unittests/sdkcompat/as232/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java b/aswb/tests/unittests/sdkcompat/as232/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java index faaa9dcfd00..ed87ed760d9 100644 --- a/aswb/tests/unittests/sdkcompat/as232/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java +++ b/aswb/tests/unittests/sdkcompat/as232/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java @@ -99,6 +99,7 @@ protected void initTest(Container applicationServices, Container projectServices mockBlazeImportSettings(projectServices); // For Blaze.isBlazeProject. createMocksForAddDependency(applicationServices, projectServices); + project.setBaseDir(new MockVirtualFile("/")); service = new BlazeProjectSystem(project); } diff --git a/aswb/tests/unittests/sdkcompat/asdev/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java b/aswb/tests/unittests/sdkcompat/asdev/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java index 3ff113a9526..1b7194a7e31 100644 --- a/aswb/tests/unittests/sdkcompat/asdev/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java +++ b/aswb/tests/unittests/sdkcompat/asdev/com/google/idea/blaze/android/projectsystem/BlazeModuleSystemTest.java @@ -95,6 +95,7 @@ protected void initTest(Container applicationServices, Container projectServices mockBlazeImportSettings(projectServices); // For Blaze.isBlazeProject. createMocksForAddDependency(applicationServices, projectServices); + project.setBaseDir(new MockVirtualFile("/")); service = new BlazeProjectSystem(project); } diff --git a/base/src/META-INF/blaze-base.xml b/base/src/META-INF/blaze-base.xml index 174a566dc9c..e51c3fb4fc2 100644 --- a/base/src/META-INF/blaze-base.xml +++ b/base/src/META-INF/blaze-base.xml @@ -494,6 +494,9 @@ interface="com.google.idea.blaze.base.qsync.HandledRulesProvider" /> + + diff --git a/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java b/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java index 3e08f6b4242..1fa124ce963 100644 --- a/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java +++ b/base/src/com/google/idea/blaze/base/bazel/BazelBuildSystem.java @@ -120,6 +120,11 @@ public void populateBlazeVersionData( builder.setBazelVersion(BazelVersion.parseVersion(blazeInfo)); } + @Override + public Optional getBazelVersionString(BlazeInfo blazeInfo) { + return Optional.ofNullable(BazelVersion.parseVersion(blazeInfo).toString()); + } + @Override public BazelQueryRunner createQueryRunner(Project project) { return new BazelQueryRunner(project, this); diff --git a/base/src/com/google/idea/blaze/base/bazel/BazelVersion.java b/base/src/com/google/idea/blaze/base/bazel/BazelVersion.java index 067ef9f2d5a..e9f6b62cfb6 100644 --- a/base/src/com/google/idea/blaze/base/bazel/BazelVersion.java +++ b/base/src/com/google/idea/blaze/base/bazel/BazelVersion.java @@ -67,7 +67,7 @@ int getBugfix() { } @VisibleForTesting - static BazelVersion parseVersion(@Nullable String string) { + public static BazelVersion parseVersion(@Nullable String string) { // treat all unknown / development versions as the very latest version if (string == null) { return DEVELOPMENT; diff --git a/base/src/com/google/idea/blaze/base/bazel/BuildSystem.java b/base/src/com/google/idea/blaze/base/bazel/BuildSystem.java index 64a828888d8..98eb76e0b5f 100644 --- a/base/src/com/google/idea/blaze/base/bazel/BuildSystem.java +++ b/base/src/com/google/idea/blaze/base/bazel/BuildSystem.java @@ -131,6 +131,9 @@ default BuildInvoker getBuildInvoker( void populateBlazeVersionData( WorkspaceRoot workspaceRoot, BlazeInfo blazeInfo, BlazeVersionData.Builder builder); + /** Get bazel only version. Returns empty if it's not bazel project. */ + Optional getBazelVersionString(BlazeInfo blazeInfo); + /** * Returns the parallel invoker if the sync strategy is PARALLEL and the system supports it; * otherwise returns the standard invoker. diff --git a/base/src/com/google/idea/blaze/base/build/BlazeBuildService.java b/base/src/com/google/idea/blaze/base/build/BlazeBuildService.java index f9c5881fdfc..d92f3ccf249 100644 --- a/base/src/com/google/idea/blaze/base/build/BlazeBuildService.java +++ b/base/src/com/google/idea/blaze/base/build/BlazeBuildService.java @@ -66,6 +66,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; import java.util.List; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import javax.annotation.Nullable; @@ -139,7 +140,7 @@ public void buildProject() { projectData.getWorkspacePathResolver(), projectData.getWorkspaceLanguageSettings()) .getTargetsToSync(); - } catch (SyncCanceledException e) { + } catch (SyncCanceledException | ExecutionException | InterruptedException e) { context.setCancelled(); return null; } catch (SyncFailedException e) { diff --git a/base/src/com/google/idea/blaze/base/issueparser/BlazeIssueParser.java b/base/src/com/google/idea/blaze/base/issueparser/BlazeIssueParser.java index 0ff8d875b6c..fe1e464320f 100644 --- a/base/src/com/google/idea/blaze/base/issueparser/BlazeIssueParser.java +++ b/base/src/com/google/idea/blaze/base/issueparser/BlazeIssueParser.java @@ -22,6 +22,7 @@ import com.google.common.base.Ascii; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Streams; import com.google.idea.blaze.base.command.BlazeInvocationContext; import com.google.idea.blaze.base.model.primitives.Label; import com.google.idea.blaze.base.model.primitives.TargetExpression; @@ -36,6 +37,7 @@ import com.google.idea.blaze.base.scope.output.IssueOutput; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -49,10 +51,46 @@ public class BlazeIssueParser { private static final String BAZEL_BUILD_FILES_PATTERN = "(/.*?BUILD(?:\\.bazel)?)"; - public static ImmutableList defaultIssueParsers( + private static ImmutableList commonParsers(Project project, WorkspaceRoot workspaceRoot, ProjectViewSet projectViewSet) { + return ImmutableList.builder() + .add( + new PythonCompileParser(project), + new DefaultCompileParser(project), + new TracebackParser(), + new BuildParser(), + new SkylarkErrorParser(), + new LinelessBuildParser(), + new InvalidTargetProjectViewPackageParser( + projectViewSet, "no such package '(.*)': BUILD file not found on package path"), + new InvalidTargetProjectViewPackageParser( + projectViewSet, "ERROR: invalid target format '(.*?)'"), + new FileNotFoundBuildParser(workspaceRoot) + ) + .build(); + } + + // When it comes to target detection, it's highly probable that we'll encounter files that aren't + // associated with any target. We aim to avoid raising visible errors in such cases. + public static ImmutableList targetDetectionQueryParsers( Project project, - WorkspaceRoot workspaceRoot, - BlazeInvocationContext.ContextType invocationContext) { + WorkspaceRoot workspaceRoot) { + ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet(); + if (projectViewSet == null) { + // some parsers will work regardless, but don't even bother splitting them if there's no + // project view available + return ImmutableList.of(); + } + + return ImmutableList.builder() + .addAll(commonParsers(project, workspaceRoot, projectViewSet)) + .add(GenericErrorParser.FOR_TARGET_DETECTION_QUERY) + .build(); + } + + public static ImmutableList defaultIssueParsers( + Project project, + WorkspaceRoot workspaceRoot, + BlazeInvocationContext.ContextType invocationContext) { ProjectViewSet projectViewSet = ProjectViewManager.getInstance(project).getProjectViewSet(); if (projectViewSet == null) { // some parsers will work regardless, but don't even bother splitting them if there's no @@ -63,25 +101,15 @@ public static ImmutableList defaultIssueParsers( ImmutableList.Builder parsers = ImmutableList.builder() .add( - new BlazeIssueParser.PythonCompileParser(project), - new BlazeIssueParser.DefaultCompileParser(project), - new BlazeIssueParser.TracebackParser(), - new BlazeIssueParser.BuildParser(), - new BlazeIssueParser.SkylarkErrorParser(), - new BlazeIssueParser.LinelessBuildParser(), new BlazeIssueParser.ProjectViewLabelParser(projectViewSet), - new BlazeIssueParser.InvalidTargetProjectViewPackageParser( - projectViewSet, "no such package '(.*)': BUILD file not found on package path"), new BlazeIssueParser.InvalidTargetProjectViewPackageParser( projectViewSet, "no targets found beneath '(.*?)'"), new BlazeIssueParser.InvalidTargetProjectViewPackageParser( - projectViewSet, "ERROR: invalid target format '(.*?)'"), - new BlazeIssueParser.InvalidTargetProjectViewPackageParser( - projectViewSet, "ERROR: Skipping '(.*?)'"), - new BlazeIssueParser.FileNotFoundBuildParser(workspaceRoot)) - .addAll(BlazeIssueParserProvider.getAllIssueParsers(project)); + projectViewSet, "ERROR: Skipping '(.*?)'") + ) + .addAll(commonParsers(project, workspaceRoot, projectViewSet)); if (invocationContext == BlazeInvocationContext.ContextType.Sync) { - parsers.add(BlazeIssueParser.GenericErrorParser.INSTANCE); + parsers.add(BlazeIssueParser.GenericErrorParser.FOR_SYNC); } return parsers.build(); } @@ -432,21 +460,29 @@ protected IssueOutput createIssue(Matcher matcher) { * parsers. Avoids parsing build/test failure notifications. */ static class GenericErrorParser extends SingleLineParser { - static final GenericErrorParser INSTANCE = new GenericErrorParser(); // Match either specific blacklisted patterns we don't want, or the generic error message we do. // Then throw away the blacklisted matches later. - private static final String PATTERN = - "^ERROR: (?:" - + "(//.+?: Exit [0-9]+\\.)|" - + "(.*: Process exited with status [0-9]+\\.)|" - + "(build interrupted\\.)|" - + "(Couldn't start the build. Unable to run tests.)|" - + "(" + BAZEL_BUILD_FILES_PATTERN + ":[0-9]+:[0-9]+: Couldn't build file .*)|" - + "(.*))$"; - - private GenericErrorParser() { - super(PATTERN); + private static final ImmutableList COMMON_PATTERNS = ImmutableList.of( + "(//.+?: Exit [0-9]+\\.)", + "(.*: Process exited with status [0-9]+\\.)", + "(build interrupted\\.)", + "(Couldn't start the build. Unable to run tests.)", + "(" + BAZEL_BUILD_FILES_PATTERN + ":[0-9]+:[0-9]+: Couldn't build file .*)"); + + private static final ImmutableList QUERY_PATTERNS = ImmutableList.of( + "(Skipping '//.+': no such target '//.+': target '.*' not declared in package '.+' defined by .+)", + "(Skipping '//.+': no targets found beneath '.+')" + ); + + private static final ImmutableList PATTERN_FOR_DETECTION_QUERY = ImmutableList.copyOf(Streams.concat(COMMON_PATTERNS.stream(), QUERY_PATTERNS.stream()).toList()); + private static final ImmutableList PATTERN_FOR_SYNC = COMMON_PATTERNS; + + static final GenericErrorParser FOR_SYNC = new GenericErrorParser(PATTERN_FOR_SYNC); + static final GenericErrorParser FOR_TARGET_DETECTION_QUERY = new GenericErrorParser(PATTERN_FOR_DETECTION_QUERY); + + private GenericErrorParser(ImmutableList ignoredPatterns) { + super("^ERROR: (?:" + String.join("|", ImmutableList.builder().addAll(ignoredPatterns).add("(.*)").build()) + ")$"); } @Nullable diff --git a/base/src/com/google/idea/blaze/base/qsync/BazelDependencyBuilder.java b/base/src/com/google/idea/blaze/base/qsync/BazelDependencyBuilder.java index 4553f508f59..20ffc033eed 100644 --- a/base/src/com/google/idea/blaze/base/qsync/BazelDependencyBuilder.java +++ b/base/src/com/google/idea/blaze/base/qsync/BazelDependencyBuilder.java @@ -30,6 +30,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import com.google.common.io.CharSource; +import com.google.common.io.MoreFiles; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.Uninterruptibles; @@ -79,7 +81,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; import java.time.Instant; import java.util.Collection; import java.util.List; @@ -224,6 +225,10 @@ public OutputInfo build( } } + protected CharSource getAspect() throws IOException { + return MoreFiles.asCharSource(getBundledAspectPath(), UTF_8); + } + protected Path getBundledAspectPath() { PluginDescriptor plugin = checkNotNull(PluginManager.getPluginByClass(getClass())); return Paths.get(plugin.getPluginPath().toString(), "aspect", "build_dependencies.bzl"); @@ -236,12 +241,23 @@ protected Path getBundledAspectPath() { * the name of the aspect within that file. For example, {@code //package:aspect.bzl}. */ protected String prepareAspect(BlazeContext context) throws IOException, BuildException { - Path aspect = getBundledAspectPath(); - Files.copy( - aspect, - workspaceRoot.directory().toPath().resolve(".aswb.bzl"), - StandardCopyOption.REPLACE_EXISTING); - return "//:.aswb.bzl"; + Label generatedAspectLabel = getGeneratedAspectLabel(); + Path generatedAspect = + workspaceRoot + .path() + .resolve(generatedAspectLabel.getPackage()) + .resolve(generatedAspectLabel.getName()); + Files.writeString(generatedAspect, getAspect().read()); + // bazel asks BUILD file exists with the .bzl file. It's ok that BUILD file contains nothing. + Path buildPath = generatedAspect.resolveSibling("BUILD"); + if (!Files.exists(buildPath)) { + Files.createFile(buildPath); + } + return generatedAspectLabel.toString(); + } + + protected Label getGeneratedAspectLabel() { + return Label.of("//.aswb:build_dependencies.bzl"); } private OutputInfo createOutputInfo( diff --git a/base/src/com/google/idea/blaze/base/qsync/BazelVersionHandler.java b/base/src/com/google/idea/blaze/base/qsync/BazelVersionHandler.java new file mode 100644 index 00000000000..81544f6a787 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/qsync/BazelVersionHandler.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.blaze.base.qsync; + +import com.google.idea.blaze.base.bazel.BuildSystem; +import com.google.idea.blaze.base.bazel.BuildSystem.BuildInvoker; +import com.google.idea.blaze.base.sync.SyncScope.SyncFailedException; +import com.google.idea.blaze.exception.BuildException; +import java.util.Optional; + +/** + * Helps to collect bazel version by using {@link BuildSystem} and {@link BuildInvoker}. Handle + * exception casting to avoid sync runner to handle too many exceptions. + */ +public class BazelVersionHandler { + BuildSystem buildSystem; + BuildInvoker buildInvoker; + + public BazelVersionHandler(BuildSystem buildSystem, BuildInvoker buildInvoker) { + this.buildSystem = buildSystem; + this.buildInvoker = buildInvoker; + } + + public Optional getBazelVersion() throws BuildException { + try { + return buildSystem.getBazelVersionString(buildInvoker.getBlazeInfo()); + } catch (SyncFailedException e) { + throw new BuildException( + "Could not get bazel version, incorrect aspect file may be used. ", e); + } + } +} diff --git a/base/src/com/google/idea/blaze/base/qsync/DependencyTrackerImpl.java b/base/src/com/google/idea/blaze/base/qsync/DependencyTrackerImpl.java index bfac552ec67..79f0b43786c 100644 --- a/base/src/com/google/idea/blaze/base/qsync/DependencyTrackerImpl.java +++ b/base/src/com/google/idea/blaze/base/qsync/DependencyTrackerImpl.java @@ -31,9 +31,9 @@ import com.google.idea.blaze.common.PrintOutput; import com.google.idea.blaze.exception.BuildException; import com.google.idea.blaze.qsync.BlazeProject; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.deps.ArtifactTracker; import com.google.idea.blaze.qsync.deps.OutputInfo; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.DependencyTrackingBehavior; import com.google.idea.blaze.qsync.project.ProjectDefinition; import com.google.idea.blaze.qsync.project.RequestedTargets; diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectLoader.java b/base/src/com/google/idea/blaze/base/qsync/ProjectLoader.java index 20ddc85426f..4faa46f3fb1 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectLoader.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectLoader.java @@ -48,8 +48,7 @@ import com.google.idea.blaze.exception.BuildException; import com.google.idea.blaze.qsync.BlazeProject; import com.google.idea.blaze.qsync.BlazeProjectSnapshotBuilder; -import com.google.idea.blaze.qsync.ProjectProtoTransform; -import com.google.idea.blaze.qsync.ProjectProtoTransform.Registry; +import com.google.idea.blaze.qsync.DependenciesProjectProtoUpdater; import com.google.idea.blaze.qsync.ProjectRefresher; import com.google.idea.blaze.qsync.VcsStateDiffer; import com.google.idea.blaze.qsync.deps.ArtifactTracker; @@ -58,6 +57,8 @@ import com.google.idea.blaze.qsync.java.ParallelPackageReader; import com.google.idea.blaze.qsync.project.ProjectDefinition; import com.google.idea.blaze.qsync.project.ProjectPath; +import com.google.idea.blaze.qsync.project.ProjectProtoTransform; +import com.google.idea.blaze.qsync.project.ProjectProtoTransform.Registry; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.SimpleModificationTracker; @@ -154,6 +155,13 @@ public QuerySyncProject loadProject(BlazeContext context) throws BuildException NewArtifactTracker tracker = new NewArtifactTracker<>( BlazeDataStorage.getProjectDataDir(importSettings).toPath(), artifactCache); + projectTransformRegistry.add( + new DependenciesProjectProtoUpdater( + tracker, + latestProjectDef, + artifactCache, + projectPathResolver, + QuerySync.ATTACH_DEP_SRCJARS::getValue)); artifactTracker = tracker; renderJarArtifactTracker = new RenderJarArtifactTrackerImpl(); @@ -197,7 +205,12 @@ public QuerySyncProject loadProject(BlazeContext context) throws BuildException () -> !QuerySync.EXTRACT_RES_PACKAGES_AT_BUILD_TIME.getValue(), QuerySync.USE_NEW_BUILD_ARTIFACT_MANAGEMENT); QueryRunner queryRunner = createQueryRunner(buildSystem); - ProjectQuerier projectQuerier = createProjectQuerier(projectRefresher, queryRunner, vcsHandler); + ProjectQuerier projectQuerier = + createProjectQuerier( + projectRefresher, + queryRunner, + vcsHandler, + new BazelVersionHandler(buildSystem, buildSystem.getBuildInvoker(project, context))); QuerySyncSourceToTargetMap sourceToTargetMap = new QuerySyncSourceToTargetMap(graph, workspaceRoot.path()); @@ -209,6 +222,7 @@ public QuerySyncProject loadProject(BlazeContext context) throws BuildException importSettings, workspaceRoot, artifactTracker, + artifactCache, artifactStore, renderJarArtifactTracker, appInspectorArtifactTracker, @@ -227,6 +241,7 @@ public QuerySyncProject loadProject(BlazeContext context) throws BuildException buildSystem, projectTransformRegistry); BlazeProjectListenerProvider.registerListenersFor(querySyncProject); + projectTransformRegistry.addAll(ProjectProtoTransformProvider.getAll(querySyncProject)); return querySyncProject; } @@ -238,8 +253,9 @@ private ParallelPackageReader createWorkspaceRelativePackageReader() { private ProjectQuerierImpl createProjectQuerier( ProjectRefresher projectRefresher, QueryRunner queryRunner, - Optional vcsHandler) { - return new ProjectQuerierImpl(queryRunner, projectRefresher, vcsHandler); + Optional vcsHandler, + BazelVersionHandler bazelVersionProvider) { + return new ProjectQuerierImpl(queryRunner, projectRefresher, vcsHandler, bazelVersionProvider); } protected QueryRunner createQueryRunner(BuildSystem buildSystem) { diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectProtoTransformProvider.java b/base/src/com/google/idea/blaze/base/qsync/ProjectProtoTransformProvider.java new file mode 100644 index 00000000000..8e1985d49e6 --- /dev/null +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectProtoTransformProvider.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.idea.blaze.base.qsync; + +import com.google.common.collect.ImmutableList; +import com.google.idea.blaze.qsync.project.ProjectProtoTransform; +import com.intellij.openapi.extensions.ExtensionPointName; +import java.util.List; + +/** + * Provides a {@link ProjectProtoTransform} that requires AS specific dependencies so cannot be + * created directly by the base code. + */ +public interface ProjectProtoTransformProvider { + + ExtensionPointName EP_NAME = + new ExtensionPointName<>("com.google.idea.blaze.base.qsync.ProjectProtoTransformProvider"); + + static ImmutableList getAll(QuerySyncProject project) { + return EP_NAME.getExtensionList().stream() + .map(ep -> ep.createTransforms(project)) + .flatMap(List::stream) + .collect(ImmutableList.toImmutableList()); + } + + List createTransforms(QuerySyncProject project); +} diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java b/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java index b818392d016..a0232f05dc2 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectQuerierImpl.java @@ -45,14 +45,18 @@ public class ProjectQuerierImpl implements ProjectQuerier { private final ProjectRefresher projectRefresher; private final Optional vcsHandler; + private final BazelVersionHandler bazelVersionProvider; + @VisibleForTesting public ProjectQuerierImpl( QueryRunner queryRunner, ProjectRefresher projectRefresher, - Optional vcsHandler) { + Optional vcsHandler, + BazelVersionHandler bazelVersionProvider) { this.queryRunner = queryRunner; this.projectRefresher = projectRefresher; this.vcsHandler = vcsHandler; + this.bazelVersionProvider = bazelVersionProvider; } /** @@ -74,7 +78,9 @@ public PostQuerySyncData fullQuery(ProjectDefinition projectDef, BlazeContext co vcsState.map(s -> s.upstreamRevision).orElse(""), vcsState.flatMap(s -> s.workspaceSnapshotPath).map(Object::toString).orElse(""))); - RefreshOperation fullQuery = projectRefresher.startFullUpdate(context, projectDef, vcsState); + RefreshOperation fullQuery = + projectRefresher.startFullUpdate( + context, projectDef, vcsState, bazelVersionProvider.getBazelVersion()); QuerySpec querySpec = fullQuery.getQuerySpec().get(); return fullQuery.createPostQuerySyncData(queryRunner.runQuery(querySpec, context)); @@ -124,7 +130,12 @@ public PostQuerySyncData update( vcsState.flatMap(s -> s.workspaceSnapshotPath).map(Object::toString).orElse(""))); RefreshOperation refresh = - projectRefresher.startPartialRefresh(context, previousState, vcsState, currentProjectDef); + projectRefresher.startPartialRefresh( + context, + previousState, + vcsState, + bazelVersionProvider.getBazelVersion(), + currentProjectDef); Optional spec = refresh.getQuerySpec(); QuerySummary querySummary; diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectStatsLogger.java b/base/src/com/google/idea/blaze/base/qsync/ProjectStatsLogger.java index 8dc5df94d12..2ee57c02323 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectStatsLogger.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectStatsLogger.java @@ -24,8 +24,8 @@ import com.google.idea.blaze.base.projectview.section.sections.TryImportSection; import com.google.idea.blaze.common.Context; import com.google.idea.blaze.qsync.BlazeProjectListener; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.deps.ArtifactTracker; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; import java.util.Optional; /** Updates project info according to the newly generated build graph. */ diff --git a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java index bd86e423785..416d20450b1 100644 --- a/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java +++ b/base/src/com/google/idea/blaze/base/qsync/ProjectUpdater.java @@ -35,7 +35,7 @@ import com.google.idea.blaze.common.PrintOutput; import com.google.idea.blaze.exception.BuildException; import com.google.idea.blaze.qsync.BlazeProjectListener; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.ProjectPath; import com.google.idea.blaze.qsync.project.ProjectProto; import com.google.idea.blaze.qsync.project.ProjectProto.LibrarySource; diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncManager.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncManager.java index d307ce12910..3352467bea1 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncManager.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncManager.java @@ -44,8 +44,8 @@ import com.google.idea.blaze.common.Label; import com.google.idea.blaze.common.PrintOutput; import com.google.idea.blaze.exception.BuildException; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.deps.ArtifactTracker; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.PostQuerySyncData; import com.google.idea.blaze.qsync.project.ProjectDefinition; import com.google.idea.blaze.qsync.project.TargetsToBuild; diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncProject.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncProject.java index 7b420b0f796..1b3e35fd581 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncProject.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncProject.java @@ -45,16 +45,17 @@ import com.google.idea.blaze.base.util.SaveUtil; import com.google.idea.blaze.common.Label; import com.google.idea.blaze.common.PrintOutput; +import com.google.idea.blaze.common.artifact.BuildArtifactCache; import com.google.idea.blaze.common.vcs.VcsState; import com.google.idea.blaze.exception.BuildException; import com.google.idea.blaze.qsync.BlazeProject; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.BlazeProjectSnapshotBuilder; -import com.google.idea.blaze.qsync.ProjectProtoTransform; import com.google.idea.blaze.qsync.deps.ArtifactTracker; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.PostQuerySyncData; import com.google.idea.blaze.qsync.project.ProjectDefinition; import com.google.idea.blaze.qsync.project.ProjectPath; +import com.google.idea.blaze.qsync.project.ProjectProtoTransform; import com.google.idea.blaze.qsync.project.SnapshotDeserializer; import com.google.idea.blaze.qsync.project.SnapshotSerializer; import com.google.idea.blaze.qsync.project.TargetsToBuild; @@ -89,6 +90,7 @@ public class QuerySyncProject { private final BlazeImportSettings importSettings; private final WorkspaceRoot workspaceRoot; private final ArtifactTracker artifactTracker; + private final BuildArtifactCache buildArtifactCache; private final ProjectArtifactStore artifactStore; private final RenderJarArtifactTracker renderJarArtifactTracker; private final AppInspectorArtifactTracker appInspectorArtifactTracker; @@ -118,6 +120,7 @@ public QuerySyncProject( BlazeImportSettings importSettings, WorkspaceRoot workspaceRoot, ArtifactTracker artifactTracker, + BuildArtifactCache buildArtifactCache, ProjectArtifactStore artifactStore, RenderJarArtifactTracker renderJarArtifactTracker, AppInspectorArtifactTracker appInspectorArtifactTracker, @@ -141,6 +144,7 @@ public QuerySyncProject( this.importSettings = importSettings; this.workspaceRoot = workspaceRoot; this.artifactTracker = artifactTracker; + this.buildArtifactCache = buildArtifactCache; this.artifactStore = artifactStore; this.renderJarArtifactTracker = renderJarArtifactTracker; this.appInspectorArtifactTracker = appInspectorArtifactTracker; @@ -193,6 +197,10 @@ public ProjectPath.Resolver getProjectPathResolver() { return projectPathResolver; } + public BuildArtifactCache getBuildArtifactCache() { + return buildArtifactCache; + } + public ProjectArtifactStore getArtifactStore() { return artifactStore; } @@ -253,7 +261,10 @@ public void sync(BlazeContext parentContext, Optional lastQue : projectQuerier.update(projectDefinition, lastQuery.get(), context); BlazeProjectSnapshot newSnapshot = blazeProjectSnapshotBuilder.createBlazeProjectSnapshot( - context, postQuerySyncData, projectProtoTransforms.getComposedTransform()); + context, + postQuerySyncData, + artifactTracker.getStateSnapshot(), + projectProtoTransforms.getComposedTransform()); onNewSnapshot(context, newSnapshot); // TODO: Revisit SyncListeners once we switch fully to qsync @@ -332,6 +343,7 @@ public void build(BlazeContext parentContext, DependencyTracker.DependencyBuildR blazeProjectSnapshotBuilder.createBlazeProjectSnapshot( context, snapshotHolder.getCurrent().orElseThrow().queryData(), + artifactTracker.getStateSnapshot(), projectProtoTransforms.getComposedTransform()); onNewSnapshot(context, newSnapshot); } diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncProjectData.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncProjectData.java index 3d4f99e714e..f0dce652b5f 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncProjectData.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncProjectData.java @@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.idea.blaze.base.bazel.BazelVersion; import com.google.idea.blaze.base.command.info.BlazeInfo; import com.google.idea.blaze.base.dependencies.TargetInfo; import com.google.idea.blaze.base.ideinfo.TargetMap; @@ -29,7 +30,7 @@ import com.google.idea.blaze.base.sync.projectview.WorkspaceLanguageSettings; import com.google.idea.blaze.base.sync.workspace.ArtifactLocationDecoder; import com.google.idea.blaze.base.sync.workspace.WorkspacePathResolver; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.ProjectTarget; import com.google.idea.blaze.qsync.project.QuerySyncLanguage; import com.intellij.openapi.diagnostic.Logger; @@ -145,18 +146,21 @@ public BlazeVersionData getBlazeVersionData() { // assumes that the base VCS revision is a decimal integer, which may not be true. logger.warn("Usage of legacy getBlazeVersionData"); BlazeVersionData.Builder data = BlazeVersionData.builder(); - String baseRev = - blazeProject - .flatMap(p -> p.queryData().vcsState()) - .map(q -> q.upstreamRevision) - .orElse(null); - if (baseRev != null) { - try { - data.setClientCl(Long.parseLong(baseRev)); - } catch (NumberFormatException e) { - logger.warn(e); - } - } + blazeProject + .flatMap(p -> p.queryData().vcsState()) + .map(q -> q.upstreamRevision) + .ifPresent( + revision -> { + try { + data.setClientCl(Long.parseLong(revision)); + } catch (NumberFormatException e) { + logger.warn(e); + } + }); + blazeProject + .flatMap(p -> p.queryData().bazelVersion()) + .ifPresent(version -> data.setBazelVersion(BazelVersion.parseVersion(version))); + return data.build(); } diff --git a/base/src/com/google/idea/blaze/base/qsync/QuerySyncSourceToTargetMap.java b/base/src/com/google/idea/blaze/base/qsync/QuerySyncSourceToTargetMap.java index c0791b1e993..1a7de63f93a 100644 --- a/base/src/com/google/idea/blaze/base/qsync/QuerySyncSourceToTargetMap.java +++ b/base/src/com/google/idea/blaze/base/qsync/QuerySyncSourceToTargetMap.java @@ -22,7 +22,7 @@ import com.google.idea.blaze.base.model.primitives.Label; import com.google.idea.blaze.base.targetmaps.SourceToTargetMap; import com.google.idea.blaze.qsync.BlazeProject; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.intellij.openapi.diagnostic.Logger; import java.io.File; import java.nio.file.Path; diff --git a/base/src/com/google/idea/blaze/base/qsync/RenderJarTrackerImpl.java b/base/src/com/google/idea/blaze/base/qsync/RenderJarTrackerImpl.java index a29f5ccefcc..a0142ee5f87 100644 --- a/base/src/com/google/idea/blaze/base/qsync/RenderJarTrackerImpl.java +++ b/base/src/com/google/idea/blaze/base/qsync/RenderJarTrackerImpl.java @@ -24,7 +24,7 @@ import com.google.idea.blaze.common.PrintOutput; import com.google.idea.blaze.exception.BuildException; import com.google.idea.blaze.qsync.BlazeProject; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import java.io.IOException; import java.nio.file.Path; import java.util.HashSet; diff --git a/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForProjectAction.java b/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForProjectAction.java index 56587319f93..82f0d66b505 100644 --- a/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForProjectAction.java +++ b/base/src/com/google/idea/blaze/base/qsync/action/BuildDependenciesForProjectAction.java @@ -19,7 +19,7 @@ import com.google.idea.blaze.base.logging.utils.querysync.QuerySyncActionStatsScope; import com.google.idea.blaze.base.qsync.QuerySyncManager; import com.google.idea.blaze.base.qsync.QuerySyncManager.TaskOrigin; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.intellij.openapi.actionSystem.ActionUpdateThread; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.diagnostic.Logger; diff --git a/base/src/com/google/idea/blaze/base/qsync/artifacts/ProjectArtifactStore.java b/base/src/com/google/idea/blaze/base/qsync/artifacts/ProjectArtifactStore.java index 2cd9788512b..18555ae98d1 100644 --- a/base/src/com/google/idea/blaze/base/qsync/artifacts/ProjectArtifactStore.java +++ b/base/src/com/google/idea/blaze/base/qsync/artifacts/ProjectArtifactStore.java @@ -21,8 +21,8 @@ import com.google.idea.blaze.common.Context; import com.google.idea.blaze.common.artifact.BuildArtifactCache; import com.google.idea.blaze.exception.BuildException; +import com.google.idea.blaze.qsync.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.artifacts.ArtifactDirectoryUpdate; -import com.google.idea.blaze.qsync.project.BlazeProjectSnapshot; import com.google.idea.blaze.qsync.project.ProjectProto.ArtifactDirectories; import com.google.idea.blaze.qsync.project.ProjectProto.ArtifactDirectoryContents; import java.io.IOException; diff --git a/base/src/com/google/idea/blaze/base/qsync/cache/ArtifactTrackerImpl.java b/base/src/com/google/idea/blaze/base/qsync/cache/ArtifactTrackerImpl.java index f2e8dea58e9..22e0e76f60a 100644 --- a/base/src/com/google/idea/blaze/base/qsync/cache/ArtifactTrackerImpl.java +++ b/base/src/com/google/idea/blaze/base/qsync/cache/ArtifactTrackerImpl.java @@ -70,17 +70,15 @@ import com.google.idea.blaze.common.artifact.OutputArtifact; import com.google.idea.blaze.common.proto.ProtoStringInterner; import com.google.idea.blaze.exception.BuildException; -import com.google.idea.blaze.qsync.ProjectProtoTransform; -import com.google.idea.blaze.qsync.TestSourceGlobMatcher; import com.google.idea.blaze.qsync.artifacts.BuildArtifact; import com.google.idea.blaze.qsync.cc.CcDependenciesInfo; import com.google.idea.blaze.qsync.deps.ArtifactTracker; +import com.google.idea.blaze.qsync.deps.JavaArtifactInfo; import com.google.idea.blaze.qsync.deps.OutputGroup; import com.google.idea.blaze.qsync.deps.OutputInfo; import com.google.idea.blaze.qsync.java.AndroidResPackagesProjectUpdater; import com.google.idea.blaze.qsync.java.GeneratedSourceProjectUpdater; import com.google.idea.blaze.qsync.java.GeneratedSourceProjectUpdater.GeneratedSourceJar; -import com.google.idea.blaze.qsync.java.JavaArtifactInfo; import com.google.idea.blaze.qsync.java.JavaTargetInfo.JavaArtifacts; import com.google.idea.blaze.qsync.java.JavaTargetInfo.JavaTargetArtifacts; import com.google.idea.blaze.qsync.java.SrcJarProjectUpdater; @@ -89,6 +87,8 @@ import com.google.idea.blaze.qsync.project.ProjectDefinition; import com.google.idea.blaze.qsync.project.ProjectPath; import com.google.idea.blaze.qsync.project.ProjectProto; +import com.google.idea.blaze.qsync.project.ProjectProtoTransform; +import com.google.idea.blaze.qsync.project.TestSourceGlobMatcher; import com.google.protobuf.ExtensionRegistry; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtilRt; @@ -739,6 +739,11 @@ private ProjectProto.Project updateProjectProtoForJavaDeps(ProjectProto.Project return projectProto; } + @Override + public ArtifactTracker.State getStateSnapshot() { + return State.EMPTY; + } + @Override public Set