Treat core_platform as stable unless module uses legacy
The sdk_version: "core_platform" refers to the stable core platform unless the module is in the exception list. This change makes sure that CheckStableSdkVersion() reflects that behavior. Bug: 180399951 Test: m nothing Change-Id: Ia0b1e13322352b87f5a3c6621e37f23ba637ffb6
This commit is contained in:
committed by
Daulet Zhanguzin
parent
282671d696
commit
043f5e7881
@@ -1971,7 +1971,7 @@ func TestJavaStableSdkVersion(t *testing.T) {
|
|||||||
java_library {
|
java_library {
|
||||||
name: "myjar",
|
name: "myjar",
|
||||||
srcs: ["foo/bar/MyClass.java"],
|
srcs: ["foo/bar/MyClass.java"],
|
||||||
sdk_version: "core_platform",
|
sdk_version: "test_current",
|
||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@@ -2018,13 +2018,16 @@ func TestJavaStableSdkVersion(t *testing.T) {
|
|||||||
java_library {
|
java_library {
|
||||||
name: "myjar",
|
name: "myjar",
|
||||||
srcs: ["foo/bar/MyClass.java"],
|
srcs: ["foo/bar/MyClass.java"],
|
||||||
sdk_version: "core_platform",
|
sdk_version: "test_current",
|
||||||
apex_available: ["myapex"],
|
apex_available: ["myapex"],
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Updatable apex with non-stable transitive dep",
|
name: "Updatable apex with non-stable transitive dep",
|
||||||
|
// This is not actually detecting that the transitive dependency is unstable, rather it is
|
||||||
|
// detecting that the transitive dependency is building against a wider API surface than the
|
||||||
|
// module that depends on it is using.
|
||||||
expectedError: "compiles against Android API, but dependency \"transitive-jar\" is compiling against private API.",
|
expectedError: "compiles against Android API, but dependency \"transitive-jar\" is compiling against private API.",
|
||||||
bp: `
|
bp: `
|
||||||
apex {
|
apex {
|
||||||
|
11
java/java.go
11
java/java.go
@@ -122,7 +122,16 @@ func (j *Module) CheckStableSdkVersion() error {
|
|||||||
if sdkVersion.stable() {
|
if sdkVersion.stable() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("non stable SDK %v", sdkVersion)
|
if sdkVersion.kind == sdkCorePlatform {
|
||||||
|
if useLegacyCorePlatformApiByName(j.BaseModuleName()) {
|
||||||
|
return fmt.Errorf("non stable SDK %v - uses legacy core platform", sdkVersion)
|
||||||
|
} else {
|
||||||
|
// Treat stable core platform as stable.
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("non stable SDK %v", sdkVersion)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) checkSdkVersions(ctx android.ModuleContext) {
|
func (j *Module) checkSdkVersions(ctx android.ModuleContext) {
|
||||||
|
@@ -160,7 +160,11 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func useLegacyCorePlatformApi(ctx android.EarlyModuleContext) bool {
|
func useLegacyCorePlatformApi(ctx android.EarlyModuleContext) bool {
|
||||||
_, found := legacyCorePlatformApiLookup[ctx.ModuleName()]
|
return useLegacyCorePlatformApiByName(ctx.ModuleName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func useLegacyCorePlatformApiByName(name string) bool {
|
||||||
|
_, found := legacyCorePlatformApiLookup[name]
|
||||||
return found
|
return found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user