From 33dddf5a7e4437e61ab5aa122a23a7df8cf2e470 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Thu, 7 Sep 2023 14:54:41 -0400 Subject: [PATCH] Do not convert resource dirs without resources Previously we would convert to java_resources when there were no resources and get an error. Test: b build //external/libphonenumber/... --config=android Change-Id: I86f30b993a3ffdb20000f6a4c5261e2c4c74263c --- android/allowlists/allowlists.go | 2 ++ bp2build/java_library_conversion_test.go | 7 ++++--- java/java.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go index ad7f8d8c1..dbb435a07 100644 --- a/android/allowlists/allowlists.go +++ b/android/allowlists/allowlists.go @@ -178,6 +178,7 @@ var ( "external/libjpeg-turbo": Bp2BuildDefaultTrueRecursively, "external/libmpeg2": Bp2BuildDefaultTrueRecursively, "external/libpng": Bp2BuildDefaultTrueRecursively, + "external/libphonenumber": Bp2BuildDefaultTrueRecursively, "external/libvpx": Bp2BuildDefaultTrueRecursively, "external/libyuv": Bp2BuildDefaultTrueRecursively, "external/lz4/lib": Bp2BuildDefaultTrue, @@ -1051,6 +1052,7 @@ var ( "libgmock_ndk", // depends on unconverted modules: libgtest_ndk_c++ "libnativehelper_lazy_mts_jni", "libnativehelper_mts_jni", // depends on unconverted modules: libnativetesthelper_jni, libgmock_ndk "libnativetesthelper_jni", // depends on unconverted modules: libgtest_ndk_c++ + "libphonenumber_test", // depends on android.test.mock "libstatslog", // depends on unconverted modules: libstatspull, statsd-aidl-ndk "libstatslog_art", // depends on unconverted modules: statslog_art.cpp, statslog_art.h "linker_reloc_bench_main", // depends on unconverted modules: liblinker_reloc_bench_* diff --git a/bp2build/java_library_conversion_test.go b/bp2build/java_library_conversion_test.go index 990869133..512c1e102 100644 --- a/bp2build/java_library_conversion_test.go +++ b/bp2build/java_library_conversion_test.go @@ -441,12 +441,13 @@ func TestJavaLibraryResourcesExcludeFile(t *testing.T) { func TestJavaLibraryResourcesWithMultipleDirs(t *testing.T) { runJavaLibraryTestCase(t, Bp2buildTestCase{ Filesystem: map[string]string{ - "res/a.res": "", - "res1/b.res": "", + "res/a.res": "", + "res1/b.res": "", + "res2/b.java": "", }, Blueprint: `java_library { name: "java-lib-1", - java_resource_dirs: ["res", "res1"], + java_resource_dirs: ["res", "res1", "res2"], sdk_version: "current", }`, ExpectedBazelTargets: []string{ diff --git a/java/java.go b/java/java.go index 967f8c297..99bb1b3ee 100644 --- a/java/java.go +++ b/java/java.go @@ -2826,7 +2826,7 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte if resourceStripPrefix == nil && i == 0 { resourceStripPrefix = resAttr.Resource_strip_prefix resources = resAttr.Resources.Value - } else { + } else if !resAttr.Resources.IsEmpty() { ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "java_resources",