diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 24 | 
1 files changed, 24 insertions, 0 deletions
diff --git a/java/java.go b/java/java.go index 0d39a6a78..988a07492 100644 --- a/java/java.go +++ b/java/java.go @@ -1812,6 +1812,28 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) {  	}  } +func (al *ApiLibrary) sortApiFilesByApiScope(ctx android.ModuleContext, srcFiles android.Paths) android.Paths { +	sortedSrcFiles := android.Paths{} + +	// API signature file name sorted from +	// the narrowest api scope to the widest api scope +	scopeOrderedSourceFileNames := allApiScopes.Strings( +		func(s *apiScope) string { return s.apiFilePrefix + "current.txt" }) + +	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)  |