blob: 11f3976b14940b46dd9f2893af59e083eadedb3c [file] [log] [blame]
Colin Crossb1974532019-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 Crossb1974532019-02-15 10:37:39 -080031
Colin Crossb1974532019-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 Crossb1974532019-02-15 10:37:39 -080040 "ext",
Colin Crossb1974532019-02-15 10:37:39 -080041 "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",
Colin Cross0b03d972019-05-13 11:06:25 -070047 "kotlin-stdlib-jdk7",
48 "kotlin-stdlib-jdk8",
Colin Crossb1974532019-02-15 10:37:39 -080049 "kotlin-annotations",
50 }
51
52 for _, extra := range extraModules {
53 bp += fmt.Sprintf(`
54 java_library {
55 name: "%s",
56 srcs: ["a.java"],
Paul Duffin52d398a2019-06-11 12:31:14 +010057 sdk_version: "none",
Colin Crossb1974532019-02-15 10:37:39 -080058 system_modules: "core-platform-api-stubs-system-modules",
59 }
60 `, extra)
61 }
62
63 bp += `
Colin Cross3047fa22019-04-18 10:56:44 -070064 java_library {
65 name: "framework",
66 srcs: ["a.java"],
Paul Duffina3d09862019-06-11 13:40:47 +010067 sdk_version: "none",
Colin Cross3047fa22019-04-18 10:56:44 -070068 system_modules: "core-platform-api-stubs-system-modules",
69 aidl: {
70 export_include_dirs: ["framework/aidl"],
71 },
72 }
73
Colin Crossb1974532019-02-15 10:37:39 -080074 android_app {
75 name: "framework-res",
Paul Duffin50c217c2019-06-12 13:25:22 +010076 sdk_version: "core_platform",
Colin Crossb1974532019-02-15 10:37:39 -080077 }
Colin Cross50ddcc42019-05-16 12:28:22 -070078
79 java_library {
80 name: "android.hidl.base-V1.0-java",
81 srcs: ["a.java"],
Paul Duffina3d09862019-06-11 13:40:47 +010082 sdk_version: "none",
Colin Cross50ddcc42019-05-16 12:28:22 -070083 system_modules: "core-platform-api-stubs-system-modules",
84 installable: true,
85 }
86
87 java_library {
88 name: "android.hidl.manager-V1.0-java",
89 srcs: ["a.java"],
Paul Duffina3d09862019-06-11 13:40:47 +010090 sdk_version: "none",
Colin Cross50ddcc42019-05-16 12:28:22 -070091 system_modules: "core-platform-api-stubs-system-modules",
92 installable: true,
93 }
94
95 java_library {
96 name: "org.apache.http.legacy",
97 srcs: ["a.java"],
Paul Duffina3d09862019-06-11 13:40:47 +010098 sdk_version: "none",
Colin Cross50ddcc42019-05-16 12:28:22 -070099 system_modules: "core-platform-api-stubs-system-modules",
100 installable: true,
101 }
Colin Crossb1974532019-02-15 10:37:39 -0800102 `
103
104 systemModules := []string{
Neil Fullerba88c412018-10-21 22:57:26 +0100105 "core-current-stubs-system-modules",
Colin Crossb1974532019-02-15 10:37:39 -0800106 "core-platform-api-stubs-system-modules",
107 "android_stubs_current_system_modules",
108 "android_system_stubs_current_system_modules",
109 "android_test_stubs_current_system_modules",
110 }
111
112 for _, extra := range systemModules {
113 bp += fmt.Sprintf(`
114 java_system_modules {
Paul Duffin68289b02019-09-20 13:50:52 +0100115 name: "%[1]s",
116 libs: ["%[1]s-lib"],
117 }
118 java_library {
119 name: "%[1]s-lib",
120 sdk_version: "none",
121 system_modules: "none",
Colin Crossb1974532019-02-15 10:37:39 -0800122 }
123 `, extra)
124 }
125
126 return bp
127}