Skip to content

Commit 4bebd03

Browse files
hvadehrarules_java Copybara
authored andcommitted
Overhaul @rules_java bzl_library dep graph
- Construct an accurate `bzl_library` target for the compatibility proxy - Updates `proto_support.bzl` to use the right `java_common` - Work towards fixing bazelbuild/bazel#24455 PiperOrigin-RevId: 699129931 Change-Id: I55f6e744602e3760f69bc197a8f107fd119feee0
1 parent a22cec1 commit 4bebd03

11 files changed

Lines changed: 84 additions & 21 deletions

File tree

.bazelci/presubmit.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ build_targets: &build_targets
44
- "@remote_java_tools//java_tools/..."
55
# TODO: Look into broken targets in //toolchains
66
- "-//toolchains/..."
7-
- "-//test/repo/..."
87
# TODO: re-enable docs after protobuf is fixed
98
- "-//java/docs/..."
109
- "-//test:docs_up_to_date_test"

java/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ bzl_library(
6565
deps = ["//java/common"],
6666
)
6767

68+
bzl_library(
69+
name = "http_jar_bzl",
70+
srcs = ["http_jar.bzl"],
71+
visibility = ["//visibility:public"],
72+
deps = ["@bazel_tools//tools:bzl_srcs"],
73+
)
74+
6875
filegroup(
6976
name = "for_bazel_tests",
7077
testonly = 1,

java/bazel/rules/BUILD.bazel

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ bzl_library(
2424
srcs = glob(["*.bzl"]),
2525
visibility = ["//visibility:public"], # for Bazel docgen
2626
deps = [
27-
"//java/common",
27+
"//java/common:semantics_bzl",
2828
"//java/common/rules:core_rules",
2929
"//java/common/rules/impl",
30+
"//java/private:internals",
3031
"@bazel_skylib//lib:paths",
3132
"@rules_cc//cc:find_cc_toolchain_bzl",
3233
"@rules_cc//cc/common",

java/common/BUILD

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,32 @@ filegroup(
1414

1515
bzl_library(
1616
name = "common",
17-
srcs = glob(["*.bzl"]),
17+
srcs = glob(
18+
["*.bzl"],
19+
exclude = [
20+
"java_semantics.bzl",
21+
"proguard_spec_info.bzl",
22+
],
23+
),
24+
visibility = ["//visibility:public"],
25+
deps = ["@compatibility_proxy//:proxy_bzl"],
26+
)
27+
28+
bzl_library(
29+
name = "semantics_bzl",
30+
srcs = ["java_semantics.bzl"],
1831
visibility = ["//visibility:public"],
1932
deps = [
20-
"//java/private:internals",
21-
"@compatibility_proxy//:proxy_bzl",
33+
"@rules_cc//cc/common",
2234
],
2335
)
2436

37+
bzl_library(
38+
name = "proguard_spec_info_bzl",
39+
srcs = ["proguard_spec_info.bzl"],
40+
visibility = ["//visibility:public"],
41+
)
42+
2543
filegroup(
2644
name = "for_bazel_tests",
2745
testonly = 1,

java/common/rules/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bzl_library(
3838
deps = [
3939
":android_lint_bzl",
4040
":rule_util_bzl",
41-
"//java/common",
41+
"//java/private:internals",
4242
"@bazel_skylib//lib:paths",
4343
"@rules_cc//cc/common",
4444
],
@@ -53,6 +53,7 @@ bzl_library(
5353
],
5454
visibility = [
5555
"//java:__subpackages__",
56+
"@compatibility_proxy//:__pkg__",
5657
],
5758
)
5859

java/common/rules/impl/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bzl_library(
1717
visibility = ["//java:__subpackages__"],
1818
deps = [
1919
":java_helper_bzl",
20+
"//java/common:proguard_spec_info_bzl",
2021
"@com_google_protobuf//bazel/common:proto_info_bzl",
2122
],
2223
)

java/private/BUILD

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ bzl_library(
77
srcs = [
88
"native.bzl",
99
],
10-
visibility = ["//java:__subpackages__"],
10+
visibility = [
11+
"//java:__subpackages__",
12+
"@compatibility_proxy//:__pkg__",
13+
],
1114
)
1215

1316
bzl_library(
@@ -19,7 +22,10 @@ bzl_library(
1922
"java_info.bzl",
2023
"message_bundle_info.bzl",
2124
],
22-
visibility = ["//java:__subpackages__"],
25+
visibility = [
26+
"//java:__subpackages__",
27+
"@compatibility_proxy//:__pkg__",
28+
],
2329
deps = [
2430
":native_bzl",
2531
"//java/common/rules:toolchain_rules",
@@ -35,7 +41,7 @@ bzl_library(
3541
name = "proto_support",
3642
srcs = ["proto_support.bzl"],
3743
visibility = ["//visibility:public"],
38-
deps = [":native_bzl"],
44+
deps = ["@compatibility_proxy//:proxy_bzl"],
3945
)
4046

4147
filegroup(

java/private/proto_support.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
"""Support for Java compilation of protocol buffer generated code."""
1515

16-
load("//java/common:java_common.bzl", "java_common")
16+
load("@compatibility_proxy//:proxy.bzl", "java_common")
1717

1818
# Partial support, because internal symbols are not available in older Bazel version
1919
# TODO: Once Java rules are moved into the rules_java, this should become a full support.

java/rules_java_deps.bzl

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,25 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
66
def _compatibility_proxy_repo_impl(rctx):
77
# TODO: use @bazel_features
88
bazel = native.bazel_version
9-
rctx.file(
10-
"BUILD.bazel",
11-
"""
12-
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
13-
bzl_library(name = "proxy_bzl", srcs = ["proxy.bzl"], visibility = ["//visibility:public"])
14-
""",
15-
)
169
if not bazel or bazel >= "8":
10+
rctx.file(
11+
"BUILD.bazel",
12+
"""
13+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
14+
exports_files(['proxy.bzl'], visibility = ["@rules_java//test:__pkg__"])
15+
bzl_library(
16+
name = "proxy_bzl",
17+
srcs = ["proxy.bzl"],
18+
deps = [
19+
"@rules_java//java/bazel/rules",
20+
"@rules_java//java/common/rules:toolchain_rules",
21+
"@rules_java//java/private:internals",
22+
"@rules_java//java:http_jar_bzl",
23+
],
24+
visibility = ["//visibility:public"]
25+
)
26+
""",
27+
)
1728
rctx.file(
1829
"proxy.bzl",
1930
"""
@@ -45,6 +56,22 @@ http_jar = _http_jar
4556
""",
4657
)
4758
else:
59+
rctx.file(
60+
"BUILD.bazel",
61+
"""
62+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
63+
exports_files(['proxy.bzl'], visibility = ["@rules_java//test:__pkg__"])
64+
bzl_library(
65+
name = "proxy_bzl",
66+
srcs = ["proxy.bzl"],
67+
deps = [
68+
"@rules_java//java/private:native_bzl",
69+
"@bazel_tools//tools:bzl_srcs",
70+
],
71+
visibility = ["//visibility:public"]
72+
)
73+
""",
74+
)
4875
rctx.file(
4976
"proxy.bzl",
5077
"""

java/toolchains/BUILD

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ bzl_library(
1414
name = "toolchain_rules",
1515
srcs = glob(["*.bzl"]),
1616
visibility = ["//visibility:public"],
17-
deps = [
18-
"//java/private:native_bzl",
19-
"@compatibility_proxy//:proxy_bzl",
20-
],
17+
deps = ["@compatibility_proxy//:proxy_bzl"],
2118
)
2219

2320
filegroup(

0 commit comments

Comments
 (0)