summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2023-09-20 23:43:32 +0000
committer Jihoon Kang <jihoonkang@google.com> 2023-09-22 16:55:43 +0000
commita96a7b1e13f04c79831347acc02bedc62cfd954e (patch)
tree89e50313e6c5c4eb2078aa42f79320e9fb0ea113 /java/java_test.go
parent6be0f00671e39a8b744a10bd1d0c91dc8724d4b2 (diff)
Remove naming conventioned based file sorting in java_api_library
With api_files property being removed from java_api_library, all api files are passed to java_api_library via java_api_contribution, which provide api_surface information. Instead of relying on the naming convention of the api files, java_api_library can utilize this information to sort the api files from narrower api scope to the wider api scope. Test: m --build-from-text-stub Bug: 295429988 Change-Id: Idd832778833c072c6b7e9d1f775533e5f4e2af00
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go
index ec6be5c48..b555a9513 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2398,3 +2398,30 @@ func TestJavaApiContributionImport(t *testing.T) {
sourceFilesFlag := "--source-files current.txt"
android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag)
}
+
+func TestJavaApiLibraryApiFilesSorting(t *testing.T) {
+ ctx, _ := testJava(t, `
+ java_api_library {
+ name: "foo",
+ api_contributions: [
+ "system-server-api-stubs-docs-non-updatable.api.contribution",
+ "test-api-stubs-docs-non-updatable.api.contribution",
+ "system-api-stubs-docs-non-updatable.api.contribution",
+ "module-lib-api-stubs-docs-non-updatable.api.contribution",
+ "api-stubs-docs-non-updatable.api.contribution",
+ ],
+ }
+ `)
+ m := ctx.ModuleForTests("foo", "android_common")
+ manifest := m.Output("metalava.sbox.textproto")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ manifestCommand := sboxProto.Commands[0].GetCommand()
+
+ // Api files are sorted from the narrowest api scope to the widest api scope.
+ // test api and module lib api surface do not have subset/superset relationship,
+ // but they will never be passed as inputs at the same time.
+ sourceFilesFlag := "--source-files default/java/api/current.txt " +
+ "default/java/api/system-current.txt default/java/api/test-current.txt " +
+ "default/java/api/module-lib-current.txt default/java/api/system-server-current.txt"
+ android.AssertStringDoesContain(t, "source text files not in api scope order", manifestCommand, sourceFilesFlag)
+}