Allow java_sdk_library to specify doctags_files
When generating Javadoc the processor needs to be given information
about the doctags that are present in the source. This change allows
that information to be managed with the java_sdk_library that generates
the stubs source from which the Javadoc is generated.
Bug: 168301990
Test: Built offline-sdk-docs with and without the change and
diffed them. The only difference was the timestamp.js
file.
Change-Id: I4adbeb0781bc2191461fec856ffa90ea185e7434
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 0d29a37..60924a6 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -589,6 +589,9 @@
// An Android shared library is one that can be referenced in a <uses-library> element
// in an AndroidManifest.xml.
Shared_library *bool
+
+ // Files containing information about supported java doc tags.
+ Doctag_files []string `android:"path"`
}
// Common code between sdk library and sdk library import
@@ -601,6 +604,9 @@
commonSdkLibraryProperties commonToSdkLibraryAndImportProperties
+ // Paths to commonSdkLibraryProperties.Doctag_files
+ doctagPaths android.Paths
+
// Functionality related to this being used as a component of a java_sdk_library.
EmbeddableSdkLibraryComponent
}
@@ -633,6 +639,10 @@
return true
}
+func (c *commonToSdkLibraryAndImport) generateCommonBuildActions(ctx android.ModuleContext) {
+ c.doctagPaths = android.PathsForModuleSrc(ctx, c.commonSdkLibraryProperties.Doctag_files)
+}
+
// Module name of the runtime implementation library
func (c *commonToSdkLibraryAndImport) implLibraryModuleName() string {
return c.moduleBase.BaseModuleName() + ".impl"
@@ -732,6 +742,14 @@
}
} else {
+ switch tag {
+ case ".doctags":
+ if c.doctagPaths != nil {
+ return c.doctagPaths, nil
+ } else {
+ return nil, fmt.Errorf("no doctag_files specified on %s", c.moduleBase.BaseModuleName())
+ }
+ }
return nil, nil
}
}
@@ -1014,6 +1032,8 @@
}
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ module.generateCommonBuildActions(ctx)
+
// Only build an implementation library if required.
if module.requiresRuntimeImplementationLibrary() {
module.Library.GenerateAndroidBuildActions(ctx)
@@ -1895,6 +1915,8 @@
}
func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ module.generateCommonBuildActions(ctx)
+
// Record the paths to the prebuilt stubs library and stubs source.
ctx.VisitDirectDeps(func(to android.Module) {
tag := ctx.OtherModuleDependencyTag(to)
@@ -2187,6 +2209,9 @@
// True if the java_sdk_library_import is for a shared library, false
// otherwise.
Shared_library *bool
+
+ // The paths to the doctag files to add to the prebuilt.
+ Doctag_paths android.Paths
}
type scopeProperties struct {
@@ -2226,6 +2251,7 @@
s.Libs = sdk.properties.Libs
s.Naming_scheme = sdk.commonSdkLibraryProperties.Naming_scheme
s.Shared_library = proptools.BoolPtr(sdk.sharedLibrary())
+ s.Doctag_paths = sdk.doctagPaths
}
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
@@ -2274,6 +2300,16 @@
}
}
+ if len(s.Doctag_paths) > 0 {
+ dests := []string{}
+ for _, p := range s.Doctag_paths {
+ dest := filepath.Join("doctags", p.Rel())
+ ctx.SnapshotBuilder().CopyToSnapshot(p, dest)
+ dests = append(dests, dest)
+ }
+ propertySet.AddProperty("doctag_files", dests)
+ }
+
if len(s.Libs) > 0 {
propertySet.AddPropertyWithTag("libs", s.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(false))
}