Export API files as part of the java_sdk_library
Bug: 153443117
Test: m nothing
Merged-In: I9d6f5b91a7cc25019e2eb9e3c138f0874d2831de
Change-Id: I9d6f5b91a7cc25019e2eb9e3c138f0874d2831de
(cherry picked from commit 1fd005d5b30ce24593d7fe2e7dba43855d6f6466)
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 90f143a..e0ea515 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -339,6 +339,7 @@
// Provider of information about API stubs, used by java_sdk_library.
type ApiStubsProvider interface {
ApiFilePath
+ RemovedApiFilePath() android.Path
StubsSrcJar() android.Path
}
@@ -1187,6 +1188,10 @@
return d.apiFilePath
}
+func (d *Droidstubs) RemovedApiFilePath() android.Path {
+ return d.removedApiFile
+}
+
func (d *Droidstubs) StubsSrcJar() android.Path {
return d.stubsSrcJar
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 85d5bd3..39c118d 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -240,10 +240,11 @@
}
type scopePaths struct {
- stubsHeaderPath android.Paths
- stubsImplPath android.Paths
- apiFilePath android.Path
- stubsSrcJar android.Path
+ stubsHeaderPath android.Paths
+ stubsImplPath android.Paths
+ currentApiFilePath android.Path
+ removedApiFilePath android.Path
+ stubsSrcJar android.Path
}
// Common code between sdk library and sdk library import
@@ -334,7 +335,8 @@
if scopeTag, ok := tag.(scopeDependencyTag); ok {
apiScope := scopeTag.apiScope
scopePaths := module.getScopePaths(apiScope)
- scopePaths.apiFilePath = doc.ApiFilePath()
+ scopePaths.currentApiFilePath = doc.ApiFilePath()
+ scopePaths.removedApiFilePath = doc.RemovedApiFilePath()
scopePaths.stubsSrcJar = doc.StubsSrcJar()
} else {
ctx.ModuleErrorf("depends on module %q of unknown tag %q", otherName, tag)
@@ -826,6 +828,12 @@
// The stub sources.
Stub_srcs []string `android:"path"`
+
+ // The current.txt
+ Current_api string `android:"path"`
+
+ // The removed.txt
+ Removed_api string `android:"path"`
}
type sdkLibraryImportProperties struct {
@@ -1187,9 +1195,11 @@
}
type scopeProperties struct {
- Jars android.Paths
- StubsSrcJar android.Path
- SdkVersion string
+ Jars android.Paths
+ StubsSrcJar android.Path
+ CurrentApiFile android.Path
+ RemovedApiFile android.Path
+ SdkVersion string
}
func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberContext, variant android.Module) {
@@ -1204,6 +1214,8 @@
properties.Jars = jars
properties.SdkVersion = apiScope.sdkVersion
properties.StubsSrcJar = paths.stubsSrcJar
+ properties.CurrentApiFile = paths.currentApiFilePath
+ properties.RemovedApiFile = paths.removedApiFilePath
s.Scopes[apiScope] = properties
}
}
@@ -1232,6 +1244,18 @@
ctx.SnapshotBuilder().UnzipToSnapshot(properties.StubsSrcJar, snapshotRelativeDir)
scopeSet.AddProperty("stub_srcs", []string{snapshotRelativeDir})
+ if properties.CurrentApiFile != nil {
+ currentApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+".txt")
+ ctx.SnapshotBuilder().CopyToSnapshot(properties.CurrentApiFile, currentApiSnapshotPath)
+ scopeSet.AddProperty("current_api", currentApiSnapshotPath)
+ }
+
+ if properties.RemovedApiFile != nil {
+ removedApiSnapshotPath := filepath.Join(scopeDir, ctx.Name()+"-removed.txt")
+ ctx.SnapshotBuilder().CopyToSnapshot(properties.CurrentApiFile, removedApiSnapshotPath)
+ scopeSet.AddProperty("removed_api", removedApiSnapshotPath)
+ }
+
if properties.SdkVersion != "" {
scopeSet.AddProperty("sdk_version", properties.SdkVersion)
}