Internal change

PiperOrigin-RevId: 970944472
This commit is contained in:
Protobuf Team Bot 2026-08-25 19:11:59 -07:00 committed by Copybara-Service
parent b6ca8b9fb1
commit 279eb6fe5a
6 changed files with 57 additions and 3 deletions

View file

@ -7,6 +7,11 @@
"""java_lite_proto_library rule""" """java_lite_proto_library rule"""
load("//bazel/private:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library") load(
"//bazel/private:java_lite_proto_library.bzl",
_java_lite_proto_aspect = "java_lite_proto_aspect",
_java_lite_proto_library = "java_lite_proto_library",
)
java_lite_proto_library = _java_lite_proto_library java_lite_proto_library = _java_lite_proto_library
java_lite_proto_aspect = _java_lite_proto_aspect

View file

@ -7,6 +7,11 @@
"""java_proto_library rule.""" """java_proto_library rule."""
load("//bazel/private:java_proto_library.bzl", _java_proto_library = "java_proto_library") load(
"//bazel/private:java_proto_library.bzl",
_bazel_java_proto_aspect = "bazel_java_proto_aspect",
_java_proto_library = "java_proto_library",
)
java_proto_library = _java_proto_library java_proto_library = _java_proto_library
bazel_java_proto_aspect = _bazel_java_proto_aspect

View file

@ -61,7 +61,7 @@ def _aspect_impl(target, ctx):
transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps] transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps]
return [ return [
java_info, add_constraints(java_info, constraints = ["android"]),
JavaProtoAspectInfo(jars = depset(jars, transitive = transitive_jars)), JavaProtoAspectInfo(jars = depset(jars, transitive = transitive_jars)),
] ]

View file

@ -0,0 +1,26 @@
package com.google.protobuf.kotlin.diamond
import kotlin.test.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
/**
* Regression test for Bazel Java One-Version classpath collisions in Kotlin proto generation.
*
* Verifies that when a test depends simultaneously on a leaf Kotlin proto library
* (`:leaf_kt_proto`) and an exporter Kotlin proto library (`:exporter_kt_proto`, which re-exports
* `:leaf_proto`), the Kotlin proto code generation does not duplicate class definitions with
* differing Cyclic Redundancy Checks (CRCs) across multiple jars on the runtime classpath.
*/
@RunWith(JUnit4::class)
class DiamondDependencyTest {
@Test
fun testDiamondDependencyClasspath() {
val leaf = leafMessage { value = "leaf" }
assertEquals("leaf", leaf.value)
val exporter = exporterMessage { value = "exporter" }
assertEquals("exporter", exporter.value)
}
}

View file

@ -0,0 +1,9 @@
edition = "2024";
package protobuf.kotlin.test.diamond;
option java_package = "com.google.protobuf.kotlin.diamond";
message ExporterMessage {
string value = 1;
}

View file

@ -0,0 +1,9 @@
edition = "2024";
package protobuf.kotlin.test.diamond;
option java_package = "com.google.protobuf.kotlin.diamond";
message LeafMessage {
string value = 1;
}