Skip to content

Commit 70970af

Browse files
hvadehrarules_java Copybara
authored andcommitted
Switch rules_java rule macro redirects from native.* to those defined locally
Using the rules requires a bazel version that contains all the changes in bazelbuild/bazel#23591 PiperOrigin-RevId: 673847088 Change-Id: Iaaf824fbae4dced297baa6a336b2e7b8b6c3ccb5
1 parent 421c655 commit 70970af

18 files changed

Lines changed: 159 additions & 57 deletions

.bazelci/presubmit.yml

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ test_targets: &test_targets
2121
buildifier: latest
2222

2323
tasks:
24+
# TODO: add config for 8.0.0 once released
25+
# Bazel 7.x
26+
# TODO: fix versions after 7.4.0
2427
ubuntu2004:
28+
name: "Bazel 7.x"
29+
bazel: "9e3fa2a2e98db4aa10918a981325cfa9473e4ed8"
2530
build_targets: *build_targets
2631
test_targets: *test_targets
2732
ubuntu2004_integration:
28-
name: "Integration Tests"
33+
name: "Bazel 7.x Integration"
34+
bazel: "9e3fa2a2e98db4aa10918a981325cfa9473e4ed8"
2935
platform: ubuntu2004
3036
working_directory: "test/repo"
3137
shell_commands:
@@ -35,14 +41,30 @@ tasks:
3541
- "//:bin_deploy.jar"
3642
- "@rules_java//java/..."
3743
macos:
44+
name: "Bazel 7.x"
45+
bazel: "9e3fa2a2e98db4aa10918a981325cfa9473e4ed8"
3846
build_targets: *build_targets
3947
windows:
48+
name: "Bazel 7.x"
49+
bazel: "9e3fa2a2e98db4aa10918a981325cfa9473e4ed8"
4050
build_targets: *build_targets
51+
# Bazel@HEAD
4152
ubuntu2004_head:
4253
name: "Bazel@HEAD"
4354
bazel: last_green
4455
platform: ubuntu2004
4556
build_targets: *build_targets
57+
ubuntu2004_integration_head:
58+
name: "Bazel@HEAD Integration"
59+
bazel: last_green
60+
platform: ubuntu2004
61+
working_directory: "test/repo"
62+
shell_commands:
63+
- sh setup.sh
64+
build_targets:
65+
- "//..."
66+
- "//:bin_deploy.jar"
67+
- "@rules_java//java/..."
4668
macos_head:
4769
name: "Bazel@HEAD"
4870
bazel: last_green
@@ -53,36 +75,20 @@ tasks:
5375
bazel: last_green
5476
platform: windows
5577
build_targets: *build_targets
56-
ubuntu2004_bzlmod:
57-
name: "bzlmod"
58-
platform: ubuntu2004
59-
build_flags:
60-
- "--config=bzlmod"
61-
build_targets: *build_targets_bzlmod
62-
macos_bzlmod:
63-
name: "bzlmod"
64-
platform: macos
65-
build_flags:
66-
- "--config=bzlmod"
67-
build_targets: *build_targets_bzlmod
68-
windows_bzlmod:
69-
name: "bzlmod"
70-
platform: windows
71-
build_flags:
72-
- "--config=bzlmod"
73-
build_targets: *build_targets_bzlmod
74-
ubuntu2004_bazel630:
75-
name: "Bazel 6.3.0"
76-
bazel: 6.3.0
77-
platform: ubuntu2004
78-
build_targets: *build_targets
79-
macos_bazel630:
80-
name: "Bazel 6.3.0"
81-
bazel: 6.3.0
82-
platform: macos
83-
build_targets: *build_targets
84-
windows_bazel630:
85-
name: "Bazel 6.3.0"
86-
bazel: 6.3.0
87-
platform: windows
88-
build_targets: *build_targets
78+
# Bazel 6.x
79+
# TODO: re-enable if possible to redirect to native rule impl
80+
# ubuntu2004_bazel630:
81+
# name: "Bazel 6.3.0"
82+
# bazel: 6.3.0
83+
# platform: ubuntu2004
84+
# build_targets: *build_targets
85+
# macos_bazel630:
86+
# name: "Bazel 6.3.0"
87+
# bazel: 6.3.0
88+
# platform: macos
89+
# build_targets: *build_targets
90+
# windows_bazel630:
91+
# name: "Bazel 6.3.0"
92+
# bazel: 6.3.0
93+
# platform: windows
94+
# build_targets: *build_targets

.bazelrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
build:bzlmod --experimental_enable_bzlmod
1+
common --incompatible_disallow_empty_glob
2+
common --experimental_rule_extension_api
23

3-
common --incompatible_disallow_empty_glob
4+
# TODO: remove once https://github.com/bazelbuild/bazel/commit/384e381fa841537987691f170ed9408dcfeed2ea is available
5+
common --experimental_google_legacy_api

MODULE.bazel

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ bazel_dep(name = "bazel_features", version = "1.11.0")
1111
bazel_dep(name = "bazel_skylib", version = "1.6.1")
1212

