summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go
index 0d39a6a78..6667a52f1 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1812,6 +1812,28 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {
}
}
+// API signature file names sorted from
+// the narrowest api scope to the widest api scope
+var scopeOrderedSourceFileNames = allApiScopes.Strings(
+ func(s *apiScope) string { return s.apiFilePrefix + "current.txt" })
+
+func (al *ApiLibrary) sortApiFilesByApiScope(ctx android.ModuleContext, srcFiles android.Paths) android.Paths {
+ sortedSrcFiles := android.Paths{}
+
+ for _, scopeSourceFileName := range scopeOrderedSourceFileNames {
+ for _, sourceFileName := range srcFiles {
+ if sourceFileName.Base() == scopeSourceFileName {
+ sortedSrcFiles = append(sortedSrcFiles, sourceFileName)
+ }
+ }
+ }
+ if len(srcFiles) != len(sortedSrcFiles) {
+ ctx.ModuleErrorf("Unrecognizable source file found within %s", srcFiles)
+ }
+
+ return sortedSrcFiles
+}
+
func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule := android.NewRuleBuilder(pctx, ctx)
@@ -1862,6 +1884,8 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName())
}
+ srcFiles = al.sortApiFilesByApiScope(ctx, srcFiles)
+
cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir)
al.stubsFlags(ctx, cmd, stubsDir)