From 795319fadb84b4e65c9fb3defbaf25b612acd53b Mon Sep 17 00:00:00 2001 From: Jihoon Kang Date: Wed, 17 May 2023 00:23:38 +0000 Subject: Disallow missing api source files for java_api_library module The purpose of this change is to enable filegroups to be taken as inputs for `java_api_library` module `api_files` property. However, since android.MaybeExistentPathForSource() does not support this, it needs to be replaced with android.PathForModuleSrc(), which checks for the files' existence. Bug: 283006953 Test: go test ./java Change-Id: I8a7d7f200f900219cc17243194a4c26071329ee6 --- java/java_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'java/java_test.go') diff --git a/java/java_test.go b/java/java_test.go index 2a4913ecd..ea89e6eb8 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2252,6 +2252,29 @@ func TestJavaApiLibraryDepApiSrcs(t *testing.T) { android.AssertStringDoesContain(t, "Command expected to contain output files list text file flag", manifestCommand, "--out __SBOX_SANDBOX_DIR__/out/sources.txt") } +func TestJavaApiLibraryFilegroupInput(t *testing.T) { + ctx, _ := testJavaWithFS(t, ` + filegroup { + name: "default_current.txt", + srcs: ["current.txt"], + } + + java_api_library { + name: "foo", + api_files: [":default_current.txt"], + } + `, + map[string][]byte{ + "current.txt": nil, + }) + + m := ctx.ModuleForTests("foo", "android_common") + outputs := fmt.Sprint(m.AllOutputs()) + if !strings.Contains(outputs, "foo/foo.jar") { + t.Errorf("Module output does not contain expected jar %s", "foo/foo.jar") + } +} + func TestTradefedOptions(t *testing.T) { result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, ` java_test_host { -- cgit v1.2.3-59-g8ed1b