summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2023-09-14 06:27:36 +0000
committer Jihoon Kang <jihoonkang@google.com> 2023-09-18 19:33:01 +0000
commit8fe1982e8bf6728b2f7d1de7380d9a2f86556fbe (patch)
tree3b0c80e8956118faf9484e81b33f5af9a467d16b /java/java_test.go
parentfdf323697eeb6f10577120afb7af69e166b33642 (diff)
Sort api files by api surface in java_api_library
metalava requires api files to be sorted in the narrower api scope to the wider api scope when passed as inputs. Previously, the api files were sorted based on the naming convention, but some api files in prebuilts do not necessarily follow the naming convention (i.e. *-current.txt). Therefore, utilize the api surface information provided by the java_api_contribution provider instead of the naming convention to sort the api files. Test: m nothing Bug: 300175323 Change-Id: I8466db712bff8fef906186bd272d85682877533d
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 8d602b70a..2ee05ec73 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1865,11 +1865,13 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
ctx, _ := testJavaWithFS(t, `
@@ -1919,24 +1921,28 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_c := `
java_api_contribution {
name: "foo3",
- api_file: "current.txt",
+ api_file: "system-current.txt",
+ api_surface: "system",
}
`
provider_bp_d := `
java_api_contribution {
name: "foo4",
- api_file: "current.txt",
+ api_file: "system-current.txt",
+ api_surface: "system",
}
`
ctx, _ := testJavaWithFS(t, `
@@ -1992,8 +1998,9 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
sourceTextFileDirs: []string{"a/current.txt", "b/current.txt"},
},
{
- moduleName: "bar3",
- sourceTextFileDirs: []string{"c/current.txt", "a/current.txt", "b/current.txt", "d/current.txt", "api1/current.txt", "api2/current.txt"},
+ moduleName: "bar3",
+ // API text files need to be sorted from the narrower api scope to the wider api scope
+ sourceTextFileDirs: []string{"a/current.txt", "b/current.txt", "api1/current.txt", "api2/current.txt", "c/system-current.txt", "d/system-current.txt"},
},
}
for _, c := range testcases {
@@ -2011,12 +2018,14 @@ func TestJavaApiLibraryJarGeneration(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
ctx, _ := testJavaWithFS(t, `
@@ -2064,12 +2073,14 @@ func TestJavaApiLibraryLibsLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
lib_bp_a := `
@@ -2139,12 +2150,14 @@ func TestJavaApiLibraryStaticLibsLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
lib_bp_a := `
@@ -2213,12 +2226,14 @@ func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
lib_bp_a := `
@@ -2398,6 +2413,7 @@ func TestJavaApiContributionImport(t *testing.T) {
java_api_contribution_import {
name: "bar",
api_file: "current.txt",
+ api_surface: "public",
}
`)
m := ctx.ModuleForTests("foo", "android_common")