diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go index c88af1b55..5099b498a 100644 --- a/bp2build/java_library_conversion_test.go +++ b/bp2build/java_library_conversion_test.go @@ -1109,3 +1109,23 @@ func TestJavaLibrarySameNameAsPrebuilt(t *testing.T) { ctx.RegisterModuleType("java_import", java.ImportFactory) }) } + +func TestJavaLibrarySharding(t *testing.T) { + runJavaLibraryTestCase(t, Bp2buildTestCase{ + Description: "java library with sharded compilation", + Blueprint: `java_library { + name: "lib1", + srcs: ["a.java"], + javac_shard_size: 3, + sdk_version: "current", + }`, + ExpectedBazelTargets: []string{ + MakeBazelTarget("java_library", "lib1", AttrNameToString{ + "srcs": `["a.java"]`, + "sdk_version": `"current"`, + "javac_shard_size": "3", + }), + MakeNeverlinkDuplicateTarget("java_library", "lib1"), + }, + }) +} diff --git a/java/java.go b/java/java.go index 1b9941c4e..de74ab2ce 100644 --- a/java/java.go +++ b/java/java.go @@ -2916,6 +2916,7 @@ type javaCommonAttributes struct { Sdk_version bazel.StringAttribute Java_version bazel.StringAttribute Errorprone_force_enable bazel.BoolAttribute + Javac_shard_size *int64 } type javaDependencyLabels struct { @@ -3105,6 +3106,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.Bp2buildMutatorContext Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, Errorprone_force_enable: errorproneForceEnable, + Javac_shard_size: m.properties.Javac_shard_size, } for axis, configToProps := range archVariantProps {