1313
# Required by @remote_java_tools, which is loaded via module extension.
14-
bazel_dep(name = "rules_proto", version = "4.0.0")
14+
bazel_dep(name = "rules_proto", version = "6.0.2")
1515
bazel_dep(name = "rules_license", version = "0.0.3")
1616
bazel_dep(name = "abseil-cpp", version = "20230802.1", repo_name = "com_google_absl")
1717

@@ -97,3 +97,11 @@ single_version_override(
9797
module_name = "rules_python",
9898
version = "0.24.0",
9999
)
100+
101+
# TODO: drop this & update version from BCR above
102+
archive_override(
103+
module_name = "rules_cc",
104+
integrity = "sha256-ZvxtrlaB2jZk56tUDasvs4b1ThcPMaEa64u+MZSwf1E=",
105+
strip_prefix = "rules_cc-0.0.10-rc2",
106+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.10-rc2/rules_cc-0.0.10-rc2.tar.gz"],
107+
)

java/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ licenses(["notice"])
77
filegroup(
88
name = "srcs",
99
srcs = glob(["**"]) + [
10+
"//java/bazel:srcs",
11+
"//java/bazel/common:srcs",
1012
"//java/bazel/rules:srcs",
1113
"//java/common:srcs",
1214
"//java/private:srcs",
@@ -39,8 +41,10 @@ bzl_library(
3941
],
4042
visibility = ["//visibility:public"],
4143
deps = [
44+
"//java/bazel/common", # copybara-use-repo-external-label
4245
"//java/bazel/rules", # copybara-use-repo-external-label
4346
"//java/common",
47+
"//java/common/rules:core_rules",
4448
"//java/private",
4549
],
4650
)
@@ -66,6 +70,7 @@ filegroup(
6670
":core_rules",
6771
":java_single_jar",
6872
":rules",
73+
"//java/bazel:for_bazel_tests", # copybara-use-repo-external-label
6974
"//java/bazel/rules:for_bazel_tests", # copybara-use-repo-external-label
7075
"//java/common:for_bazel_tests",
7176
"//java/private:for_bazel_tests",

java/bazel/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ filegroup(
5959
testonly = 1,
6060
visibility = ["//java:__pkg__"],
6161
)
62+
63+
filegroup(
64+
name = "srcs",
65+
srcs = glob(["**"]),
66+
visibility = ["//java:__pkg__"],
67+
)

java/bazel/common/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,11 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
33
bzl_library(
44
name = "common",
55
srcs = glob(["*.bzl"]),
6+
visibility = ["//java:__pkg__"],
7+
)
8+
9+
filegroup(
10+
name = "srcs",
11+
srcs = glob(["**"]),
12+
visibility = ["//java:__pkg__"],
613
)

java/common/rules/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ bzl_library(
3939
deps = [
4040
":android_lint_bzl",
4141
":rule_util_bzl",
42-
# TODO: re-enable after rules_cc release
43-
# "@rules_cc//cc/common",
4442
"//java/common",
4543
"@bazel_skylib//lib:paths",
44+
"@rules_cc//cc/common",
4645
],
4746
)
4847

@@ -52,6 +51,7 @@ filegroup(
5251
srcs = [
5352
"BUILD",
5453
":core_rules",
54+
"//java/common/rules/impl:for_bazel_tests",
5555
],
5656
visibility = ["//java/common:__pkg__"],
5757
)

java/common/rules/impl/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,25 @@
1+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
filegroup(
46
name = "srcs",
57
srcs = glob(["**"]),
68
visibility = ["//java/common/rules:__pkg__"],
79
)
10+
11+
bzl_library(
12+
name = "impl",
13+
srcs = glob(["*.bzl"]),
14+
visibility = ["//java:__subpackages__"],
15+
)
16+
17+
filegroup(
18+
name = "for_bazel_tests",
19+
testonly = 1,
20+
srcs = [
21+
"BUILD",
22+
":impl",
23+
],
24+
visibility = ["//java/common/rules:__pkg__"],
25+
)

java/common/rules/impl/java_binary_impl.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616

1717
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
1818
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
19+
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
1920
load("//java/common:java_common.bzl", "java_common")
2021
load("//java/common:java_info.bzl", "JavaInfo")
2122
load("//java/common:java_semantics.bzl", "semantics")
2223
load("//java/common/rules/impl:basic_java_library_impl.bzl", "basic_java_library", "collect_deps")
23-
load("//third_party/protobuf/bazel/common:proto_info.bzl", "ProtoInfo")
2424
load(":java_binary_deploy_jar.bzl", "create_deploy_archive")
2525
load(":java_helper.bzl", "helper")
2626

java/java_binary.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# limitations under the License.
1414
"""java_binary rule"""
1515

16+
load("//java/bazel/rules:bazel_java_binary_wrapper.bzl", _java_binary = "java_binary")
17+
1618
def java_binary(**attrs):
1719
"""Bazel java_binary rule.
1820
@@ -22,5 +24,4 @@ def java_binary(**attrs):
2224
**attrs: Rule attributes
2325
"""
2426

25-
# buildifier: disable=native-java
26-
native.java_binary(**attrs)
27+
_java_binary(**attrs)

0 commit comments

Comments
 (0)