diff --git a/java/androidmk.go b/java/androidmk.go index b5235940e..b7df9bf9e 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -549,8 +549,8 @@ func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries { if BoolDefault(jd.properties.Installable, true) { entries.SetPath("LOCAL_DROIDDOC_DOC_ZIP", jd.docZip) } - if jd.stubsSrcJar != nil { - entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.stubsSrcJar) + if jd.exportableStubsSrcJar != nil { + entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", jd.exportableStubsSrcJar) } }, }, @@ -596,17 +596,17 @@ func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries { Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { - if dstubs.Javadoc.stubsSrcJar != nil { - entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.stubsSrcJar) + if dstubs.Javadoc.exportableStubsSrcJar != nil { + entries.SetPath("LOCAL_DROIDDOC_STUBS_SRCJAR", dstubs.Javadoc.exportableStubsSrcJar) } if dstubs.everythingArtifacts.apiVersionsXml != nil { - entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.everythingArtifacts.apiVersionsXml) + entries.SetPath("LOCAL_DROIDDOC_API_VERSIONS_XML", dstubs.exportableArtifacts.apiVersionsXml) } if dstubs.everythingArtifacts.annotationsZip != nil { - entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.everythingArtifacts.annotationsZip) + entries.SetPath("LOCAL_DROIDDOC_ANNOTATIONS_ZIP", dstubs.exportableArtifacts.annotationsZip) } if dstubs.everythingArtifacts.metadataZip != nil { - entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.everythingArtifacts.metadataZip) + entries.SetPath("LOCAL_DROIDDOC_METADATA_ZIP", dstubs.exportableArtifacts.metadataZip) } }, }, diff --git a/java/droidstubs.go b/java/droidstubs.go index dc3a0ec19..426754553 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -333,66 +333,89 @@ func (d *Droidstubs) OutputFiles(tag string) (android.Paths, error) { } } -func (d *Droidstubs) AnnotationsZip(stubsType StubsType) (android.Path, error) { +func (d *Droidstubs) AnnotationsZip(stubsType StubsType) (ret android.Path, err error) { switch stubsType { case Everything: - return d.everythingArtifacts.annotationsZip, nil + ret, err = d.everythingArtifacts.annotationsZip, nil case Exportable: - return d.exportableArtifacts.annotationsZip, nil + ret, err = d.exportableArtifacts.annotationsZip, nil default: - return nil, fmt.Errorf("annotations zip not supported for the stub type %s", stubsType.String()) + ret, err = nil, fmt.Errorf("annotations zip not supported for the stub type %s", stubsType.String()) } + return ret, err } -func (d *Droidstubs) ApiFilePath(stubsType StubsType) (android.Path, error) { +func (d *Droidstubs) ApiFilePath(stubsType StubsType) (ret android.Path, err error) { switch stubsType { case Everything: - return d.apiFile, nil + ret, err = d.apiFile, nil case Exportable: - return d.exportableApiFile, nil + ret, err = d.exportableApiFile, nil default: - return nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String()) + ret, err = nil, fmt.Errorf("api file path not supported for the stub type %s", stubsType.String()) } + if ret == nil && err == nil { + err = fmt.Errorf("stubs srcjar is null for the stub type %s", stubsType.String()) + } + return ret, err } -func (d *Droidstubs) ApiVersionsXmlFilePath(stubsType StubsType) (android.Path, error) { +func (d *Droidstubs) ApiVersionsXmlFilePath(stubsType StubsType) (ret android.Path, err error) { switch stubsType { case Everything: - return d.everythingArtifacts.apiVersionsXml, nil - default: - return nil, fmt.Errorf("api versions xml file path not supported for the stub type %s", stubsType.String()) - } -} - -func (d *Droidstubs) DocZip(stubsType StubsType) (android.Path, error) { - switch stubsType { - case Everything: - return d.docZip, nil - default: - return nil, fmt.Errorf("docs zip not supported for the stub type %s", stubsType.String()) - } -} - -func (d *Droidstubs) RemovedApiFilePath(stubsType StubsType) (android.Path, error) { - switch stubsType { - case Everything: - return d.removedApiFile, nil + ret, err = d.everythingArtifacts.apiVersionsXml, nil case Exportable: - return d.exportableRemovedApiFile, nil + ret, err = d.exportableArtifacts.apiVersionsXml, nil default: - return nil, fmt.Errorf("removed api file path not supported for the stub type %s", stubsType.String()) + ret, err = nil, fmt.Errorf("api versions xml file path not supported for the stub type %s", stubsType.String()) } + if ret == nil && err == nil { + err = fmt.Errorf("api versions xml file is null for the stub type %s", stubsType.String()) + } + return ret, err } -func (d *Droidstubs) StubsSrcJar(stubsType StubsType) (android.Path, error) { +func (d *Droidstubs) DocZip(stubsType StubsType) (ret android.Path, err error) { switch stubsType { case Everything: - return d.stubsSrcJar, nil - case Exportable: - return d.exportableStubsSrcJar, nil + ret, err = d.docZip, nil default: - return nil, fmt.Errorf("stubs srcjar not supported for the stub type %s", stubsType.String()) + ret, err = nil, fmt.Errorf("docs zip not supported for the stub type %s", stubsType.String()) } + if ret == nil && err == nil { + err = fmt.Errorf("docs zip is null for the stub type %s", stubsType.String()) + } + return ret, err +} + +func (d *Droidstubs) RemovedApiFilePath(stubsType StubsType) (ret android.Path, err error) { + switch stubsType { + case Everything: + ret, err = d.removedApiFile, nil + case Exportable: + ret, err = d.exportableRemovedApiFile, nil + default: + ret, err = nil, fmt.Errorf("removed api file path not supported for the stub type %s", stubsType.String()) + } + if ret == nil && err == nil { + err = fmt.Errorf("removed api file is null for the stub type %s", stubsType.String()) + } + return ret, err +} + +func (d *Droidstubs) StubsSrcJar(stubsType StubsType) (ret android.Path, err error) { + switch stubsType { + case Everything: + ret, err = d.stubsSrcJar, nil + case Exportable: + ret, err = d.exportableStubsSrcJar, nil + default: + ret, err = nil, fmt.Errorf("stubs srcjar not supported for the stub type %s", stubsType.String()) + } + if ret == nil && err == nil { + err = fmt.Errorf("stubs srcjar is null for the stub type %s", stubsType.String()) + } + return ret, err } func (d *Droidstubs) CurrentApiTimestamp() android.Path { @@ -982,8 +1005,11 @@ func (d *Droidstubs) exportableStubCmd(ctx android.ModuleContext, params stubsCo stubConfig: params, } - d.Javadoc.exportableStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar") - optionalCmdParams.stubsSrcJar = d.Javadoc.exportableStubsSrcJar + if params.generateStubs { + d.Javadoc.exportableStubsSrcJar = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-"+"stubs.srcjar") + optionalCmdParams.stubsSrcJar = d.Javadoc.exportableStubsSrcJar + } + if params.writeSdkValues { d.exportableArtifacts.metadataZip = android.PathForModuleOut(ctx, params.stubsType.String(), ctx.ModuleName()+"-metadata.zip") d.exportableArtifacts.metadataDir = android.PathForModuleOut(ctx, params.stubsType.String(), "metadata")