blob: 1be3768b5dddc51f400f7cb00bb0c86405f27d8e [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"
21)
22
23func 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)
Colin Crosse4759b92019-02-15 10:37:39 -080031
Colin Crosse4759b92019-02-15 10:37:39 -080032 return config
33}
34
35func GatherRequiredDepsForTest() string {
36 var bp string
37
38 extraModules := []string{
39 "core-lambda-stubs",
Colin Crosse4759b92019-02-15 10:37:39 -080040 "ext",
41 "android_stubs_current",
42 "android_system_stubs_current",
43 "android_test_stubs_current",
44 "core.current.stubs",
45 "core.platform.api.stubs",
46 "kotlin-stdlib",
47 "kotlin-annotations",
48 }
49
50 for _, extra := range extraModules {
51 bp += fmt.Sprintf(`
52 java_library {
53 name: "%s",
54 srcs: ["a.java"],
55 no_standard_libs: true,
56 sdk_version: "core_current",
57 system_modules: "core-platform-api-stubs-system-modules",
58 }
59 `, extra)
60 }
61
62 bp += `
Colin Cross3047fa22019-04-18 10:56:44 -070063 java_library {
64 name: "framework",
65 srcs: ["a.java"],
66 no_standard_libs: true,
67 sdk_version: "core_current",
68 system_modules: "core-platform-api-stubs-system-modules",
69 aidl: {
70 export_include_dirs: ["framework/aidl"],
71 },
72 }
73
Colin Crosse4759b92019-02-15 10:37:39 -080074 android_app {
75 name: "framework-res",
76 no_framework_libs: true,
77 }
78 `
79
80 systemModules := []string{
81 "core-system-modules",
82 "core-platform-api-stubs-system-modules",
83 "android_stubs_current_system_modules",
84 "android_system_stubs_current_system_modules",
85 "android_test_stubs_current_system_modules",
86 }
87
88 for _, extra := range systemModules {
89 bp += fmt.Sprintf(`
90 java_system_modules {
91 name: "%s",
92 }
93 `, extra)
94 }
95
96 return bp
97}