Change checkJavaStableSdkVersion to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I221f4ea7479d512d49cfb40a8cb06bba62ec2c7a
diff --git a/java/base.go b/java/base.go
index 3bf2e23..c0ac4ab 100644
--- a/java/base.go
+++ b/java/base.go
@@ -612,21 +612,24 @@
return proptools.Bool(j.properties.Is_stubs_module)
}
-func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error {
- sdkVersion := j.SdkVersion(ctx)
- if sdkVersion.Stable() {
- return nil
- }
- if sdkVersion.Kind == android.SdkCorePlatform {
- if useLegacyCorePlatformApi(ctx, j.BaseModuleName()) {
- return fmt.Errorf("non stable SDK %v - uses legacy core platform", sdkVersion)
- } else {
- // Treat stable core platform as stable.
+func CheckStableSdkVersion(ctx android.BaseModuleContext, module android.ModuleProxy) error {
+ if info, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
+ if info.SdkVersion.Stable() {
return nil
}
- } else {
- return fmt.Errorf("non stable SDK %v", sdkVersion)
+ if info.SdkVersion.Kind == android.SdkCorePlatform {
+ if useLegacyCorePlatformApi(ctx, android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).BaseModuleName) {
+ return fmt.Errorf("non stable SDK %v - uses legacy core platform", info.SdkVersion)
+ } else {
+ // Treat stable core platform as stable.
+ return nil
+ }
+ } else {
+ return fmt.Errorf("non stable SDK %v", info.SdkVersion)
+ }
}
+
+ return nil
}
// checkSdkVersions enforces restrictions around SDK dependencies.
@@ -1300,6 +1303,7 @@
ExportedPluginDisableTurbine: j.exportedDisableTurbine,
StubsLinkType: j.stubsLinkType,
AconfigIntermediateCacheOutputPaths: deps.aconfigProtoFiles,
+ SdkVersion: j.SdkVersion(ctx),
})
j.outputFile = j.headerJarFile
@@ -1929,6 +1933,7 @@
JacocoReportClassesFile: j.jacocoReportClassesFile,
StubsLinkType: j.stubsLinkType,
AconfigIntermediateCacheOutputPaths: j.aconfigCacheFiles,
+ SdkVersion: j.SdkVersion(ctx),
})
// Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource