Skip to content

Commit 079be27

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Remove Java runtime classes from kotlin release.
Because we build lite and core totally separately, they can't both be depended on without producing conflicts. Our kotlin setup has been doing exactly this for a long time though, in order to share code between kotlin and kotlin-lite. Even *with* this change, it's invalid to depend on both lite and core, because they contain different builds of our boostrapped protos. However, they now share the internal `lite_runtime_only` target, which kotlin can reuse to share code. This prevents `lite` from getting linked into kotlin, allowing kt_jvm_export to properly strip out all classes from the Java runtime. Fixes #20566 PiperOrigin-RevId: 734387194
1 parent ed8fae7 commit 079be27

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

java/core/BUILD.bazel

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,10 @@ internal_gen_well_known_protos_java(
141141
# Should be used as `//java/lite`.
142142
java_library(
143143
name = "lite",
144-
srcs = LITE_SRCS + [
145-
":gen_well_known_protos_javalite",
146-
],
147-
visibility = [
148-
"//java/lite:__pkg__",
149-
],
144+
srcs = [":gen_well_known_protos_javalite"],
145+
visibility = ["//java/lite:__pkg__"],
146+
exports = [":lite_runtime_only"],
147+
deps = [":lite_runtime_only"],
150148
)
151149

152150
protobuf_versioned_java_library(
@@ -182,6 +180,7 @@ protobuf_java_export(
182180
protobuf_java_library(
183181
name = "lite_runtime_only",
184182
srcs = LITE_SRCS,
183+
visibility = ["//java/kotlin:__pkg__"],
185184
)
186185

187186
proto_library(

java/kotlin/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ kt_jvm_library(
2626
visibility = ["//visibility:public"],
2727
deps = [
2828
":only_for_use_in_proto_generated_code_its_generator_and_tests",
29-
"//java/lite",
29+
"//java/core:lite_runtime_only",
3030
],
3131
)
3232

@@ -40,7 +40,7 @@ kt_jvm_library(
4040
name = "bytestring_lib",
4141
srcs = ["src/main/kotlin/com/google/protobuf/ByteStrings.kt"],
4242
visibility = ["//java:__subpackages__"],
43-
deps = ["//java/lite"],
43+
deps = ["//java/core:lite_runtime_only"],
4444
)
4545

4646
kt_jvm_library(
@@ -116,7 +116,7 @@ kt_jvm_library(
116116
srcs = ["src/test/kotlin/com/google/protobuf/ByteStringsTest.kt"],
117117
deps = [
118118
":bytestring_lib",
119-
"//java/lite",
119+
"//java/core:lite_runtime_only",
120120
"@protobuf_maven//:com_google_truth_truth",
121121
"@protobuf_maven//:junit_junit",
122122
"@rules_kotlin//kotlin/compiler:kotlin-test",

0 commit comments

Comments
 (0)