Fix build breakages when WITHOUT_CHECK_API=true
Bug: 158578354
Test: export WITHOUT_CHECK_API=true
m checkbuild
Change-Id: I7b5fff40b870c9d754f779ff1c3314bac7e42440
Merged-In: I7b5fff40b870c9d754f779ff1c3314bac7e42440
diff --git a/java/droiddoc.go b/java/droiddoc.go
index d6bff95..a24d44b 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -1414,7 +1414,7 @@
}
func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
- if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() {
+ if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() && d.apiFile != nil {
if d.apiFile.String() == "" {
ctx.ModuleErrorf("API signature file has to be specified in Metalava when jdiff is enabled.")
}
@@ -1835,13 +1835,19 @@
Flag("-XDignore.symbol.file").
FlagWithArg("-doclet ", "jdiff.JDiff").
FlagWithInput("-docletpath ", jdiff).
- Flag("-quiet").
- FlagWithArg("-newapi ", strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext())).
- FlagWithArg("-newapidir ", filepath.Dir(d.apiXmlFile.String())).
- Implicit(d.apiXmlFile).
- FlagWithArg("-oldapi ", strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext())).
- FlagWithArg("-oldapidir ", filepath.Dir(d.lastReleasedApiXmlFile.String())).
- Implicit(d.lastReleasedApiXmlFile)
+ Flag("-quiet")
+
+ if d.apiXmlFile != nil {
+ cmd.FlagWithArg("-newapi ", strings.TrimSuffix(d.apiXmlFile.Base(), d.apiXmlFile.Ext())).
+ FlagWithArg("-newapidir ", filepath.Dir(d.apiXmlFile.String())).
+ Implicit(d.apiXmlFile)
+ }
+
+ if d.lastReleasedApiXmlFile != nil {
+ cmd.FlagWithArg("-oldapi ", strings.TrimSuffix(d.lastReleasedApiXmlFile.Base(), d.lastReleasedApiXmlFile.Ext())).
+ FlagWithArg("-oldapidir ", filepath.Dir(d.lastReleasedApiXmlFile.String())).
+ Implicit(d.lastReleasedApiXmlFile)
+ }
rule.Command().
BuiltTool(ctx, "soong_zip").
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 7ce0912..26bd670 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -2188,8 +2188,12 @@
properties.Jars = jars
properties.SdkVersion = sdk.sdkVersionForStubsLibrary(ctx.SdkModuleContext(), apiScope)
properties.StubsSrcJar = paths.stubsSrcJar.Path()
- properties.CurrentApiFile = paths.currentApiFilePath.Path()
- properties.RemovedApiFile = paths.removedApiFilePath.Path()
+ if paths.currentApiFilePath.Valid() {
+ properties.CurrentApiFile = paths.currentApiFilePath.Path()
+ }
+ if paths.removedApiFilePath.Valid() {
+ properties.RemovedApiFile = paths.removedApiFilePath.Path()
+ }
s.Scopes[apiScope] = properties
}
}