diff options
author | Jaewoong Jung <jungjw@google.com> | 2021-04-02 00:38:25 +0000 |
---|---|---|
committer | Jaewoong Jung <jungjw@google.com> | 2021-04-02 04:55:27 +0000 |
commit | 56e12dbbafafcd322ab4a7ac530f086f2bb7a1bb (patch) | |
tree | 033dfb0e5cf39f6227ec425429479208bff79236 /java/java.go | |
parent | 4aa7faf487c76ac45fc7112b56865a44290533ea (diff) |
Revert "Revert "Add min_sdk_version to java_import.""
This reverts commit 5ab650800820efec13d2e36d0ae25a4e4240ac00.
Reason for revert: Resubmitting Ie255f74d40432f4bdd0092d618705a7d17235e58 after fixing the broken targets.
Bug: 183695497
Test: https://android-build.googleplex.com/builds/forrest/run/L58600000849810513
Change-Id: I5f072f396002ca3a45bd530ad9be987efa732833
Diffstat (limited to 'java/java.go')
-rw-r--r-- | java/java.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/java/java.go b/java/java.go index 70ad87938..26e5091b6 100644 --- a/java/java.go +++ b/java/java.go @@ -1074,8 +1074,14 @@ func BinaryHostFactory() android.Module { type ImportProperties struct { Jars []string `android:"path,arch_variant"` + // The version of the SDK that the source prebuilt file was built against. Defaults to the + // current version if not specified. Sdk_version *string + // The minimum version of the SDK that this module supports. Defaults to sdk_version if not + // specified. + Min_sdk_version *string + Installable *bool // List of shared java libs that this module has dependencies to @@ -1139,6 +1145,9 @@ func (j *Import) systemModules() string { } func (j *Import) minSdkVersion() sdkSpec { + if j.properties.Min_sdk_version != nil { + return sdkSpecFrom(*j.properties.Min_sdk_version) + } return j.sdkVersion() } @@ -1350,7 +1359,20 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu // Implements android.ApexModule func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion android.ApiLevel) error { - // Do not check for prebuilts against the min_sdk_version of enclosing APEX + sdkSpec := j.minSdkVersion() + if !sdkSpec.specified() { + return fmt.Errorf("min_sdk_version is not specified") + } + if sdkSpec.kind == sdkCore { + return nil + } + ver, err := sdkSpec.effectiveVersion(ctx) + if err != nil { + return err + } + if ver.ApiLevel(ctx).GreaterThan(sdkVersion) { + return fmt.Errorf("newer SDK(%v)", ver) + } return nil } |