Commit a0fc665
committed
Fix Bazel 8.2.1 WORKSPACE builds, bump dev deps
Fixes a few problems when building under `WORKSPACE` with Bazel 8.2.1
(7.6.1 doesn't require these changes). Adds to `.bazelrc` the
`--incompatible_autoload_externally=` flag as a common option for all
builds, and a (disabled) line of options for `WORKSPACE` builds.
Bumps these development dependency versions:
- `com_google_buildifier_buildtools`: 5.1.0 => 8.2.1
- `rules_shell`: 0.4.1 => 0.5.0
---
Though `WORKSPACE` is on the way out, we should ensure that
`rules_scala` remains as compatible as it can be until it's totally
gone. All of these errors happened when running `./test_all` with Bazel
8.2.1 and `WORKSPACE` enabled while working on bazel-contrib#1747.
The first error was the following "cycle". (I later realized it's
somehow due to bazelbuild/rules_java#294 from `rules_java` 8.12.0. See
the note at the very end below.)
```sh
$ bazel run //tools:lint_check
ERROR: Cycle caused by autoloads, failed to load .bzl file
'@@bazel_features_version//:version.bzl'.
Add 'bazel_features_version' to --repositories_without_autoloads
or disable autoloads by setting '--incompatible_autoload_externally='
More information on bazelbuild/bazel#23043.
```
`--incompatible_autoload_externally=` fixed this problem, but also
precipitated all the other errors below.
- bazelbuild/bazel#23043
- https://bazel.build/reference/command-line-reference#common_options-flag--incompatible_autoload_externally
Updating `com_github_bazelbuild_buildtools` to v8.2.1 fixes the next
error, whereby Bazel no longer autoloaded `sh_test`. v5.1.0 was missing
the required `load("@rules_shell//shell:sh_test.bzl", "sh_test")`
statement, added in v8.0.3 by bazelbuild/buildtools#1332:
```sh
$ bazel run //tools:lint_check
ERROR: .../external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel:60:1:
name 'sh_test' is not defined (did you mean 'cc_test'?)
ERROR: .../external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel:
no such target '@@com_github_bazelbuild_buildtools//buildifier:runner.bash.template':
target 'runner.bash.template' not declared in package 'buildifier' defined by
.../external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel;
however, a source file of this name exists.
(Perhaps add 'exports_files(["runner.bash.template"])' to buildifier/BUILD?)
ERROR: /Users/mbland/src/bazel-contrib/rules_scala/tools/BUILD:19:11:
every rule of type _buildifier implicitly depends upon the target
'@@com_github_bazelbuild_buildtools//buildifier:runner.bash.template',
but this target could not be found because of: no such target
'@@com_github_bazelbuild_buildtools//buildifier:runner.bash.template':
target 'runner.bash.template' not declared in package 'buildifier' defined by
.../external/com_github_bazelbuild_buildtools/buildifier/BUILD.bazel;
however, a source file of this name exists.
(Perhaps add 'exports_files(["runner.bash.template"])' to buildifier/BUILD?)
ERROR: Analysis of target '//tools:lint_check' failed;
build aborted: Analysis failed
```
Upgrading to v8.2.1 and updating `//tools:lint_check` to become a
`buildifier_test` also finally got rid of this next warning. This
required exporting the `MODULE.bazel` file from the root package,
disabling one lint warning, and accepting a couple of new lint fixes:
```txt
DEBUG: .../external/+dev_deps+com_github_bazelbuild_buildtools/buildifier/internal/factory.bzl:17:10:
DEPRECATION NOTICE: value 'check' for attribute 'mode' will be removed
in the future. Migrate '@@//tools:lint_check' to buildifier_test.
```
Adding `rules_jvm_external` 6.7 to `//scala:latest_deps.bzl` fixes this
next error, described in detail in:
- protocolbuffers/protobuf#19129 (comment)
```sh
$ bazel build --test_output=errors src/... test/...
ERROR: .../external/com_google_protobuf/java/core/BUILD.bazel:169:21:
@@com_google_protobuf//java/core:lite_mvn-lib:
no such attribute 'javacopts' in 'java_library' rule
ERROR: .../external/com_google_protobuf/java/core/BUILD.bazel:169:21:
@@com_google_protobuf//java/core:lite_mvn-lib:
no such attribute 'resources' in 'java_library' rule
(did you mean 'features'?)
ERROR: .../external/com_google_protobuf/java/core/BUILD.bazel:169:21:
@@com_google_protobuf//java/core:lite_mvn-lib:
no such attribute 'runtime_deps' in 'java_library' rule
ERROR: .../external/com_google_protobuf/java/core/BUILD.bazel:287:21:
@@com_google_protobuf//java/core:core_mvn-lib:
no such attribute 'javacopts' in 'java_library' rule
ERROR: .../external/com_google_protobuf/java/core/BUILD.bazel:287:21:
@@com_google_protobuf//java/core:core_mvn-lib:
no such attribute 'resources' in 'java_library' rule (did you mean 'features'?)
ERROR: .../external/com_google_protobuf/java/core/BUILD.bazel:287:21:
@@com_google_protobuf//java/core:core_mvn-lib:
no such attribute 'runtime_deps' in 'java_library' rule
ERROR: .../external/com_google_protobuf/BUILD.bazel:475:6:
Target '@@com_google_protobuf//java/core:core'
contains an error and its package is in error
and referenced by '@@com_google_protobuf//:protobuf_java'
ERROR: Analysis of target
'//test/proto/custom_generator:failing_scala_proto_deps_toolchain_def'
failed; build aborted: Analysis failed
```
All of the previous errors only affected `rules_scala`'s own development
builds and test runs, when it is the main repository/root module. This
final error is something users could possibly run into when using
`--incompatible_autoload_externally=` with `rules_scala`.
`jvm_import` statements in Maven dependency repos generated by
`jvm_import_external` from `//scala:scala_maven_import_external.bzl`
began to fail. Defining `_JAVA_IMPORT_RULE_LOAD` and using it as the
default value for the `rule_load` attribute of the
`_jvm_import_external` rule fixed this:
```sh
$ bazel test --test_output=errors third_party/...
ERROR: .../external/org_apache_commons_commons_lang_3_5_without_file/BUILD:7:12:
@@org_apache_commons_commons_lang_3_5_without_file//:org_apache_commons_commons_lang_3_5_without_file:
no such attribute 'jars' in 'java_import' rule
ERROR: .../external/org_apache_commons_commons_lang_3_5_without_file/BUILD:7:12:
@@org_apache_commons_commons_lang_3_5_without_file//:org_apache_commons_commons_lang_3_5_without_file:
no such attribute 'neverlink' in 'java_import' rule
ERROR: .../external/org_apache_commons_commons_lang_3_5_without_file/BUILD:14:12:
@@org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file:
no such attribute 'jars' in 'java_import' rule
ERROR: .../third_party/dependency_analyzer/src/test/BUILD:4:6:
Target '@@org_apache_commons_commons_lang_3_5_without_file//:linkable_org_apache_commons_commons_lang_3_5_without_file'
contains an error and its package is in error and referenced by
'//third_party/dependency_analyzer/src/test:strict_deps_test'
ERROR: Analysis of target
'//third_party/dependency_analyzer/src/test:strict_deps_test' failed;
build aborted: Analysis failed
```
---
And just now, I'm noticing that I'd already added the following to
`.bazelrc`, where the `rules_java` release references
bazelbuild/bazel#26119:
```sh
# Uncomment for WORKSPACE builds for Bazel [8.0.0, 8.3.0) per:
# https://github.com/bazelbuild/rules_java/releases/tag/8.12.0
#common --repositories_without_autoloads=bazel_features_version,bazel_features_globals
```
Oh well. But now we're future proof.1 parent 05ecd67 commit a0fc665
File tree
8 files changed
+53
-11
lines changed- scala
- private/extensions
- tools
8 files changed
+53
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | | - | |
| 51 | + | |
47 | 52 | | |
48 | 53 | | |
49 | | - | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
| |||
229 | 233 | | |
230 | 234 | | |
231 | 235 | | |
| 236 | + | |
232 | 237 | | |
233 | 238 | | |
234 | 239 | | |
| |||
237 | 242 | | |
238 | 243 | | |
239 | 244 | | |
240 | | - | |
| 245 | + | |
241 | 246 | | |
242 | 247 | | |
243 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | | - | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
0 commit comments