From 3c4a98ab8d728782981c192ee6047c3ac33f85e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20L=C3=A1zaro?= Date: Sat, 2 Aug 2025 17:35:18 -0700 Subject: [PATCH] Upgrades to bazel 7 --- .bazelrc | 7 ++ .bazelversion | 2 +- .gitignore | 3 +- BUILD.bazel | 3 - MODULE.bazel | 6 ++ MODULE.bazel.lock | 64 +++++++++++++++++++ WORKSPACE | 11 +++- language/scala/BUILD.bazel | 4 -- language/scala/diff_test.go | 18 +++--- .../protobuf_provider/proto/BUILD.out | 4 +- pkg/scalaconfig/config.go | 4 ++ pkg/scalaconfig/config_test.go | 2 +- workspace_deps.bzl | 48 +++++--------- 13 files changed, 121 insertions(+), 55 deletions(-) create mode 100644 MODULE.bazel create mode 100644 MODULE.bazel.lock diff --git a/.bazelrc b/.bazelrc index 7359f235..7fb1aa71 100644 --- a/.bazelrc +++ b/.bazelrc @@ -2,3 +2,10 @@ build --incompatible_java_common_parameters=false query --output=label_kind + +build --java_language_version=17 +build --java_runtime_version=remotejdk_17 + +# For now keep bzlmod support disabled and workspace enabled +build --enable_workspace +build --noenable_bzlmod \ No newline at end of file diff --git a/.bazelversion b/.bazelversion index 19b860c1..e8be6840 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -6.4.0 +7.6.1 diff --git a/.gitignore b/.gitignore index 3a847ef3..7d68ddb9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /pkg/parser/node.exe /bazel-* /.vscode/ -/examples/ \ No newline at end of file +/examples/ +.idea/ \ No newline at end of file diff --git a/BUILD.bazel b/BUILD.bazel index 2e18d681..f17531e4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -106,9 +106,6 @@ package_filegroup( "//cmd/semanticdbmerge:filegroup", "//cmd/wildcardimportfixer:filegroup", "//docs/architecture:filegroup", - "//examples:filegroup", - "//examples/java_index:filegroup", - "//examples/protobuf_index:filegroup", "//language/files:filegroup", "//language/scala:filegroup", "//pkg/autokeep:filegroup", diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 00000000..00bb1836 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,6 @@ +############################################################################### +# Bazel now uses Bzlmod by default to manage external dependencies. +# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. +# +# For more details, please check https://github.com/bazelbuild/bazel/issues/18958 +############################################################################### diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock new file mode 100644 index 00000000..2f4b509c --- /dev/null +++ b/MODULE.bazel.lock @@ -0,0 +1,64 @@ +{ + "lockFileVersion": 13, + "registryFileHashes": { + "https://bcr.bazel.build/bazel_registry.json": "8a28e4aff06ee60aed2a8c281907fb8bcbf3b753c91fb5a5c57da3215d5b3497", + "https://bcr.bazel.build/modules/abseil-cpp/20210324.2/MODULE.bazel": "7cd0312e064fde87c8d1cd79ba06c876bd23630c83466e9500321be55c96ace2", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/MODULE.bazel": "70390338f7a5106231d20620712f7cccb659cd0e9d073d1991c038eb9fc57589", + "https://bcr.bazel.build/modules/abseil-cpp/20211102.0/source.json": "7e3a9adf473e9af076ae485ed649d5641ad50ec5c11718103f34de03170d94ad", + "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", + "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", + "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", + "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", + "https://bcr.bazel.build/modules/bazel_skylib/1.2.1/MODULE.bazel": "f35baf9da0efe45fa3da1696ae906eea3d615ad41e2e3def4aeb4e8bc0ef9a7a", + "https://bcr.bazel.build/modules/bazel_skylib/1.3.0/MODULE.bazel": "20228b92868bf5cfc41bda7afc8a8ba2a543201851de39d990ec957b513579c5", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/MODULE.bazel": "8fdee2dbaace6c252131c00e1de4b165dc65af02ea278476187765e1a617b917", + "https://bcr.bazel.build/modules/bazel_skylib/1.6.1/source.json": "082ed5f9837901fada8c68c2f3ddc958bb22b6d654f71dd73f3df30d45d4b749", + "https://bcr.bazel.build/modules/buildozer/7.1.2/MODULE.bazel": "2e8dd40ede9c454042645fd8d8d0cd1527966aa5c919de86661e62953cd73d84", + "https://bcr.bazel.build/modules/buildozer/7.1.2/source.json": "c9028a501d2db85793a6996205c8de120944f50a0d570438fcae0457a5f9d1f8", + "https://bcr.bazel.build/modules/googletest/1.11.0/MODULE.bazel": "3a83f095183f66345ca86aa13c58b59f9f94a2f81999c093d4eeaa2d262d12f4", + "https://bcr.bazel.build/modules/googletest/1.11.0/source.json": "c73d9ef4268c91bd0c1cd88f1f9dfa08e814b1dbe89b5f594a9f08ba0244d206", + "https://bcr.bazel.build/modules/platforms/0.0.4/MODULE.bazel": "9b328e31ee156f53f3c416a64f8491f7eb731742655a47c9eec4703a71644aee", + "https://bcr.bazel.build/modules/platforms/0.0.5/MODULE.bazel": "5733b54ea419d5eaf7997054bb55f6a1d0b5ff8aedf0176fef9eea44f3acda37", + "https://bcr.bazel.build/modules/platforms/0.0.6/MODULE.bazel": "ad6eeef431dc52aefd2d77ed20a4b353f8ebf0f4ecdd26a807d2da5aa8cd0615", + "https://bcr.bazel.build/modules/platforms/0.0.7/MODULE.bazel": "72fd4a0ede9ee5c021f6a8dd92b503e089f46c227ba2813ff183b71616034814", + "https://bcr.bazel.build/modules/platforms/0.0.9/MODULE.bazel": "4a87a60c927b56ddd67db50c89acaa62f4ce2a1d2149ccb63ffd871d5ce29ebc", + "https://bcr.bazel.build/modules/platforms/0.0.9/source.json": "cd74d854bf16a9e002fb2ca7b1a421f4403cda29f824a765acd3a8c56f8d43e6", + "https://bcr.bazel.build/modules/protobuf/21.7/MODULE.bazel": "a5a29bb89544f9b97edce05642fac225a808b5b7be74038ea3640fae2f8e66a7", + "https://bcr.bazel.build/modules/protobuf/21.7/source.json": "bbe500720421e582ff2d18b0802464205138c06056f443184de39fbb8187b09b", + "https://bcr.bazel.build/modules/protobuf/3.19.0/MODULE.bazel": "6b5fbb433f760a99a22b18b6850ed5784ef0e9928a72668b66e4d7ccd47db9b0", + "https://bcr.bazel.build/modules/protobuf/3.19.6/MODULE.bazel": "9233edc5e1f2ee276a60de3eaa47ac4132302ef9643238f23128fea53ea12858", + "https://bcr.bazel.build/modules/rules_cc/0.0.1/MODULE.bazel": "cb2aa0747f84c6c3a78dad4e2049c154f08ab9d166b1273835a8174940365647", + "https://bcr.bazel.build/modules/rules_cc/0.0.2/MODULE.bazel": "6915987c90970493ab97393024c156ea8fb9f3bea953b2f3ec05c34f19b5695c", + "https://bcr.bazel.build/modules/rules_cc/0.0.8/MODULE.bazel": "964c85c82cfeb6f3855e6a07054fdb159aced38e99a5eecf7bce9d53990afa3e", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/MODULE.bazel": "836e76439f354b89afe6a911a7adf59a6b2518fafb174483ad78a2a2fde7b1c5", + "https://bcr.bazel.build/modules/rules_cc/0.0.9/source.json": "1f1ba6fea244b616de4a554a0f4983c91a9301640c8fe0dd1d410254115c8430", + "https://bcr.bazel.build/modules/rules_java/4.0.0/MODULE.bazel": "5a78a7ae82cd1a33cef56dc578c7d2a46ed0dca12643ee45edbb8417899e6f74", + "https://bcr.bazel.build/modules/rules_java/7.6.5/MODULE.bazel": "481164be5e02e4cab6e77a36927683263be56b7e36fef918b458d7a8a1ebadb1", + "https://bcr.bazel.build/modules/rules_java/7.6.5/source.json": "a805b889531d1690e3c72a7a7e47a870d00323186a9904b36af83aa3d053ee8d", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/MODULE.bazel": "a56b85e418c83eb1839819f0b515c431010160383306d13ec21959ac412d2fe7", + "https://bcr.bazel.build/modules/rules_jvm_external/4.4.2/source.json": "a075731e1b46bc8425098512d038d416e966ab19684a10a34f4741295642fc35", + "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", + "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", + "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", + "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", + "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/MODULE.bazel": "e8dff86b0971688790ae75528fe1813f71809b5afd57facb44dad9e8eca631b7", + "https://bcr.bazel.build/modules/rules_proto/5.3.0-21.7/source.json": "d57902c052424dfda0e71646cb12668d39c4620ee0544294d9d941e7d12bc3a9", + "https://bcr.bazel.build/modules/rules_python/0.10.2/MODULE.bazel": "cc82bc96f2997baa545ab3ce73f196d040ffb8756fd2d66125a530031cd90e5f", + "https://bcr.bazel.build/modules/rules_python/0.22.1/MODULE.bazel": "26114f0c0b5e93018c0c066d6673f1a2c3737c7e90af95eff30cfee38d0bbac7", + "https://bcr.bazel.build/modules/rules_python/0.22.1/source.json": "57226905e783bae7c37c2dd662be078728e48fa28ee4324a7eabcafb5a43d014", + "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", + "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", + "https://bcr.bazel.build/modules/stardoc/0.5.1/source.json": "a96f95e02123320aa015b956f29c00cb818fa891ef823d55148e1a362caacf29", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", + "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/source.json": "f1ef7d3f9e0e26d4b23d1c39b5f5de71f584dd7d1b4ef83d9bbba6ec7a6a6459", + "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", + "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/MODULE.bazel": "af322bc08976524477c79d1e45e241b6efbeb918c497e8840b8ab116802dda79", + "https://bcr.bazel.build/modules/zlib/1.3.1.bcr.3/source.json": "2be409ac3c7601245958cd4fcdff4288be79ed23bd690b4b951f500d54ee6e7d" + }, + "selectedYankedVersions": {}, + "moduleExtensions": {} +} diff --git a/WORKSPACE b/WORKSPACE index c07ce7a2..48003bb5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -39,7 +39,16 @@ load( go_rules_dependencies() -go_register_toolchains(version = "1.18.2") +go_register_toolchains(version = "1.24.5") + +# Create the host platform repository transitively required by rules_go. +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") +load("@platforms//host:extension.bzl", "host_platform_repo") + +maybe( + host_platform_repo, + name = "host_platform", +) # ---------------------------------------------------- # @bazel_gazelle diff --git a/language/scala/BUILD.bazel b/language/scala/BUILD.bazel index 647a954a..e0da5d62 100644 --- a/language/scala/BUILD.bazel +++ b/language/scala/BUILD.bazel @@ -86,10 +86,6 @@ gazelle_binary( go_test( name = "scala_test", srcs = [ - # "coverage_test.go", - # "diff_test.go", - # "existing_scala_rule_test.go", - # "flags_test.go", "coverage_test.go", "diff_test.go", "existing_scala_rule_test.go", diff --git a/language/scala/diff_test.go b/language/scala/diff_test.go index 7638fc05..be08d65a 100644 --- a/language/scala/diff_test.go +++ b/language/scala/diff_test.go @@ -358,9 +358,9 @@ object B {} }, }...), wantDiff: ` ---- lib/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 -+++ lib/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 -@@ -8,5 +8,8 @@ +--- lib/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000 ++++ lib/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000 +@@ -8,4 +8,7 @@ scala_library( name = "b", srcs = ["B.scala"], @@ -415,9 +415,9 @@ object B {} }, }...), wantDiff: ` ---- b/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 -+++ b/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 -@@ -3,5 +3,8 @@ +--- b/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000 ++++ b/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000 +@@ -3,4 +3,7 @@ scala_library( name = "b", srcs = ["B.scala"], @@ -467,9 +467,9 @@ object B extends A {} }, }...), wantDiff: ` ---- lib/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 -+++ lib/BUILD.bazel 1970-01-01 00:00:00.000000000 +0000 -@@ -8,5 +8,11 @@ +--- lib/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000 ++++ lib/BUILD.bazel 1970-01-01 00:00:00.000000001 +0000 +@@ -8,4 +8,10 @@ scala_library( name = "b", srcs = ["B.scala"], diff --git a/language/scala/testdata/protobuf_provider/proto/BUILD.out b/language/scala/testdata/protobuf_provider/proto/BUILD.out index fffd555d..ad467abd 100644 --- a/language/scala/testdata/protobuf_provider/proto/BUILD.out +++ b/language/scala/testdata/protobuf_provider/proto/BUILD.out @@ -1,6 +1,6 @@ -load("@rules_proto//proto:defs.bzl", "proto_library") -load("@build_stack_rules_proto//rules/scala:proto_scala_library.bzl", "proto_scala_library") load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile") +load("@build_stack_rules_proto//rules/scala:proto_scala_library.bzl", "proto_scala_library") +load("@rules_proto//proto:defs.bzl", "proto_library") proto_library( name = "proto_proto", diff --git a/pkg/scalaconfig/config.go b/pkg/scalaconfig/config.go index 27eadc4f..1f5da16b 100644 --- a/pkg/scalaconfig/config.go +++ b/pkg/scalaconfig/config.go @@ -3,6 +3,7 @@ package scalaconfig import ( "fmt" "log" + "slices" "sort" "strconv" "strings" @@ -733,6 +734,9 @@ func (c *Config) ruleAttrMergeDeps( next := c.mergeDeps(r.Attr(attrName), deps, labels, attrName, from, r) if len(next.List) > 0 { + slices.SortFunc(next.List, func (a,b build.Expr) int { + return strings.Compare(labelFromDepExpr(a).String(), labelFromDepExpr(b).String()) + }) r.SetAttr(attrName, next) } else { r.DelAttr(attrName) diff --git a/pkg/scalaconfig/config_test.go b/pkg/scalaconfig/config_test.go index 7b92a866..18553fe3 100644 --- a/pkg/scalaconfig/config_test.go +++ b/pkg/scalaconfig/config_test.go @@ -608,7 +608,7 @@ test( expr = "@@@", ) `, - want: label.NoLabel, + want: label.New("@", "", "@"), }, "valid label": { in: ` diff --git a/workspace_deps.bzl b/workspace_deps.bzl index 756514e9..564239d3 100644 --- a/workspace_deps.bzl +++ b/workspace_deps.bzl @@ -39,17 +39,15 @@ def protobuf_core_deps(): com_google_protobuf() # via def io_bazel_rules_go(): - # Release: v0.35.0 - # TargetCommitish: release-0.35 - # Date: 2022-09-11 15:59:49 +0000 UTC - # URL: https://github.com/bazelbuild/rules_go/releases/tag/v0.35.0 - # Size: 931734 (932 kB) + # Release: v0.56.0 _maybe( http_archive, name = "io_bazel_rules_go", - sha256 = "cc027f11f98aef8bc52c472ced0714994507a16ccd3a0820b2df2d6db695facd", - strip_prefix = "rules_go-0.35.0", - urls = ["https://github.com/bazelbuild/rules_go/archive/v0.35.0.tar.gz"], + sha256 = "94643c4ce02f3b62f3be7d13d527a5c780a568073b7562606e78399929005f98", + urls = [ + "https://mirror.bazel.build/github.com/bazel-contrib/rules_go/releases/download/v0.56.0/rules_go-v0.56.0.zip", + "https://github.com/bazel-contrib/rules_go/releases/download/v0.56.0/rules_go-v0.56.0.zip", + ], ) def scalameta_parsers(): @@ -69,21 +67,14 @@ filegroup( ) def bazel_gazelle(): - # Branch: master - # Commit: 2d1002926dd160e4c787c1b7ecc60fb7d39b97dc - # Date: 2022-11-14 04:43:02 +0000 UTC - # URL: https://github.com/bazelbuild/bazel-gazelle/commit/2d1002926dd160e4c787c1b7ecc60fb7d39b97dc - # - # fix updateStmt makeslice panic (#1371) - # Size: 1859745 (1.9 MB) + # Release: v0.39.1 _maybe( http_archive, name = "bazel_gazelle", - patch_args = ["-p1"], - patches = ["@build_stack_scala_gazelle//third_party/bazelbuild/bazel-gazelle:pr-1394.patch"], - sha256 = "5ebc984c7be67a317175a9527ea1fb027c67f0b57bb0c990bac348186195f1ba", - strip_prefix = "bazel-gazelle-2d1002926dd160e4c787c1b7ecc60fb7d39b97dc", - urls = ["https://github.com/bazelbuild/bazel-gazelle/archive/2d1002926dd160e4c787c1b7ecc60fb7d39b97dc.tar.gz"], + integrity = "sha256-t2D3/nUXOIYAf3wuYWohJBII89kOhlfcZdNqdx6Ra2o=", + urls = [ + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz", + ], ) def local_bazel_gazelle(): @@ -111,21 +102,12 @@ def rules_proto(): ) def build_stack_rules_proto(): - # Branch: master - # Commit: aa380e4421057b35228544bc234f816bb6b72c1c - # Date: 2022-12-08 05:19:32 +0000 UTC - # URL: https://github.com/stackb/rules_proto/commit/aa380e4421057b35228544bc234f816bb6b72c1c - # - # use distinct impLang for scala proto exports (#304) - # - # * use distinct impLang for scala proto exports - # * fix test - # Size: 2074364 (2.1 MB) + # Release: v3.2.0 http_archive( name = "build_stack_rules_proto", - sha256 = "820dc71f2e265a50104671d323caba53790dfe20e9f7249a0e6beeaee39b4597", - strip_prefix = "rules_proto-aa380e4421057b35228544bc234f816bb6b72c1c", - urls = ["https://github.com/stackb/rules_proto/archive/aa380e4421057b35228544bc234f816bb6b72c1c.tar.gz"], + sha256 = "b7cbaf457d91e1d3c295df53b80f24e1d6da71c94ee61c42277ab938db6d1c68", + strip_prefix = "rules_proto-3.2.0", + url = "https://github.com/stackb/rules_proto/archive/refs/tags/v3.2.0.tar.gz", ) def rules_jvm_external():