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
This commit is contained in:
Jihoon Kang
2023-09-20 23:43:32 +00:00
parent 6be0f00671
commit a96a7b1e13
3 changed files with 55 additions and 22 deletions

View File

@@ -286,6 +286,17 @@ func (scopes apiScopes) Strings(accessor func(*apiScope) string) []string {
return list
}
// Method that maps the apiScopes properties to the index of each apiScopes elements.
// apiScopes property to be used as the key can be specified with the input accessor.
// Only a string property of apiScope can be used as the key of the map.
func (scopes apiScopes) MapToIndex(accessor func(*apiScope) string) map[string]int {
ret := make(map[string]int)
for i, scope := range scopes {
ret[accessor(scope)] = i
}
return ret
}
var (
scopeByName = make(map[string]*apiScope)
allScopeNames []string