summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go30
1 files changed, 26 insertions, 4 deletions
diff --git a/java/java.go b/java/java.go
index 9786947f7..3ffe5729e 100644
--- a/java/java.go
+++ b/java/java.go
@@ -33,12 +33,12 @@ import (
)
func init() {
- RegisterJavaBuildComponents(android.InitRegistrationContext)
+ registerJavaBuildComponents(android.InitRegistrationContext)
RegisterJavaSdkMemberTypes()
}
-func RegisterJavaBuildComponents(ctx android.RegistrationContext) {
+func registerJavaBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("java_defaults", DefaultsFactory)
ctx.RegisterModuleType("java_library", LibraryFactory)
@@ -776,7 +776,7 @@ func (j *TestHost) AddExtraResource(p android.Path) {
func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if j.testProperties.Test_options.Unit_test == nil && ctx.Host() {
// TODO(b/): Clean temporary heuristic to avoid unexpected onboarding.
- defaultUnitTest := !inList("tradefed", j.properties.Static_libs) && !inList("tradefed", j.properties.Libs) && !inList("cts", j.testProperties.Test_suites)
+ defaultUnitTest := !inList("tradefed", j.properties.Libs) && !inList("cts", j.testProperties.Test_suites)
j.testProperties.Test_options.Unit_test = proptools.BoolPtr(defaultUnitTest)
}
j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template,
@@ -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
}