blob: bec3c0b2c630b9ce0a1f7f56c1453baec5ca44ed [file] [log] [blame]
Colin Crosse4759b92019-02-15 10:37:39 -08001// 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
15package java
16
17import (
18 "fmt"
19
20 "android/soong/android"
Colin Cross69f59a32019-02-15 10:39:37 -080021 "android/soong/dexpreopt"
Colin Crosse4759b92019-02-15 10:37:39 -080022)
23
24func TestConfig(buildDir string, env map[string]string) android.Config {
25 if env == nil {
26 env = make(map[string]string)
27 }
28 if env["ANDROID_JAVA8_HOME"] == "" {
29 env["ANDROID_JAVA8_HOME"] = "jdk8"
30 }
31 config := android.TestArchConfig(buildDir, env)
32 config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"}
33
Colin Cross69f59a32019-02-15 10:39:37 -080034 pathCtx := android.PathContextForTesting(config, nil)
35 setDexpreoptGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx))
36
Colin Crosse4759b92019-02-15 10:37:39 -080037 return config
38}
39
40func GatherRequiredDepsForTest() string {
41 var bp string
42
43 extraModules := []string{
44 "core-lambda-stubs",
45 "framework",
46 "ext",
47 "android_stubs_current",
48 "android_system_stubs_current",
49 "android_test_stubs_current",
50 "core.current.stubs",
51 "core.platform.api.stubs",
52 "kotlin-stdlib",
53 "kotlin-annotations",
54 }
55
56 for _, extra := range extraModules {
57 bp += fmt.Sprintf(`
58 java_library {
59 name: "%s",
60 srcs: ["a.java"],
61 no_standard_libs: true,
62 sdk_version: "core_current",
63 system_modules: "core-platform-api-stubs-system-modules",
64 }
65 `, extra)
66 }
67
68 bp += `
69 android_app {
70 name: "framework-res",
71 no_framework_libs: true,
72 }
73 `
74
75 systemModules := []string{
76 "core-system-modules",
77 "core-platform-api-stubs-system-modules",
78 "android_stubs_current_system_modules",
79 "android_system_stubs_current_system_modules",
80 "android_test_stubs_current_system_modules",
81 }
82
83 for _, extra := range systemModules {
84 bp += fmt.Sprintf(`
85 java_system_modules {
86 name: "%s",
87 }
88 `, extra)
89 }
90
91 return bp
92}