diff options
Diffstat (limited to 'java/base.go')
| -rw-r--r-- | java/base.go | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/java/base.go b/java/base.go index b925350a0..4932c4831 100644 --- a/java/base.go +++ b/java/base.go @@ -442,9 +442,6 @@ type Module struct { // manifest file to use instead of properties.Manifest overrideManifest android.OptionalPath - // map of SDK version to class loader context - classLoaderContexts dexpreopt.ClassLoaderContextMap - // list of plugins that this java module is exporting exportedPluginJars android.Paths @@ -1481,11 +1478,30 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } if ctx.Device() { - lintSDKVersionString := func(sdkSpec android.SdkSpec) string { + lintSDKVersion := func(sdkSpec android.SdkSpec) int { if v := sdkSpec.ApiLevel; !v.IsPreview() { - return v.String() + return v.FinalInt() } else { - return ctx.Config().DefaultAppTargetSdk(ctx).String() + // When running metalava, we pass --version-codename. When that value + // is not REL, metalava will add 1 to the --current-version argument. + // On old branches, PLATFORM_SDK_VERSION is the latest version (for that + // branch) and the codename is REL, except potentially on the most + // recent non-master branch. On that branch, it goes through two other + // phases before it gets to the phase previously described: + // - PLATFORM_SDK_VERSION has not been updated yet, and the codename + // is not rel. This happens for most of the internal branch's life + // while the branch has been cut but is still under active development. + // - PLATFORM_SDK_VERSION has been set, but the codename is still not + // REL. This happens briefly during the release process. During this + // state the code to add --current-version is commented out, and then + // that commenting out is reverted after the codename is set to REL. + // On the master branch, the PLATFORM_SDK_VERSION always represents a + // prior version and the codename is always non-REL. + // + // We need to add one here to match metalava adding 1. Technically + // this means that in the state described in the second bullet point + // above, this number is 1 higher than it should be. + return ctx.Config().PlatformSdkVersion().FinalInt() + 1 } } @@ -1494,9 +1510,9 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { j.linter.srcJars = srcJars j.linter.classpath = append(append(android.Paths(nil), flags.bootClasspath...), flags.classpath...) j.linter.classes = j.implementationJarFile - j.linter.minSdkVersion = lintSDKVersionString(j.MinSdkVersion(ctx)) - j.linter.targetSdkVersion = lintSDKVersionString(j.TargetSdkVersion(ctx)) - j.linter.compileSdkVersion = lintSDKVersionString(j.SdkVersion(ctx)) + j.linter.minSdkVersion = lintSDKVersion(j.MinSdkVersion(ctx)) + j.linter.targetSdkVersion = lintSDKVersion(j.TargetSdkVersion(ctx)) + j.linter.compileSdkVersion = lintSDKVersion(j.SdkVersion(ctx)) j.linter.compileSdkKind = j.SdkVersion(ctx).Kind j.linter.javaLanguageLevel = flags.javaVersion.String() j.linter.kotlinLanguageLevel = "1.3" |