Skip to content

Commit fb37786

Browse files
authored
Use rules_scala v7.0.0 from GitHub, bump versions (#389)
Using the `rules_scala` Bazel module, upgrading from v6.6.0 to v7.0.0, is the most significant change here. Will update `MODULE.bazel` to use `rules_scala` from the Bazel Central Registry after bazelbuild/bazel-central-registry#4552 lands. Lots of other version bumps: - Bazel: 8.2.0 => 8.2.1 - Go: 1.22.5 => 1.24.3 - `apple_support`: 1.15.1 => 1.22.0 - `aspect_rules_ts`: 2.4.2 => 3.5.3 - `com.google.oauth-client:google-oauth-client`: 1.36.0 => 1.39.0 - `commons-cli:commons-cli`: 1.8.0 => 1.9.0 - `engflowapis-java`: 2025.01.17-13.50.20 => 2025.03.14-12.58.52 - `gazelle`: 0.37.0 => 0.43.0 - `googleapis`: 0.0.0-20240326-1c8d509c5 => 0.0.0-20241220-5e258e33.bcr.1 - `grpc-java`: 1.64.0 => 1.71.0 - `io.netty:netty-handler`: 4.1.111.Final => 4.1.121.Final - `protobuf`: v23.1 => v30.2 - `rules_cc`: 0.0.9 => 0.1.1 - `rules_dotnet`: 0.18.1 => 0.18.2 - `rules_go`: 0.48.1 => 0.54.0 - `rules_java`: 7.9.1 => 8.11.0 - `rules_jvm_external`: 6.2 => 6.7 - `rules_kotlin`: 1.9.6 => 2.1.4 - `rules_perl`: 0.2.0 => 0.4.1 - `rules_proto_grpc`: 5.0.0-alpha2 => 5.0.1 - `rules_proto`: 6.0.2 => 7.1.0 - `rules_python`: 1.0.0 => 1.4.1 - `rules_swift`: 1.18.0 => 2.8.2 Other changes: - Adds `scala/0001-protobuf-19679-rm-protoc-dep.patch` and adds `common --incompatible_enable_proto_toolchain_resolution` to `.bazelrc`. This enables the precompiled `protoc` toolchain from `rules_scala`, `@rules_scala_protoc_toolchains`. - Updates C++ compiler flags in `.bazelrc` to `-std=c++17` to build `protobuf` v30.2 remotely on an EngFlow cluster. - Updates `README.md` to include the EngFlow credential helper in `.bazelrc.user`, and to specify `--config=engflow` as needed. - Removed `repo_name` from every `bazel_dep`. - Updated former `repo_name` references in `BUILD` files. - Ran `bazel mod tidy` to standardize the formatting of `MODULE.bazel`.
1 parent 79b5193 commit fb37786

File tree

11 files changed

+12841
-1194
lines changed

11 files changed

+12841
-1194
lines changed

.bazelrc

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
33
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
44
common --noincompatible_check_sharding_support
55

6+
# Remove once proto toolchainization becomes the default
7+
# - https://bazel.build/reference/command-line-reference#flag--incompatible_enable_proto_toolchain_resolution
8+
# - https://docs.google.com/document/d/1CE6wJHNfKbUPBr7-mmk_0Yo3a4TaqcTPE0OWNuQkhPs/edit
9+
common --incompatible_enable_proto_toolchain_resolution
10+
611
build --java_runtime_version=remotejdk_11
712
build --java_language_version=11
813

@@ -28,8 +33,8 @@ build:ci --nobuild_runfile_links
2833
build:ci --keep_going
2934

3035
# Additional clang toolchain options for automatically configured toolchains.
31-
build --cxxopt="-std=c++14"
32-
build --host_cxxopt="-std=c++14"
36+
build --cxxopt="-std=c++17"
37+
build --host_cxxopt="-std=c++17"
3338
build:clang --cxxopt="-fno-exceptions"
3439
build:clang --host_cxxopt="-fno-exceptions"
3540
build:clang --cxxopt="-fvisibility=hidden"

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.2.0
1+
8.2.1

MODULE.bazel

+59-200
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
"""EngFlow example project"""
22

3-
module(name = "engflow-example", version = "0.0.0")
3+
module(
4+
name = "engflow-example",
5+
version = "0.0.0",
6+
)
7+
48
http_file = use_repo_rule(
5-
"@bazel_tools//tools/build_defs/repo:http.bzl", "http_file"
9+
"@bazel_tools//tools/build_defs/repo:http.bzl",
10+
"http_file",
611
)
12+
713
http_archive = use_repo_rule(
8-
"@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive"
14+
"@bazel_tools//tools/build_defs/repo:http.bzl",
15+
"http_archive",
916
)
1017

1118
# Some file dependencies
@@ -38,13 +45,17 @@ http_archive(
3845
url = "https://github.com/abseil/abseil-py/archive/refs/tags/v2.1.0.tar.gz",
3946
)
4047

48+
register_toolchains("@rules_scala_protoc_toolchains//:all")
49+
4150
bazel_dep(name = "bazel_skylib", version = "1.7.1")
42-
bazel_dep(name = "engflowapis-java", version = "2025.01.17-13.50.20")
43-
bazel_dep(name = "platforms", version = "0.0.10")
44-
bazel_dep(
45-
name = "protobuf",
46-
version = "23.1",
47-
repo_name = "com_google_protobuf",
51+
bazel_dep(name = "engflowapis-java", version = "2025.03.14-12.58.52")
52+
bazel_dep(name = "platforms", version = "0.0.11")
53+
bazel_dep(name = "protobuf", version = "30.2")
54+
single_version_override(
55+
module_name = "protobuf",
56+
patch_strip = 1,
57+
patches = ["//scala:0001-protobuf-19679-rm-protoc-dep.patch"],
58+
version = "30.2",
4859
)
4960

5061
# Per the instructions from:
@@ -53,43 +64,35 @@ bazel_dep(
5364
# If you also depend on `rules_cc`, `apple_support` must come _above_ `rules_cc`
5465
# in your `MODULE.bazel` or `WORKSPACE` file because Bazel selects toolchains
5566
# based on which is registered first.
56-
bazel_dep(
57-
name = "apple_support",
58-
version = "1.15.1",
59-
repo_name = "build_bazel_apple_support",
60-
)
61-
bazel_dep(name = "rules_cc", version = "0.0.9")
67+
bazel_dep(name = "apple_support", version = "1.22.0")
68+
bazel_dep(name = "rules_cc", version = "0.1.1")
6269

6370
# https://github.com/googleapis/googleapis/pull/855
6471
# https://github.com/bazelbuild/bazel-central-registry/pull/1699
6572
bazel_dep(
6673
name = "googleapis",
67-
version = "0.0.0-20240326-1c8d509c5",
68-
repo_name = "com_google_googleapis",
74+
version = "0.0.0-20241220-5e258e33.bcr.1",
6975
)
70-
71-
bazel_dep(name = "rules_python", version = "1.0.0")
76+
bazel_dep(name = "rules_python", version = "1.4.1")
7277

7378
PYTHON_VERSION = "3.12"
79+
7480
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
7581
python.toolchain(
7682
is_default = True,
7783
python_version = PYTHON_VERSION,
7884
)
7985

8086
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
81-
8287
pip.parse(
8388
hub_name = "pip",
8489
python_version = PYTHON_VERSION,
8590
requirements_lock = "//python:requirements_lock.txt",
8691
)
87-
8892
use_repo(pip, "pip")
8993

90-
bazel_dep(name = "rules_proto", version = "6.0.2")
91-
92-
bazel_dep(name = "rules_dotnet", version = "0.18.1")
94+
bazel_dep(name = "rules_proto", version = "7.1.0")
95+
bazel_dep(name = "rules_dotnet", version = "0.18.2")
9396

9497
dotnet = use_extension("@rules_dotnet//dotnet:extensions.bzl", "dotnet")
9598
dotnet.toolchain(dotnet_version = "8.0.200")
@@ -98,220 +101,76 @@ use_repo(dotnet, "dotnet_toolchains")
98101
register_toolchains("@dotnet_toolchains//:all")
99102

100103
# https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/bzlmod.md
101-
bazel_dep(name = "rules_go", version = "0.48.1")
102-
bazel_dep(name = "gazelle", version = "0.37.0")
104+
bazel_dep(name = "rules_go", version = "0.54.0")
105+
bazel_dep(name = "gazelle", version = "0.43.0")
103106

104-
GO_VERSION = "1.22.5"
107+
GO_VERSION = "1.24.3"
105108

106109
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
107110
go_sdk.download(version = GO_VERSION)
108111

109112
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
110113
go_deps.from_file(go_mod = "//:go.mod")
111-
112114
use_repo(go_deps, "com_github_google_go_cmp")
113115

114-
bazel_dep(name = "rules_java", version = "7.9.1")
116+
bazel_dep(name = "rules_java", version = "8.11.0")
115117

116118
# https://github.com/bazelbuild/rules_jvm_external/blob/master/docs/bzlmod.md
117-
bazel_dep(name = "rules_jvm_external", version = "6.2")
118-
bazel_dep(
119-
name = "grpc-java",
120-
version = "1.64.0",
121-
repo_name = "io_grpc_grpc_java",
122-
)
119+
bazel_dep(name = "rules_jvm_external", version = "6.7")
120+
bazel_dep(name = "grpc-java", version = "1.71.0")
123121

124122
# Loads rules required to compile proto files
125-
bazel_dep(name = "rules_proto_grpc", version = "5.0.0-alpha2")
123+
bazel_dep(name = "rules_proto_grpc", version = "5.0.1")
126124

127125
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
128126
maven.install(
129127
artifacts = [
130-
"commons-cli:commons-cli:1.8.0",
131-
"com.google.oauth-client:google-oauth-client:1.36.0",
132-
"io.netty:netty-handler:4.1.111.Final",
128+
"commons-cli:commons-cli:1.9.0",
129+
"com.google.oauth-client:google-oauth-client:1.39.0",
130+
"io.netty:netty-handler:4.1.121.Final",
133131
],
134132

135133
# When updating versions, run `REPIN=1 bazel run @maven//:pin`
136134
fail_if_repin_required = True,
137135
lock_file = "//:maven_install.json",
138-
139-
strict_visibility = True,
140136
repositories = [
141137
"https://repo.maven.apache.org/maven2/",
142138
],
139+
strict_visibility = True,
143140
)
144141
use_repo(maven, "maven")
145142

146-
bazel_dep(name = "rules_kotlin", version = "1.9.6")
147-
bazel_dep(name = "rules_perl", version = "0.2.0")
148-
149-
bazel_dep(
150-
name = "rules_swift",
151-
version = "1.18.0",
152-
repo_name = "build_bazel_rules_swift"
153-
)
154-
155-
bazel_dep(name = "aspect_rules_ts", version = "2.4.2")
143+
bazel_dep(name = "rules_kotlin", version = "2.1.4")
144+
bazel_dep(name = "rules_perl", version = "0.4.1")
145+
bazel_dep(name = "rules_swift", version = "2.8.2")
146+
bazel_dep(name = "aspect_rules_ts", version = "3.5.3")
156147

157148
rules_ts_ext = use_extension(
158149
"@aspect_rules_ts//ts:extensions.bzl",
159150
"ext",
160151
dev_dependency = True,
161152
)
162-
163153
rules_ts_ext.deps()
164-
165154
use_repo(rules_ts_ext, "npm_typescript")
166155

167-
# rules_scala is not yet bzlmod compatible:
168-
#
169-
# - https://github.com/bazelbuild/rules_scala/issues/1482
170-
# - https://github.com/bazelbuild/bazel-central-registry/issues/522
171-
#
172-
# This is due to the following differences between the WORKSPACE and bzlmod
173-
# models:
174-
#
175-
# - WORKSPACE executes http_archive, load, and any imported functions
176-
# sequentially. This enables later expressions to refer to repos defined by
177-
# expressions executed earlier in the WORKSPACE file. Also, WORKSPACE
178-
# expressions can introduce repos to the global scope directly, without
179-
# explicit import statements.
180-
#
181-
# - bzlmod enforces explicit repository declarations, with no expression
182-
# referring to a repo defined in the same file. (The exception being arguments
183-
# to register_toolchains(), and probably register_execution_platforms(), which
184-
# don't appear to carry the risk of introducing circular definitions.)
185-
#
186-
# MODULE.bazel also doesn't allow load() calls, and load()s must appear at the
187-
# beginning of an extension file, before any function definitions or calls.
188-
#
189-
# This enables bzlmod to build and verify an acyclic dependency graph from
190-
# repo declarations alone, before and without executing any extension
191-
# functions.
192-
#
193-
# As a result, importing the rules_scala repos into MODULE.bazel requires
194-
# separate files:
195-
#
196-
# - MODULE.bazel loads the rules_scala archive as @io_bazel_rules_scala.
197-
#
198-
# - The //scala/extensions:config.bzl extension defines
199-
# @io_bazel_rules_scala_config, which depends on @io_bazel_rules_scala.
200-
#
201-
# - The //scala/extensions:deps.bzl extension defines the repos needed by the
202-
# Scala rules, which depend on @io_bazel_rules_scala and
203-
# @io_bazel_rules_scala_config.
204-
#
205-
# The following problems occur when trying to import everything directly in
206-
# MODULE.bazel, or in fewer extension files.
207-
#
208-
# ---
209-
#
210-
# In an extension, the http_archive call for rules_scala must still come first,
211-
# thereby rendering later load() calls invalid. This precludes encapsulating the
212-
# entire rules_scala configuration in a single extension.
213-
#
214-
# ---
215-
#
216-
# Defining @io_bazel_rules_scala_config using the following in MODULE.bazel:
217-
#
218-
# scala_config = use_repo_rule(
219-
# "@io_bazel_rules_scala//:scala_config.bzl", "scala_config"
220-
# )
221-
# scala_config(name = "io_bazel_rules_scala_config")
222-
#
223-
# would produce:
224-
#
225-
# ERROR: Circular definition of repositories generated by module extensions
226-
# and/or .bzl files:
227-
# .-> @@_main~_repo_rules~io_bazel_rules_scala
228-
# | extension '_repo_rules' defined in //:MODULE.bazel
229-
# | @@_main~_repo_rules~io_bazel_rules_scala//:scala_config.bzl
230-
# `-- @@_main~_repo_rules~io_bazel_rules_scala
231-
# ERROR: cycles detected during target parsing
232-
#
233-
# ---
234-
#
235-
# Calling scala_config() and exporting @io_bazel_rules_scala_config from
236-
# //scala:deps.bzl would also produce a circular definition error:
237-
#
238-
# ERROR: Circular definition of repositories generated by module extensions
239-
# and/or .bzl files:
240-
# .-> @@_main~scala_deps~io_bazel_rules_scala_config
241-
# | extension 'scala_deps' defined in //scala:deps.bzl
242-
# | //scala:deps.bzl
243-
# | @@_main~_repo_rules~io_bazel_rules_scala//testing:scalatest.bzl
244-
# | @@_main~_repo_rules~io_bazel_rules_scala//scalatest:scalatest.bzl
245-
# | @@_main~_repo_rules~io_bazel_rules_scala//third_party/repositories:repositories.bzl
246-
# | @@_main~scala_deps~io_bazel_rules_scala_config//:config.bzl
247-
# `-- @@_main~scala_deps~io_bazel_rules_scala_config
248-
# ERROR: cycles detected during target parsing
249-
#
250-
# This is because
251-
# @io_bazel_rules_scala//third_party/repositories:repositories.bzl contains a
252-
# load() statement depending on @io_bazel_rules_scala_config:
253-
#
254-
# load(
255-
# "@io_bazel_rules_scala_config//:config.bzl",
256-
# "SCALA_MAJOR_VERSION",
257-
# "SCALA_VERSION",
258-
# )
259-
260-
http_archive(
261-
name = "io_bazel_rules_scala",
262-
sha256 = "e734eef95cf26c0171566bdc24d83bd82bdaf8ca7873bec6ce9b0d524bdaf05d",
263-
strip_prefix = "rules_scala-6.6.0",
264-
url = "https://github.com/bazelbuild/rules_scala/releases/download/v6.6.0/rules_scala-v6.6.0.tar.gz",
265-
patches = ["//scala:rules_scala-6.6.0.patch"],
266-
patch_args = ["-p1"],
156+
bazel_dep(name = "rules_scala")
157+
archive_override(
158+
module_name = "rules_scala",
159+
sha256 = "a4700d6e6cdf13cf85e29029ec998e2ec3ba94791606ec83d2c96e3c5b0aebed",
160+
strip_prefix = "rules_scala-7.0.0",
161+
url = "https://github.com/bazelbuild/rules_scala/releases/download/v7.0.0/rules_scala-v7.0.0.tar.gz",
267162
)
268163

269-
# This constant matches the default Scala version from rules_scala for now.
270-
SCALA_VERSION = "2.13.12"
271-
SCALA_VERSIONS = [SCALA_VERSION]
272-
273-
scala_config = use_extension("//scala/extensions:config.bzl", "scala_config")
274-
scala_config.settings(
275-
scala_version = SCALA_VERSION,
276-
scala_versions = SCALA_VERSIONS,
277-
)
278-
use_repo(
279-
scala_config,
280-
"io_bazel_rules_scala_config",
164+
scala_deps = use_extension(
165+
"@rules_scala//scala/extensions:deps.bzl",
166+
"scala_deps",
281167
)
168+
scala_deps.scala()
169+
scala_deps.scalatest()
282170

283-
repos = [
284-
"io_bazel_rules_scala_scala_compiler",
285-
"io_bazel_rules_scala_scala_library",
286-
"io_bazel_rules_scala_scala_parser_combinators",
287-
"io_bazel_rules_scala_scala_reflect",
288-
"io_bazel_rules_scala_scala_xml",
289-
"io_bazel_rules_scala_scalactic",
290-
"io_bazel_rules_scala_scalatest",
291-
"io_bazel_rules_scala_scalatest_core",
292-
"io_bazel_rules_scala_scalatest_compatible",
293-
"io_bazel_rules_scala_scalatest_featurespec",
294-
"io_bazel_rules_scala_scalatest_flatspec",
295-
"io_bazel_rules_scala_scalatest_freespec",
296-
"io_bazel_rules_scala_scalatest_funspec",
297-
"io_bazel_rules_scala_scalatest_funsuite",
298-
"io_bazel_rules_scala_scalatest_matchers_core",
299-
"io_bazel_rules_scala_scalatest_mustmatchers",
300-
"io_bazel_rules_scala_scalatest_shouldmatchers",
301-
]
302-
303-
toolchains = [
304-
"@io_bazel_rules_scala//scala:toolchain",
305-
"@io_bazel_rules_scala//testing:scalatest_toolchain",
306-
]
307-
308-
scala_deps = use_extension("//scala/extensions:deps.bzl", "scala_deps")
309-
[
310-
(
311-
[use_repo(scala_deps, repo + suffix) for repo in repos],
312-
[register_toolchains(toolchain + suffix) for toolchain in toolchains],
313-
)
314-
# The v.replace() expression mimics the logic to generate version specific
315-
# repo suffixes from rules_scala.
316-
for suffix in ["_" + v.replace(".", "_") for v in SCALA_VERSIONS]
317-
]
171+
scala_protoc = use_extension(
172+
"@rules_scala//scala/extensions:protoc.bzl",
173+
"scala_protoc",
174+
dev_dependency = True,
175+
)
176+
use_repo(scala_protoc, "rules_scala_protoc_toolchains")

0 commit comments

Comments
 (0)