Modify error emit condition for checking api files in java_api_library

java_api_library currently emits error based when the
java_api_contribution module has an empty api file or when the module
does not have any api files. This may be problematic in partial
manifests where allow missing dependency is set, thus add this condition
for error emission.

Test: go test ./java
Bug: 284212875
Change-Id: I10b4baa5723e7a53d931823b3029ea20ac731911
This commit is contained in:
Jihoon Kang 2023-05-25 05:28:29 +00:00
parent 4aed3703dd
commit 160634ca3d

View file

@ -1813,7 +1813,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
case javaApiContributionTag:
provider := ctx.OtherModuleProvider(dep, JavaApiImportProvider).(JavaApiImportInfo)
providerApiFile := provider.ApiFile
if providerApiFile == nil {
if providerApiFile == nil && !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("Error: %s has an empty api file.", dep.Name())
}
srcFiles = append(srcFiles, android.PathForSource(ctx, providerApiFile.String()))
@ -1835,7 +1835,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
srcFiles = append(srcFiles, android.PathForModuleSrc(ctx, api))
}
if srcFiles == nil {
if srcFiles == nil && !ctx.Config().AllowMissingDependencies() {
ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName())
}