Colin Cross | e4759b9 | 2019-02-15 10:37:39 -0800 | [diff] [blame^] | 1 | // Copyright 2019 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | ) |
| 22 | |
| 23 | func TestConfig(buildDir string, env map[string]string) android.Config { |
| 24 | if env == nil { |
| 25 | env = make(map[string]string) |
| 26 | } |
| 27 | if env["ANDROID_JAVA8_HOME"] == "" { |
| 28 | env["ANDROID_JAVA8_HOME"] = "jdk8" |
| 29 | } |
| 30 | config := android.TestArchConfig(buildDir, env) |
| 31 | config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"} |
| 32 | |
| 33 | return config |
| 34 | } |
| 35 | |
| 36 | func GatherRequiredDepsForTest() string { |
| 37 | var bp string |
| 38 | |
| 39 | extraModules := []string{ |
| 40 | "core-lambda-stubs", |
| 41 | "framework", |
| 42 | "ext", |
| 43 | "android_stubs_current", |
| 44 | "android_system_stubs_current", |
| 45 | "android_test_stubs_current", |
| 46 | "core.current.stubs", |
| 47 | "core.platform.api.stubs", |
| 48 | "kotlin-stdlib", |
| 49 | "kotlin-annotations", |
| 50 | } |
| 51 | |
| 52 | for _, extra := range extraModules { |
| 53 | bp += fmt.Sprintf(` |
| 54 | java_library { |
| 55 | name: "%s", |
| 56 | srcs: ["a.java"], |
| 57 | no_standard_libs: true, |
| 58 | sdk_version: "core_current", |
| 59 | system_modules: "core-platform-api-stubs-system-modules", |
| 60 | } |
| 61 | `, extra) |
| 62 | } |
| 63 | |
| 64 | bp += ` |
| 65 | android_app { |
| 66 | name: "framework-res", |
| 67 | no_framework_libs: true, |
| 68 | } |
| 69 | ` |
| 70 | |
| 71 | systemModules := []string{ |
| 72 | "core-system-modules", |
| 73 | "core-platform-api-stubs-system-modules", |
| 74 | "android_stubs_current_system_modules", |
| 75 | "android_system_stubs_current_system_modules", |
| 76 | "android_test_stubs_current_system_modules", |
| 77 | } |
| 78 | |
| 79 | for _, extra := range systemModules { |
| 80 | bp += fmt.Sprintf(` |
| 81 | java_system_modules { |
| 82 | name: "%s", |
| 83 | } |
| 84 | `, extra) |
| 85 | } |
| 86 | |
| 87 | return bp |
| 88 | } |