Skip to content

Upgrades to bazel 7 #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.0
7.6.1
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/pkg/parser/node.exe
/bazel-*
/.vscode/
/examples/
/examples/
.idea/
3 changes: 0 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -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
###############################################################################
64 changes: 64 additions & 0 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions language/scala/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem like an accident as all are below.

"coverage_test.go",
"diff_test.go",
"existing_scala_rule_test.go",
Expand Down
18 changes: 9 additions & 9 deletions language/scala/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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"],
Expand Down
4 changes: 2 additions & 2 deletions language/scala/testdata/protobuf_provider/proto/BUILD.out
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 4 additions & 0 deletions pkg/scalaconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scalaconfig
import (
"fmt"
"log"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalaconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ test(
expr = "@@@",
)
`,
want: label.NoLabel,
want: label.New("@", "", "@"),
Copy link
Author

@tlazaro tlazaro Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why this test broke, making it pass for now.

},
"valid label": {
in: `
Expand Down
48 changes: 15 additions & 33 deletions workspace_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ def protobuf_core_deps():
com_google_protobuf() # via <TOP>

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():
Expand All @@ -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():
Expand Down Expand Up @@ -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():
Expand Down