Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 1 | // Copyright (C) 2019 The Android Open Source Project |
| 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 sdk |
| 16 | |
| 17 | import ( |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 18 | "fmt" |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 19 | "testing" |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 20 | |
Paul Duffin | 4a2a29c | 2021-03-09 22:27:13 +0000 | [diff] [blame] | 21 | "android/soong/android" |
Jiakai Zhang | bc698cd | 2023-05-08 16:28:38 +0000 | [diff] [blame] | 22 | "android/soong/dexpreopt" |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 23 | "android/soong/java" |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 24 | ) |
| 25 | |
Paul Duffin | d14cbc1 | 2021-03-18 09:14:23 +0000 | [diff] [blame] | 26 | var prepareForSdkTestWithJava = android.GroupFixturePreparers( |
| 27 | java.PrepareForTestWithJavaBuildComponents, |
| 28 | PrepareForTestWithSdkBuildComponents, |
Jiakai Zhang | bc698cd | 2023-05-08 16:28:38 +0000 | [diff] [blame] | 29 | dexpreopt.PrepareForTestWithFakeDex2oatd, |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 30 | |
| 31 | // Ensure that all source paths are provided. This helps ensure that the snapshot generation is |
| 32 | // consistent and all files referenced from the snapshot's Android.bp file have actually been |
| 33 | // copied into the snapshot. |
| 34 | android.PrepareForTestDisallowNonExistentPaths, |
| 35 | |
| 36 | // Files needs by most of the tests. |
| 37 | android.MockFS{ |
Jiakai Zhang | 9c4dc19 | 2023-02-09 00:09:24 +0800 | [diff] [blame] | 38 | "Test.java": nil, |
| 39 | "art-profile": nil, |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 40 | }.AddToFixture(), |
Paul Duffin | d14cbc1 | 2021-03-18 09:14:23 +0000 | [diff] [blame] | 41 | ) |
| 42 | |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 43 | var prepareForSdkTestWithJavaSdkLibrary = android.GroupFixturePreparers( |
| 44 | prepareForSdkTestWithJava, |
| 45 | java.PrepareForTestWithJavaDefaultModules, |
| 46 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 47 | java.FixtureWithLastReleaseApis("myjavalib"), |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 48 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 49 | variables.BuildFlags = map[string]string{ |
| 50 | "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", |
| 51 | } |
| 52 | }), |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 53 | ) |
| 54 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 55 | // Contains tests for SDK members provided by the java package. |
| 56 | |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 57 | func TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 58 | result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 59 | sdk { |
| 60 | name: "mysdk", |
| 61 | java_header_libs: ["sdkmember"], |
| 62 | } |
| 63 | |
| 64 | java_library { |
| 65 | name: "sdkmember", |
| 66 | srcs: ["Test.java"], |
| 67 | system_modules: "none", |
| 68 | sdk_version: "none", |
| 69 | } |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 70 | `) |
| 71 | |
| 72 | // Make sure that the mysdk module depends on "sdkmember" and not "prebuilt_sdkmember". |
Paul Duffin | 1822a0a | 2021-03-21 12:56:33 +0000 | [diff] [blame] | 73 | sdkChecker := func(t *testing.T, result *android.TestResult) { |
| 74 | java.CheckModuleDependencies(t, result.TestContext, "mysdk", "android_common", []string{"sdkmember"}) |
| 75 | } |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 76 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 77 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | 1822a0a | 2021-03-21 12:56:33 +0000 | [diff] [blame] | 78 | snapshotTestChecker(checkSnapshotWithSourcePreferred, sdkChecker), |
| 79 | snapshotTestChecker(checkSnapshotPreferredWithSource, sdkChecker), |
| 80 | ) |
Paul Duffin | cee7e66 | 2020-07-09 17:32:57 +0100 | [diff] [blame] | 81 | } |
| 82 | |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 83 | func TestSnapshotWithJavaHeaderLibrary(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 84 | result := android.GroupFixturePreparers( |
| 85 | prepareForSdkTestWithJava, |
| 86 | android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil), |
| 87 | ).RunTestWithBp(t, ` |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 88 | sdk { |
| 89 | name: "mysdk", |
| 90 | java_header_libs: ["myjavalib"], |
| 91 | } |
| 92 | |
| 93 | java_library { |
| 94 | name: "myjavalib", |
| 95 | srcs: ["Test.java"], |
| 96 | aidl: { |
| 97 | export_include_dirs: ["aidl"], |
| 98 | }, |
| 99 | system_modules: "none", |
| 100 | sdk_version: "none", |
| 101 | compile_dex: true, |
| 102 | host_supported: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 103 | permitted_packages: ["pkg.myjavalib"], |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 104 | } |
| 105 | `) |
| 106 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 107 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 108 | checkAndroidBpContents(` |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 109 | // This is auto-generated. DO NOT EDIT. |
| 110 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 111 | apex_contributions_defaults { |
| 112 | name: "mysdk.contributions", |
| 113 | contents: ["prebuilt_myjavalib"], |
| 114 | } |
| 115 | |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 116 | java_import { |
| 117 | name: "myjavalib", |
| 118 | prefer: false, |
| 119 | visibility: ["//visibility:public"], |
| 120 | apex_available: ["//apex_available:platform"], |
| 121 | jars: ["java/myjavalib.jar"], |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 122 | permitted_packages: ["pkg.myjavalib"], |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 123 | } |
| 124 | `), |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 125 | checkAllCopyRules(` |
| 126 | .intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar |
| 127 | aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl |
| 128 | `), |
| 129 | ) |
| 130 | } |
| 131 | |
| 132 | func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 133 | result := android.GroupFixturePreparers( |
| 134 | prepareForSdkTestWithJava, |
| 135 | android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil), |
| 136 | ).RunTestWithBp(t, ` |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 137 | sdk { |
| 138 | name: "mysdk", |
| 139 | device_supported: false, |
| 140 | host_supported: true, |
| 141 | java_header_libs: ["myjavalib"], |
| 142 | } |
| 143 | |
| 144 | java_library { |
| 145 | name: "myjavalib", |
| 146 | device_supported: false, |
| 147 | host_supported: true, |
| 148 | srcs: ["Test.java"], |
| 149 | aidl: { |
| 150 | export_include_dirs: ["aidl"], |
| 151 | }, |
| 152 | system_modules: "none", |
| 153 | sdk_version: "none", |
| 154 | compile_dex: true, |
| 155 | } |
| 156 | `) |
| 157 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 158 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 159 | checkAndroidBpContents(` |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 160 | // This is auto-generated. DO NOT EDIT. |
| 161 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 162 | apex_contributions_defaults { |
| 163 | name: "mysdk.contributions", |
| 164 | contents: ["prebuilt_myjavalib"], |
| 165 | } |
| 166 | |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 167 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 168 | name: "myjavalib", |
| 169 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 170 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 171 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 172 | device_supported: false, |
| 173 | host_supported: true, |
| 174 | jars: ["java/myjavalib.jar"], |
| 175 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 176 | `), |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 177 | checkAllCopyRules(` |
Colin Cross | f06d8dc | 2023-07-18 22:11:07 -0700 | [diff] [blame] | 178 | .intermediates/myjavalib/linux_glibc_common/javac-header/myjavalib.jar -> java/myjavalib.jar |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 179 | aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl |
| 180 | `), |
| 181 | ) |
| 182 | } |
| 183 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 184 | func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 185 | result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 186 | sdk { |
| 187 | name: "mysdk", |
| 188 | host_supported: true, |
| 189 | java_header_libs: ["myjavalib"], |
| 190 | } |
| 191 | |
| 192 | java_library { |
| 193 | name: "myjavalib", |
| 194 | host_supported: true, |
| 195 | srcs: ["Test.java"], |
| 196 | system_modules: "none", |
| 197 | sdk_version: "none", |
| 198 | compile_dex: true, |
| 199 | } |
| 200 | `) |
| 201 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 202 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 203 | checkAndroidBpContents(` |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 204 | // This is auto-generated. DO NOT EDIT. |
| 205 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 206 | apex_contributions_defaults { |
| 207 | name: "mysdk.contributions", |
| 208 | contents: ["prebuilt_myjavalib"], |
| 209 | } |
| 210 | |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 211 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 212 | name: "myjavalib", |
| 213 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 214 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 215 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 216 | host_supported: true, |
| 217 | target: { |
| 218 | android: { |
| 219 | jars: ["java/android/myjavalib.jar"], |
| 220 | }, |
| 221 | linux_glibc: { |
| 222 | jars: ["java/linux_glibc/myjavalib.jar"], |
| 223 | }, |
| 224 | }, |
| 225 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 226 | `), |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 227 | checkAllCopyRules(` |
| 228 | .intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/android/myjavalib.jar |
Colin Cross | f06d8dc | 2023-07-18 22:11:07 -0700 | [diff] [blame] | 229 | .intermediates/myjavalib/linux_glibc_common/javac-header/myjavalib.jar -> java/linux_glibc/myjavalib.jar |
Paul Duffin | a04c107 | 2020-03-02 10:16:35 +0000 | [diff] [blame] | 230 | `), |
| 231 | ) |
| 232 | } |
| 233 | |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 234 | func TestSnapshotWithJavaImplLibrary(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 235 | result := android.GroupFixturePreparers( |
| 236 | prepareForSdkTestWithJava, |
| 237 | android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil), |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 238 | android.FixtureAddFile("resource.txt", nil), |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 239 | ).RunTestWithBp(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 240 | module_exports { |
| 241 | name: "myexports", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 242 | java_libs: ["myjavalib"], |
| 243 | } |
| 244 | |
| 245 | java_library { |
| 246 | name: "myjavalib", |
| 247 | srcs: ["Test.java"], |
Paul Duffin | 4e77284 | 2020-06-24 12:10:42 +0100 | [diff] [blame] | 248 | java_resources: ["resource.txt"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 249 | aidl: { |
| 250 | export_include_dirs: ["aidl"], |
| 251 | }, |
| 252 | system_modules: "none", |
| 253 | sdk_version: "none", |
| 254 | compile_dex: true, |
| 255 | host_supported: true, |
| 256 | } |
| 257 | `) |
| 258 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 259 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 260 | checkAndroidBpContents(` |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 261 | // This is auto-generated. DO NOT EDIT. |
| 262 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 263 | apex_contributions_defaults { |
| 264 | name: "myexports.contributions", |
| 265 | contents: ["prebuilt_myjavalib"], |
| 266 | } |
| 267 | |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 268 | java_import { |
| 269 | name: "myjavalib", |
| 270 | prefer: false, |
| 271 | visibility: ["//visibility:public"], |
| 272 | apex_available: ["//apex_available:platform"], |
| 273 | jars: ["java/myjavalib.jar"], |
| 274 | } |
| 275 | `), |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 276 | checkAllCopyRules(` |
Paul Duffin | 4e77284 | 2020-06-24 12:10:42 +0100 | [diff] [blame] | 277 | .intermediates/myjavalib/android_common/withres/myjavalib.jar -> java/myjavalib.jar |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 278 | aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl |
| 279 | `), |
| 280 | ) |
| 281 | } |
| 282 | |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 283 | func TestSnapshotWithJavaBootLibrary(t *testing.T) { |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 284 | result := android.GroupFixturePreparers( |
| 285 | prepareForSdkTestWithJava, |
| 286 | android.FixtureAddFile("aidl", nil), |
| 287 | android.FixtureAddFile("resource.txt", nil), |
| 288 | ).RunTestWithBp(t, ` |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 289 | sdk { |
| 290 | name: "mysdk", |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 291 | java_boot_libs: ["myjavalib"], |
| 292 | } |
| 293 | |
| 294 | java_library { |
| 295 | name: "myjavalib", |
| 296 | srcs: ["Test.java"], |
| 297 | java_resources: ["resource.txt"], |
| 298 | // The aidl files should not be copied to the snapshot because a java_boot_libs member is not |
| 299 | // intended to be used for compiling Java, only for accessing the dex implementation jar. |
| 300 | aidl: { |
| 301 | export_include_dirs: ["aidl"], |
| 302 | }, |
| 303 | system_modules: "none", |
| 304 | sdk_version: "none", |
| 305 | compile_dex: true, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 306 | permitted_packages: ["pkg.myjavalib"], |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 307 | } |
| 308 | `) |
| 309 | |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 310 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 311 | checkAndroidBpContents(` |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 312 | // This is auto-generated. DO NOT EDIT. |
| 313 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 314 | apex_contributions_defaults { |
| 315 | name: "mysdk.contributions", |
| 316 | contents: [], |
| 317 | } |
| 318 | |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 319 | java_import { |
| 320 | name: "myjavalib", |
| 321 | prefer: false, |
| 322 | visibility: ["//visibility:public"], |
| 323 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 324 | jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"], |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 325 | permitted_packages: ["pkg.myjavalib"], |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 326 | } |
| 327 | `), |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 328 | checkAllCopyRules(` |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 329 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar |
Paul Duffin | db170e4 | 2020-12-08 17:48:25 +0000 | [diff] [blame] | 330 | `), |
| 331 | ) |
| 332 | } |
| 333 | |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 334 | func TestSnapshotWithJavaBootLibrary_UpdatableMedia(t *testing.T) { |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 335 | runTest := func(t *testing.T, targetBuildRelease, expectedJarPath, expectedCopyRule string) { |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 336 | result := android.GroupFixturePreparers( |
| 337 | prepareForSdkTestWithJava, |
| 338 | android.FixtureMergeEnv(map[string]string{ |
| 339 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease, |
| 340 | }), |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 341 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 342 | variables.Platform_version_active_codenames = []string{"VanillaIceCream"} |
| 343 | }), |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 344 | ).RunTestWithBp(t, ` |
| 345 | sdk { |
| 346 | name: "mysdk", |
| 347 | java_boot_libs: ["updatable-media"], |
| 348 | } |
| 349 | |
| 350 | java_library { |
| 351 | name: "updatable-media", |
| 352 | srcs: ["Test.java"], |
| 353 | system_modules: "none", |
| 354 | sdk_version: "none", |
| 355 | compile_dex: true, |
| 356 | permitted_packages: ["pkg.media"], |
| 357 | apex_available: ["com.android.media"], |
| 358 | } |
| 359 | `) |
| 360 | |
| 361 | CheckSnapshot(t, result, "mysdk", "", |
| 362 | checkAndroidBpContents(fmt.Sprintf(` |
| 363 | // This is auto-generated. DO NOT EDIT. |
| 364 | |
| 365 | java_import { |
| 366 | name: "updatable-media", |
| 367 | prefer: false, |
| 368 | visibility: ["//visibility:public"], |
| 369 | apex_available: ["com.android.media"], |
| 370 | jars: ["%s"], |
| 371 | permitted_packages: ["pkg.media"], |
| 372 | } |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 373 | `, expectedJarPath)), |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 374 | checkAllCopyRules(expectedCopyRule), |
| 375 | ) |
| 376 | } |
| 377 | |
| 378 | t.Run("updatable-media in S", func(t *testing.T) { |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 379 | runTest(t, "S", "java/updatable-media.jar", ` |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 380 | .intermediates/updatable-media/android_common/package-check/updatable-media.jar -> java/updatable-media.jar |
| 381 | `) |
| 382 | }) |
| 383 | |
| 384 | t.Run("updatable-media in T", func(t *testing.T) { |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 385 | runTest(t, "Tiramisu", "java_boot_libs/snapshot/jars/are/invalid/updatable-media.jar", ` |
| 386 | .intermediates/mysdk/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/updatable-media.jar |
Paul Duffin | 1364891 | 2022-07-15 13:12:35 +0000 | [diff] [blame] | 387 | `) |
| 388 | }) |
| 389 | } |
| 390 | |
Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame] | 391 | func TestSnapshotWithJavaLibrary_MinSdkVersion(t *testing.T) { |
| 392 | runTest := func(t *testing.T, targetBuildRelease, minSdkVersion, expectedMinSdkVersion string) { |
| 393 | result := android.GroupFixturePreparers( |
| 394 | prepareForSdkTestWithJava, |
| 395 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 396 | variables.Platform_version_active_codenames = []string{"S", "Tiramisu", "Unfinalized"} |
| 397 | }), |
| 398 | android.FixtureMergeEnv(map[string]string{ |
| 399 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": targetBuildRelease, |
| 400 | }), |
| 401 | ).RunTestWithBp(t, fmt.Sprintf(` |
| 402 | sdk { |
| 403 | name: "mysdk", |
| 404 | java_header_libs: ["mylib"], |
| 405 | } |
| 406 | |
| 407 | java_library { |
| 408 | name: "mylib", |
| 409 | srcs: ["Test.java"], |
| 410 | system_modules: "none", |
| 411 | sdk_version: "none", |
| 412 | compile_dex: true, |
| 413 | min_sdk_version: "%s", |
| 414 | } |
| 415 | `, minSdkVersion)) |
| 416 | |
| 417 | expectedMinSdkVersionLine := "" |
| 418 | if expectedMinSdkVersion != "" { |
| 419 | expectedMinSdkVersionLine = fmt.Sprintf(" min_sdk_version: %q,\n", expectedMinSdkVersion) |
| 420 | } |
| 421 | |
| 422 | CheckSnapshot(t, result, "mysdk", "", |
| 423 | checkAndroidBpContents(fmt.Sprintf(` |
| 424 | // This is auto-generated. DO NOT EDIT. |
| 425 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 426 | apex_contributions_defaults { |
| 427 | name: "mysdk.contributions", |
| 428 | contents: ["prebuilt_mylib"], |
| 429 | } |
| 430 | |
Paul Duffin | bb638eb | 2022-11-26 13:36:38 +0000 | [diff] [blame] | 431 | java_import { |
| 432 | name: "mylib", |
| 433 | prefer: false, |
| 434 | visibility: ["//visibility:public"], |
| 435 | apex_available: ["//apex_available:platform"], |
| 436 | jars: ["java/mylib.jar"], |
| 437 | %s} |
| 438 | `, expectedMinSdkVersionLine)), |
| 439 | ) |
| 440 | } |
| 441 | |
| 442 | t.Run("min_sdk_version=S in S", func(t *testing.T) { |
| 443 | // min_sdk_version was not added to java_import until Tiramisu. |
| 444 | runTest(t, "S", "S", "") |
| 445 | }) |
| 446 | |
| 447 | t.Run("min_sdk_version=S in Tiramisu", func(t *testing.T) { |
| 448 | // The canonical form of S is 31. |
| 449 | runTest(t, "Tiramisu", "S", "31") |
| 450 | }) |
| 451 | |
| 452 | t.Run("min_sdk_version=24 in Tiramisu", func(t *testing.T) { |
| 453 | // A numerical min_sdk_version is already in canonical form. |
| 454 | runTest(t, "Tiramisu", "24", "24") |
| 455 | }) |
| 456 | |
| 457 | t.Run("min_sdk_version=Unfinalized in latest", func(t *testing.T) { |
| 458 | // An unfinalized min_sdk_version has no numeric value yet. |
| 459 | runTest(t, "", "Unfinalized", "Unfinalized") |
| 460 | }) |
| 461 | } |
| 462 | |
Jiakai Zhang | ea18033 | 2021-09-26 08:58:02 +0000 | [diff] [blame] | 463 | func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) { |
| 464 | result := android.GroupFixturePreparers( |
| 465 | prepareForSdkTestWithJava, |
| 466 | android.FixtureAddFile("aidl", nil), |
| 467 | android.FixtureAddFile("resource.txt", nil), |
| 468 | ).RunTestWithBp(t, ` |
| 469 | module_exports { |
| 470 | name: "myexports", |
| 471 | java_systemserver_libs: ["myjavalib"], |
| 472 | } |
| 473 | |
| 474 | java_library { |
| 475 | name: "myjavalib", |
| 476 | srcs: ["Test.java"], |
| 477 | java_resources: ["resource.txt"], |
| 478 | // The aidl files should not be copied to the snapshot because a java_systemserver_libs member |
| 479 | // is not intended to be used for compiling Java, only for accessing the dex implementation |
| 480 | // jar. |
| 481 | aidl: { |
| 482 | export_include_dirs: ["aidl"], |
| 483 | }, |
| 484 | system_modules: "none", |
| 485 | sdk_version: "none", |
| 486 | compile_dex: true, |
| 487 | permitted_packages: ["pkg.myjavalib"], |
| 488 | } |
| 489 | `) |
| 490 | |
| 491 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 492 | checkAndroidBpContents(` |
Jiakai Zhang | ea18033 | 2021-09-26 08:58:02 +0000 | [diff] [blame] | 493 | // This is auto-generated. DO NOT EDIT. |
| 494 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 495 | apex_contributions_defaults { |
| 496 | name: "myexports.contributions", |
| 497 | contents: [], |
| 498 | } |
| 499 | |
Jiakai Zhang | ea18033 | 2021-09-26 08:58:02 +0000 | [diff] [blame] | 500 | java_import { |
| 501 | name: "myjavalib", |
| 502 | prefer: false, |
| 503 | visibility: ["//visibility:public"], |
| 504 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 505 | jars: ["java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar"], |
Jiakai Zhang | ea18033 | 2021-09-26 08:58:02 +0000 | [diff] [blame] | 506 | permitted_packages: ["pkg.myjavalib"], |
| 507 | } |
| 508 | `), |
Jiakai Zhang | ea18033 | 2021-09-26 08:58:02 +0000 | [diff] [blame] | 509 | checkAllCopyRules(` |
Paul Duffin | 7ed6ff8 | 2022-11-21 10:57:30 +0000 | [diff] [blame] | 510 | .intermediates/myexports/common_os/empty -> java_systemserver_libs/snapshot/jars/are/invalid/myjavalib.jar |
Jiakai Zhang | ea18033 | 2021-09-26 08:58:02 +0000 | [diff] [blame] | 511 | `), |
| 512 | ) |
| 513 | } |
| 514 | |
Paul Duffin | a0dbf43 | 2019-12-05 11:25:53 +0000 | [diff] [blame] | 515 | func TestHostSnapshotWithJavaImplLibrary(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 516 | result := android.GroupFixturePreparers( |
| 517 | prepareForSdkTestWithJava, |
| 518 | android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil), |
| 519 | ).RunTestWithBp(t, ` |
Paul Duffin | e602918 | 2019-12-16 17:43:48 +0000 | [diff] [blame] | 520 | module_exports { |
| 521 | name: "myexports", |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 522 | device_supported: false, |
| 523 | host_supported: true, |
| 524 | java_libs: ["myjavalib"], |
| 525 | } |
| 526 | |
| 527 | java_library { |
| 528 | name: "myjavalib", |
| 529 | device_supported: false, |
| 530 | host_supported: true, |
| 531 | srcs: ["Test.java"], |
| 532 | aidl: { |
| 533 | export_include_dirs: ["aidl"], |
| 534 | }, |
| 535 | system_modules: "none", |
| 536 | sdk_version: "none", |
| 537 | compile_dex: true, |
| 538 | } |
| 539 | `) |
| 540 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 541 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 542 | checkAndroidBpContents(` |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 543 | // This is auto-generated. DO NOT EDIT. |
| 544 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 545 | apex_contributions_defaults { |
| 546 | name: "myexports.contributions", |
| 547 | contents: ["prebuilt_myjavalib"], |
| 548 | } |
| 549 | |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 550 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 551 | name: "myjavalib", |
| 552 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 553 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 554 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 555 | device_supported: false, |
| 556 | host_supported: true, |
| 557 | jars: ["java/myjavalib.jar"], |
| 558 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 559 | `), |
Paul Duffin | a80fdec | 2019-12-03 15:25:00 +0000 | [diff] [blame] | 560 | checkAllCopyRules(` |
| 561 | .intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/myjavalib.jar |
| 562 | aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl |
| 563 | `), |
| 564 | ) |
| 565 | } |
| 566 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 567 | func TestSnapshotWithJavaTest(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 568 | result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 569 | module_exports { |
| 570 | name: "myexports", |
| 571 | java_tests: ["myjavatests"], |
| 572 | } |
| 573 | |
| 574 | java_test { |
| 575 | name: "myjavatests", |
| 576 | srcs: ["Test.java"], |
| 577 | system_modules: "none", |
| 578 | sdk_version: "none", |
| 579 | compile_dex: true, |
| 580 | host_supported: true, |
| 581 | } |
| 582 | `) |
| 583 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 584 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 585 | checkAndroidBpContents(` |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 586 | // This is auto-generated. DO NOT EDIT. |
| 587 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 588 | apex_contributions_defaults { |
| 589 | name: "myexports.contributions", |
| 590 | contents: ["prebuilt_myjavatests"], |
| 591 | } |
| 592 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 593 | java_test_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 594 | name: "myjavatests", |
| 595 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 596 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 597 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 598 | jars: ["java/myjavatests.jar"], |
| 599 | test_config: "java/myjavatests-AndroidTest.xml", |
| 600 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 601 | `), |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 602 | checkAllCopyRules(` |
| 603 | .intermediates/myjavatests/android_common/javac/myjavatests.jar -> java/myjavatests.jar |
| 604 | .intermediates/myjavatests/android_common/myjavatests.config -> java/myjavatests-AndroidTest.xml |
| 605 | `), |
| 606 | ) |
| 607 | } |
| 608 | |
| 609 | func TestHostSnapshotWithJavaTest(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 610 | result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 611 | module_exports { |
| 612 | name: "myexports", |
| 613 | device_supported: false, |
| 614 | host_supported: true, |
| 615 | java_tests: ["myjavatests"], |
| 616 | } |
| 617 | |
| 618 | java_test { |
| 619 | name: "myjavatests", |
| 620 | device_supported: false, |
| 621 | host_supported: true, |
| 622 | srcs: ["Test.java"], |
| 623 | system_modules: "none", |
| 624 | sdk_version: "none", |
| 625 | compile_dex: true, |
| 626 | } |
| 627 | `) |
| 628 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 629 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 630 | checkAndroidBpContents(` |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 631 | // This is auto-generated. DO NOT EDIT. |
| 632 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 633 | apex_contributions_defaults { |
| 634 | name: "myexports.contributions", |
| 635 | contents: ["prebuilt_myjavatests"], |
| 636 | } |
| 637 | |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 638 | java_test_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 639 | name: "myjavatests", |
| 640 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 641 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 642 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 643 | device_supported: false, |
| 644 | host_supported: true, |
| 645 | jars: ["java/myjavatests.jar"], |
| 646 | test_config: "java/myjavatests-AndroidTest.xml", |
| 647 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 648 | `), |
Paul Duffin | 1b82e6a | 2019-12-03 18:06:47 +0000 | [diff] [blame] | 649 | checkAllCopyRules(` |
| 650 | .intermediates/myjavatests/linux_glibc_common/javac/myjavatests.jar -> java/myjavatests.jar |
| 651 | .intermediates/myjavatests/linux_glibc_common/myjavatests.config -> java/myjavatests-AndroidTest.xml |
| 652 | `), |
| 653 | ) |
| 654 | } |
| 655 | |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 656 | func TestSnapshotWithJavaSystemModules(t *testing.T) { |
Paul Duffin | 958806b | 2022-05-16 13:10:47 +0000 | [diff] [blame] | 657 | result := android.GroupFixturePreparers( |
| 658 | prepareForSdkTestWithJava, |
| 659 | java.PrepareForTestWithJavaDefaultModules, |
| 660 | java.PrepareForTestWithJavaSdkLibraryFiles, |
| 661 | java.FixtureWithPrebuiltApisAndExtensions(map[string][]string{ |
| 662 | "31": {"myjavalib"}, |
| 663 | "32": {"myjavalib"}, |
| 664 | "current": {"myjavalib"}, |
| 665 | }, map[string][]string{ |
| 666 | "1": {"myjavalib"}, |
| 667 | "2": {"myjavalib"}, |
| 668 | }), |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 669 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 670 | variables.BuildFlags = map[string]string{ |
| 671 | "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", |
| 672 | } |
| 673 | }), |
Paul Duffin | 958806b | 2022-05-16 13:10:47 +0000 | [diff] [blame] | 674 | ).RunTestWithBp(t, ` |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 675 | sdk { |
| 676 | name: "mysdk", |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 677 | java_header_libs: ["exported-system-module"], |
Paul Duffin | 3302871 | 2021-06-22 11:00:07 +0100 | [diff] [blame] | 678 | java_sdk_libs: ["myjavalib"], |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 679 | java_system_modules: ["my-system-modules"], |
| 680 | } |
| 681 | |
Paul Duffin | 3302871 | 2021-06-22 11:00:07 +0100 | [diff] [blame] | 682 | java_sdk_library { |
| 683 | name: "myjavalib", |
| 684 | apex_available: ["//apex_available:anyapex"], |
| 685 | srcs: ["Test.java"], |
| 686 | sdk_version: "current", |
| 687 | shared_library: false, |
| 688 | public: { |
| 689 | enabled: true, |
| 690 | }, |
| 691 | } |
| 692 | |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 693 | java_system_modules { |
| 694 | name: "my-system-modules", |
Paul Duffin | 3302871 | 2021-06-22 11:00:07 +0100 | [diff] [blame] | 695 | libs: ["system-module", "exported-system-module", "myjavalib.stubs"], |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | java_library { |
| 699 | name: "system-module", |
| 700 | srcs: ["Test.java"], |
| 701 | sdk_version: "none", |
| 702 | system_modules: "none", |
| 703 | } |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 704 | |
| 705 | java_library { |
| 706 | name: "exported-system-module", |
| 707 | srcs: ["Test.java"], |
| 708 | sdk_version: "none", |
| 709 | system_modules: "none", |
| 710 | } |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 711 | `) |
| 712 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 713 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 714 | checkAndroidBpContents(` |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 715 | // This is auto-generated. DO NOT EDIT. |
| 716 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 717 | apex_contributions_defaults { |
| 718 | name: "mysdk.contributions", |
| 719 | contents: [ |
| 720 | "prebuilt_exported-system-module", |
| 721 | "prebuilt_myjavalib", |
| 722 | "prebuilt_my-system-modules", |
| 723 | ], |
| 724 | } |
| 725 | |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 726 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 727 | name: "exported-system-module", |
| 728 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 729 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 730 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 731 | jars: ["java/exported-system-module.jar"], |
| 732 | } |
| 733 | |
| 734 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 735 | name: "mysdk_system-module", |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 736 | prefer: false, |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 737 | visibility: ["//visibility:private"], |
| 738 | apex_available: ["//apex_available:platform"], |
| 739 | jars: ["java/system-module.jar"], |
| 740 | } |
| 741 | |
Paul Duffin | 3302871 | 2021-06-22 11:00:07 +0100 | [diff] [blame] | 742 | java_sdk_library_import { |
| 743 | name: "myjavalib", |
| 744 | prefer: false, |
| 745 | visibility: ["//visibility:public"], |
| 746 | apex_available: ["//apex_available:anyapex"], |
| 747 | shared_library: false, |
| 748 | public: { |
| 749 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 750 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
| 751 | current_api: "sdk_library/public/myjavalib.txt", |
| 752 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 753 | sdk_version: "current", |
| 754 | }, |
| 755 | } |
| 756 | |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 757 | java_system_modules_import { |
| 758 | name: "my-system-modules", |
| 759 | prefer: false, |
| 760 | visibility: ["//visibility:public"], |
| 761 | libs: [ |
| 762 | "mysdk_system-module", |
| 763 | "exported-system-module", |
Paul Duffin | b97b157 | 2021-04-29 21:50:40 +0100 | [diff] [blame] | 764 | "myjavalib.stubs", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 765 | ], |
| 766 | } |
| 767 | `), |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 768 | checkAllCopyRules(` |
| 769 | .intermediates/exported-system-module/android_common/turbine-combined/exported-system-module.jar -> java/exported-system-module.jar |
| 770 | .intermediates/system-module/android_common/turbine-combined/system-module.jar -> java/system-module.jar |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 771 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 772 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 773 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 774 | `), |
Paul Duffin | 958806b | 2022-05-16 13:10:47 +0000 | [diff] [blame] | 775 | checkInfoContents(result.Config, ` |
Paul Duffin | c6ba182 | 2022-05-06 09:38:02 +0000 | [diff] [blame] | 776 | [ |
| 777 | { |
| 778 | "@type": "sdk", |
| 779 | "@name": "mysdk", |
| 780 | "java_header_libs": [ |
| 781 | "exported-system-module", |
| 782 | "system-module" |
| 783 | ], |
| 784 | "java_sdk_libs": [ |
| 785 | "myjavalib" |
| 786 | ], |
| 787 | "java_system_modules": [ |
| 788 | "my-system-modules" |
| 789 | ] |
| 790 | }, |
| 791 | { |
| 792 | "@type": "java_library", |
| 793 | "@name": "exported-system-module" |
| 794 | }, |
| 795 | { |
| 796 | "@type": "java_system_modules", |
| 797 | "@name": "my-system-modules", |
| 798 | "@deps": [ |
| 799 | "exported-system-module", |
| 800 | "system-module" |
| 801 | ] |
| 802 | }, |
| 803 | { |
| 804 | "@type": "java_sdk_library", |
Paul Duffin | 958806b | 2022-05-16 13:10:47 +0000 | [diff] [blame] | 805 | "@name": "myjavalib", |
| 806 | "dist_stem": "myjavalib", |
| 807 | "scopes": { |
| 808 | "public": { |
| 809 | "current_api": "sdk_library/public/myjavalib.txt", |
| 810 | "latest_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib.api.public.latest/gen/myjavalib.api.public.latest", |
| 811 | "latest_removed_api": "out/soong/.intermediates/prebuilts/sdk/myjavalib-removed.api.public.latest/gen/myjavalib-removed.api.public.latest", |
| 812 | "removed_api": "sdk_library/public/myjavalib-removed.txt" |
| 813 | } |
| 814 | } |
Paul Duffin | c6ba182 | 2022-05-06 09:38:02 +0000 | [diff] [blame] | 815 | }, |
| 816 | { |
| 817 | "@type": "java_library", |
| 818 | "@name": "system-module" |
| 819 | } |
| 820 | ] |
| 821 | `), |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 822 | ) |
| 823 | } |
| 824 | |
| 825 | func TestHostSnapshotWithJavaSystemModules(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 826 | result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 827 | sdk { |
| 828 | name: "mysdk", |
| 829 | device_supported: false, |
| 830 | host_supported: true, |
| 831 | java_system_modules: ["my-system-modules"], |
| 832 | } |
| 833 | |
| 834 | java_system_modules { |
| 835 | name: "my-system-modules", |
| 836 | device_supported: false, |
| 837 | host_supported: true, |
| 838 | libs: ["system-module"], |
| 839 | } |
| 840 | |
| 841 | java_library { |
| 842 | name: "system-module", |
| 843 | device_supported: false, |
| 844 | host_supported: true, |
| 845 | srcs: ["Test.java"], |
| 846 | sdk_version: "none", |
| 847 | system_modules: "none", |
| 848 | } |
| 849 | `) |
| 850 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 851 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 852 | checkAndroidBpContents(` |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 853 | // This is auto-generated. DO NOT EDIT. |
| 854 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 855 | apex_contributions_defaults { |
| 856 | name: "mysdk.contributions", |
| 857 | contents: ["prebuilt_my-system-modules"], |
| 858 | } |
| 859 | |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 860 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 861 | name: "mysdk_system-module", |
| 862 | prefer: false, |
Paul Duffin | 7291095 | 2020-01-20 18:16:30 +0000 | [diff] [blame] | 863 | visibility: ["//visibility:private"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 864 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 865 | device_supported: false, |
| 866 | host_supported: true, |
| 867 | jars: ["java/system-module.jar"], |
| 868 | } |
| 869 | |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 870 | java_system_modules_import { |
| 871 | name: "my-system-modules", |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 872 | prefer: false, |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 873 | visibility: ["//visibility:public"], |
| 874 | device_supported: false, |
| 875 | host_supported: true, |
| 876 | libs: ["mysdk_system-module"], |
| 877 | } |
| 878 | `), |
Colin Cross | f06d8dc | 2023-07-18 22:11:07 -0700 | [diff] [blame] | 879 | checkAllCopyRules(".intermediates/system-module/linux_glibc_common/javac-header/system-module.jar -> java/system-module.jar"), |
Paul Duffin | 7b81f5e | 2020-01-13 21:03:22 +0000 | [diff] [blame] | 880 | ) |
| 881 | } |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 882 | |
| 883 | func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 884 | result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, ` |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 885 | module_exports { |
| 886 | name: "myexports", |
| 887 | host_supported: true, |
| 888 | java_libs: ["myjavalib"], |
| 889 | target: { |
| 890 | android: { |
| 891 | java_header_libs: ["androidjavalib"], |
| 892 | }, |
| 893 | host: { |
| 894 | java_header_libs: ["hostjavalib"], |
| 895 | }, |
| 896 | }, |
| 897 | } |
| 898 | |
| 899 | java_library { |
| 900 | name: "myjavalib", |
| 901 | host_supported: true, |
| 902 | srcs: ["Test.java"], |
| 903 | system_modules: "none", |
| 904 | sdk_version: "none", |
| 905 | } |
| 906 | |
| 907 | java_library { |
| 908 | name: "androidjavalib", |
| 909 | srcs: ["Test.java"], |
| 910 | system_modules: "none", |
| 911 | sdk_version: "none", |
| 912 | } |
| 913 | |
| 914 | java_library_host { |
| 915 | name: "hostjavalib", |
| 916 | srcs: ["Test.java"], |
| 917 | } |
| 918 | `) |
| 919 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 920 | CheckSnapshot(t, result, "myexports", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 921 | checkAndroidBpContents(` |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 922 | // This is auto-generated. DO NOT EDIT. |
| 923 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 924 | apex_contributions_defaults { |
| 925 | name: "myexports.contributions", |
| 926 | contents: [ |
| 927 | "prebuilt_hostjavalib", |
| 928 | "prebuilt_androidjavalib", |
| 929 | "prebuilt_myjavalib", |
| 930 | ], |
| 931 | } |
| 932 | |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 933 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 934 | name: "hostjavalib", |
| 935 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 936 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 937 | apex_available: ["//apex_available:platform"], |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 938 | device_supported: false, |
| 939 | host_supported: true, |
| 940 | jars: ["java/hostjavalib.jar"], |
| 941 | } |
| 942 | |
| 943 | java_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 944 | name: "androidjavalib", |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 945 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 946 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 947 | apex_available: ["//apex_available:platform"], |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 948 | jars: ["java/androidjavalib.jar"], |
| 949 | } |
| 950 | |
| 951 | java_import { |
| 952 | name: "myjavalib", |
| 953 | prefer: false, |
| 954 | visibility: ["//visibility:public"], |
| 955 | apex_available: ["//apex_available:platform"], |
| 956 | host_supported: true, |
| 957 | target: { |
| 958 | android: { |
| 959 | jars: ["java/android/myjavalib.jar"], |
| 960 | }, |
| 961 | linux_glibc: { |
| 962 | jars: ["java/linux_glibc/myjavalib.jar"], |
| 963 | }, |
| 964 | }, |
| 965 | } |
| 966 | `), |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 967 | checkAllCopyRules(` |
Colin Cross | f06d8dc | 2023-07-18 22:11:07 -0700 | [diff] [blame] | 968 | .intermediates/hostjavalib/linux_glibc_common/javac-header/hostjavalib.jar -> java/hostjavalib.jar |
Paul Duffin | 865171e | 2020-03-02 18:38:15 +0000 | [diff] [blame] | 969 | .intermediates/androidjavalib/android_common/turbine-combined/androidjavalib.jar -> java/androidjavalib.jar |
| 970 | .intermediates/myjavalib/android_common/javac/myjavalib.jar -> java/android/myjavalib.jar |
| 971 | .intermediates/myjavalib/linux_glibc_common/javac/myjavalib.jar -> java/linux_glibc/myjavalib.jar |
| 972 | `), |
| 973 | ) |
| 974 | } |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 975 | |
| 976 | func TestSnapshotWithJavaSdkLibrary(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 977 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 978 | sdk { |
| 979 | name: "mysdk", |
| 980 | java_sdk_libs: ["myjavalib"], |
| 981 | } |
| 982 | |
| 983 | java_sdk_library { |
| 984 | name: "myjavalib", |
| 985 | apex_available: ["//apex_available:anyapex"], |
| 986 | srcs: ["Test.java"], |
| 987 | sdk_version: "current", |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 988 | shared_library: false, |
Paul Duffin | 4911a89 | 2020-04-29 23:35:13 +0100 | [diff] [blame] | 989 | stubs_library_visibility: ["//other"], |
| 990 | stubs_source_visibility: ["//another"], |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 991 | permitted_packages: ["pkg.myjavalib"], |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 992 | } |
| 993 | `) |
| 994 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 995 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 996 | checkAndroidBpContents(` |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 997 | // This is auto-generated. DO NOT EDIT. |
| 998 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 999 | apex_contributions_defaults { |
| 1000 | name: "mysdk.contributions", |
| 1001 | contents: ["prebuilt_myjavalib"], |
| 1002 | } |
| 1003 | |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1004 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1005 | name: "myjavalib", |
| 1006 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1007 | visibility: ["//visibility:public"], |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1008 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1009 | shared_library: false, |
Paul Duffin | 869de14 | 2021-07-15 14:14:41 +0100 | [diff] [blame] | 1010 | permitted_packages: ["pkg.myjavalib"], |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1011 | public: { |
| 1012 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1013 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 1fd005d | 2020-04-09 01:08:11 +0100 | [diff] [blame] | 1014 | current_api: "sdk_library/public/myjavalib.txt", |
| 1015 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1016 | sdk_version: "current", |
| 1017 | }, |
| 1018 | system: { |
| 1019 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1020 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 1fd005d | 2020-04-09 01:08:11 +0100 | [diff] [blame] | 1021 | current_api: "sdk_library/system/myjavalib.txt", |
| 1022 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1023 | sdk_version: "system_current", |
| 1024 | }, |
| 1025 | test: { |
| 1026 | jars: ["sdk_library/test/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1027 | stub_srcs: ["sdk_library/test/myjavalib_stub_sources"], |
Paul Duffin | 1fd005d | 2020-04-09 01:08:11 +0100 | [diff] [blame] | 1028 | current_api: "sdk_library/test/myjavalib.txt", |
| 1029 | removed_api: "sdk_library/test/myjavalib-removed.txt", |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1030 | sdk_version: "test_current", |
| 1031 | }, |
| 1032 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1033 | `), |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1034 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1035 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1036 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1037 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
| 1038 | .intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar |
| 1039 | .intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt |
| 1040 | .intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt |
| 1041 | .intermediates/myjavalib.stubs.exportable.test/android_common/combined/myjavalib.stubs.exportable.test.jar -> sdk_library/test/myjavalib-stubs.jar |
| 1042 | .intermediates/myjavalib.stubs.source.test/android_common/exportable/myjavalib.stubs.source.test_api.txt -> sdk_library/test/myjavalib.txt |
| 1043 | .intermediates/myjavalib.stubs.source.test/android_common/exportable/myjavalib.stubs.source.test_removed.txt -> sdk_library/test/myjavalib-removed.txt |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1044 | `), |
Paul Duffin | 3d1248c | 2020-04-09 00:10:17 +0100 | [diff] [blame] | 1045 | checkMergeZips( |
| 1046 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1047 | ".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip", |
Paul Duffin | 3302871 | 2021-06-22 11:00:07 +0100 | [diff] [blame] | 1048 | ".intermediates/mysdk/common_os/tmp/sdk_library/test/myjavalib_stub_sources.zip", |
| 1049 | ), |
Paul Duffin | dd46f71 | 2020-02-10 13:37:10 +0000 | [diff] [blame] | 1050 | ) |
| 1051 | } |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1052 | |
Paul Duffin | e840995 | 2022-09-22 16:24:46 +0100 | [diff] [blame] | 1053 | func TestSnapshotWithJavaSdkLibrary_DistStem(t *testing.T) { |
| 1054 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
| 1055 | sdk { |
| 1056 | name: "mysdk", |
| 1057 | java_sdk_libs: ["myjavalib-foo"], |
| 1058 | } |
| 1059 | |
| 1060 | java_sdk_library { |
| 1061 | name: "myjavalib-foo", |
| 1062 | apex_available: ["//apex_available:anyapex"], |
| 1063 | srcs: ["Test.java"], |
| 1064 | sdk_version: "current", |
| 1065 | shared_library: false, |
| 1066 | public: { |
| 1067 | enabled: true, |
| 1068 | }, |
| 1069 | dist_stem: "myjavalib", |
| 1070 | } |
| 1071 | `) |
| 1072 | |
| 1073 | CheckSnapshot(t, result, "mysdk", "", |
| 1074 | checkAndroidBpContents(` |
| 1075 | // This is auto-generated. DO NOT EDIT. |
| 1076 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1077 | apex_contributions_defaults { |
| 1078 | name: "mysdk.contributions", |
| 1079 | contents: ["prebuilt_myjavalib-foo"], |
| 1080 | } |
| 1081 | |
Paul Duffin | e840995 | 2022-09-22 16:24:46 +0100 | [diff] [blame] | 1082 | java_sdk_library_import { |
| 1083 | name: "myjavalib-foo", |
| 1084 | prefer: false, |
| 1085 | visibility: ["//visibility:public"], |
| 1086 | apex_available: ["//apex_available:anyapex"], |
| 1087 | shared_library: false, |
| 1088 | public: { |
| 1089 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 1090 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
| 1091 | current_api: "sdk_library/public/myjavalib.txt", |
| 1092 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1093 | sdk_version: "current", |
| 1094 | }, |
| 1095 | } |
| 1096 | `), |
| 1097 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1098 | .intermediates/myjavalib-foo.stubs.exportable/android_common/combined/myjavalib-foo.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1099 | .intermediates/myjavalib-foo.stubs.source/android_common/exportable/myjavalib-foo.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1100 | .intermediates/myjavalib-foo.stubs.source/android_common/exportable/myjavalib-foo.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | e840995 | 2022-09-22 16:24:46 +0100 | [diff] [blame] | 1101 | `), |
| 1102 | checkMergeZips( |
| 1103 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1104 | ), |
| 1105 | ) |
| 1106 | } |
| 1107 | |
Paul Duffin | 22628d5 | 2021-05-12 23:13:22 +0100 | [diff] [blame] | 1108 | func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) { |
| 1109 | result := android.GroupFixturePreparers( |
| 1110 | prepareForSdkTestWithJavaSdkLibrary, |
| 1111 | android.FixtureMergeEnv(map[string]string{ |
| 1112 | "SOONG_SDK_SNAPSHOT_USE_SRCJAR": "true", |
| 1113 | }), |
| 1114 | ).RunTestWithBp(t, ` |
| 1115 | sdk { |
| 1116 | name: "mysdk", |
| 1117 | java_sdk_libs: ["myjavalib"], |
| 1118 | } |
| 1119 | |
| 1120 | java_sdk_library { |
| 1121 | name: "myjavalib", |
| 1122 | srcs: ["Test.java"], |
| 1123 | sdk_version: "current", |
| 1124 | shared_library: false, |
| 1125 | public: { |
| 1126 | enabled: true, |
| 1127 | }, |
| 1128 | } |
| 1129 | `) |
| 1130 | |
| 1131 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1132 | checkAndroidBpContents(` |
Paul Duffin | 22628d5 | 2021-05-12 23:13:22 +0100 | [diff] [blame] | 1133 | // This is auto-generated. DO NOT EDIT. |
| 1134 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1135 | apex_contributions_defaults { |
| 1136 | name: "mysdk.contributions", |
| 1137 | contents: ["prebuilt_myjavalib"], |
| 1138 | } |
| 1139 | |
Paul Duffin | 22628d5 | 2021-05-12 23:13:22 +0100 | [diff] [blame] | 1140 | java_sdk_library_import { |
| 1141 | name: "myjavalib", |
| 1142 | prefer: false, |
| 1143 | visibility: ["//visibility:public"], |
| 1144 | apex_available: ["//apex_available:platform"], |
| 1145 | shared_library: false, |
| 1146 | public: { |
| 1147 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 1148 | stub_srcs: ["sdk_library/public/myjavalib.srcjar"], |
| 1149 | current_api: "sdk_library/public/myjavalib.txt", |
| 1150 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1151 | sdk_version: "current", |
| 1152 | }, |
| 1153 | } |
| 1154 | `), |
| 1155 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1156 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1157 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source-stubs.srcjar -> sdk_library/public/myjavalib.srcjar |
| 1158 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1159 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | 22628d5 | 2021-05-12 23:13:22 +0100 | [diff] [blame] | 1160 | `), |
| 1161 | ) |
| 1162 | } |
| 1163 | |
Anton Hansson | d78eb76 | 2021-09-21 15:25:12 +0100 | [diff] [blame] | 1164 | func TestSnapshotWithJavaSdkLibrary_AnnotationsZip(t *testing.T) { |
| 1165 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
| 1166 | sdk { |
| 1167 | name: "mysdk", |
| 1168 | java_sdk_libs: ["myjavalib"], |
| 1169 | } |
| 1170 | |
| 1171 | java_sdk_library { |
| 1172 | name: "myjavalib", |
| 1173 | srcs: ["Test.java"], |
| 1174 | sdk_version: "current", |
| 1175 | shared_library: false, |
| 1176 | annotations_enabled: true, |
| 1177 | public: { |
| 1178 | enabled: true, |
| 1179 | }, |
| 1180 | } |
| 1181 | `) |
| 1182 | |
| 1183 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1184 | checkAndroidBpContents(` |
Anton Hansson | d78eb76 | 2021-09-21 15:25:12 +0100 | [diff] [blame] | 1185 | // This is auto-generated. DO NOT EDIT. |
| 1186 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1187 | apex_contributions_defaults { |
| 1188 | name: "mysdk.contributions", |
| 1189 | contents: ["prebuilt_myjavalib"], |
| 1190 | } |
| 1191 | |
Anton Hansson | d78eb76 | 2021-09-21 15:25:12 +0100 | [diff] [blame] | 1192 | java_sdk_library_import { |
| 1193 | name: "myjavalib", |
| 1194 | prefer: false, |
| 1195 | visibility: ["//visibility:public"], |
| 1196 | apex_available: ["//apex_available:platform"], |
| 1197 | shared_library: false, |
| 1198 | public: { |
| 1199 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 1200 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
| 1201 | current_api: "sdk_library/public/myjavalib.txt", |
| 1202 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1203 | annotations: "sdk_library/public/myjavalib_annotations.zip", |
| 1204 | sdk_version: "current", |
| 1205 | }, |
| 1206 | } |
| 1207 | `), |
| 1208 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1209 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1210 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1211 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
| 1212 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_annotations.zip -> sdk_library/public/myjavalib_annotations.zip |
Anton Hansson | d78eb76 | 2021-09-21 15:25:12 +0100 | [diff] [blame] | 1213 | `), |
| 1214 | checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"), |
| 1215 | ) |
| 1216 | } |
| 1217 | |
Paul Duffin | a54016c | 2022-01-27 16:39:47 +0000 | [diff] [blame] | 1218 | func TestSnapshotWithJavaSdkLibrary_AnnotationsZip_PreT(t *testing.T) { |
| 1219 | result := android.GroupFixturePreparers( |
| 1220 | prepareForSdkTestWithJavaSdkLibrary, |
| 1221 | android.FixtureMergeEnv(map[string]string{ |
| 1222 | "SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S", |
| 1223 | }), |
| 1224 | ).RunTestWithBp(t, ` |
| 1225 | sdk { |
| 1226 | name: "mysdk", |
| 1227 | java_sdk_libs: ["myjavalib"], |
| 1228 | } |
| 1229 | |
| 1230 | java_sdk_library { |
| 1231 | name: "myjavalib", |
| 1232 | srcs: ["Test.java"], |
Paul Duffin | 1938dba | 2022-07-26 23:53:00 +0000 | [diff] [blame] | 1233 | sdk_version: "S", |
Paul Duffin | a54016c | 2022-01-27 16:39:47 +0000 | [diff] [blame] | 1234 | shared_library: false, |
| 1235 | annotations_enabled: true, |
| 1236 | public: { |
| 1237 | enabled: true, |
| 1238 | }, |
| 1239 | } |
| 1240 | `) |
| 1241 | |
| 1242 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1243 | checkAndroidBpContents(` |
Paul Duffin | a54016c | 2022-01-27 16:39:47 +0000 | [diff] [blame] | 1244 | // This is auto-generated. DO NOT EDIT. |
| 1245 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1246 | apex_contributions_defaults { |
| 1247 | name: "mysdk.contributions", |
| 1248 | contents: ["prebuilt_myjavalib"], |
| 1249 | } |
| 1250 | |
Paul Duffin | a54016c | 2022-01-27 16:39:47 +0000 | [diff] [blame] | 1251 | java_sdk_library_import { |
| 1252 | name: "myjavalib", |
| 1253 | prefer: false, |
| 1254 | visibility: ["//visibility:public"], |
| 1255 | apex_available: ["//apex_available:platform"], |
| 1256 | shared_library: false, |
| 1257 | public: { |
| 1258 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 1259 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
| 1260 | current_api: "sdk_library/public/myjavalib.txt", |
| 1261 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1262 | sdk_version: "current", |
| 1263 | }, |
| 1264 | } |
| 1265 | `), |
| 1266 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1267 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1268 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1269 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | a54016c | 2022-01-27 16:39:47 +0000 | [diff] [blame] | 1270 | `), |
| 1271 | checkMergeZips(".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip"), |
| 1272 | ) |
| 1273 | } |
| 1274 | |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1275 | func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 1276 | result := android.GroupFixturePreparers( |
| 1277 | prepareForSdkTestWithJavaSdkLibrary, |
| 1278 | android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { |
| 1279 | variables.BuildFlags = map[string]string{ |
| 1280 | "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", |
| 1281 | } |
| 1282 | }), |
| 1283 | ).RunTestWithBp(t, ` |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1284 | sdk { |
| 1285 | name: "mysdk", |
| 1286 | java_sdk_libs: ["myjavalib"], |
| 1287 | } |
| 1288 | |
| 1289 | java_sdk_library { |
| 1290 | name: "myjavalib", |
| 1291 | srcs: ["Test.java"], |
| 1292 | sdk_version: "current", |
| 1293 | shared_library: false, |
| 1294 | compile_dex: true, |
| 1295 | public: { |
| 1296 | enabled: true, |
| 1297 | }, |
| 1298 | system: { |
| 1299 | enabled: true, |
| 1300 | }, |
| 1301 | } |
| 1302 | `) |
| 1303 | |
| 1304 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1305 | checkAndroidBpContents(` |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1306 | // This is auto-generated. DO NOT EDIT. |
| 1307 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1308 | apex_contributions_defaults { |
| 1309 | name: "mysdk.contributions", |
| 1310 | contents: ["prebuilt_myjavalib"], |
| 1311 | } |
| 1312 | |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1313 | java_sdk_library_import { |
| 1314 | name: "myjavalib", |
| 1315 | prefer: false, |
| 1316 | visibility: ["//visibility:public"], |
| 1317 | apex_available: ["//apex_available:platform"], |
| 1318 | shared_library: false, |
| 1319 | compile_dex: true, |
| 1320 | public: { |
| 1321 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 1322 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
| 1323 | current_api: "sdk_library/public/myjavalib.txt", |
| 1324 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1325 | sdk_version: "current", |
| 1326 | }, |
| 1327 | system: { |
| 1328 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
| 1329 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
| 1330 | current_api: "sdk_library/system/myjavalib.txt", |
| 1331 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1332 | sdk_version: "system_current", |
| 1333 | }, |
| 1334 | } |
| 1335 | `), |
| 1336 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 1337 | ctx := android.ModuleInstallPathContextForTesting(result.Config) |
| 1338 | dexJarBuildPath := func(name string, kind android.SdkKind) string { |
| 1339 | dep := result.Module(name, "android_common").(java.SdkLibraryDependency) |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 1340 | path := dep.SdkApiExportableStubDexJar(ctx, kind).Path() |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1341 | return path.RelativeToTop().String() |
| 1342 | } |
| 1343 | |
| 1344 | dexJarPath := dexJarBuildPath("myjavalib", android.SdkPublic) |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 1345 | android.AssertStringEquals(t, "source dex public stubs jar build path", "out/soong/.intermediates/myjavalib.stubs.exportable/android_common/dex/myjavalib.stubs.exportable.jar", dexJarPath) |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1346 | |
| 1347 | dexJarPath = dexJarBuildPath("myjavalib", android.SdkSystem) |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 1348 | systemDexJar := "out/soong/.intermediates/myjavalib.stubs.exportable.system/android_common/dex/myjavalib.stubs.exportable.system.jar" |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1349 | android.AssertStringEquals(t, "source dex system stubs jar build path", systemDexJar, dexJarPath) |
| 1350 | |
| 1351 | // This should fall back to system as module is not available. |
| 1352 | dexJarPath = dexJarBuildPath("myjavalib", android.SdkModule) |
| 1353 | android.AssertStringEquals(t, "source dex module stubs jar build path", systemDexJar, dexJarPath) |
| 1354 | |
Jihoon Kang | bd09345 | 2023-12-26 19:08:01 +0000 | [diff] [blame] | 1355 | // Prebuilt dex jar does not come from the exportable stubs. |
Paul Duffin | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1356 | dexJarPath = dexJarBuildPath(android.PrebuiltNameFromSource("myjavalib"), android.SdkPublic) |
| 1357 | android.AssertStringEquals(t, "prebuilt dex public stubs jar build path", "out/soong/.intermediates/snapshot/prebuilt_myjavalib.stubs/android_common/dex/myjavalib.stubs.jar", dexJarPath) |
| 1358 | }), |
| 1359 | ) |
| 1360 | } |
| 1361 | |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1362 | func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1363 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1364 | sdk { |
| 1365 | name: "mysdk", |
| 1366 | java_sdk_libs: ["myjavalib"], |
| 1367 | } |
| 1368 | |
| 1369 | java_sdk_library { |
| 1370 | name: "myjavalib", |
| 1371 | srcs: ["Test.java"], |
| 1372 | sdk_version: "none", |
| 1373 | system_modules: "none", |
| 1374 | } |
| 1375 | `) |
| 1376 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1377 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1378 | checkAndroidBpContents(` |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1379 | // This is auto-generated. DO NOT EDIT. |
| 1380 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1381 | apex_contributions_defaults { |
| 1382 | name: "mysdk.contributions", |
| 1383 | contents: ["prebuilt_myjavalib"], |
| 1384 | } |
| 1385 | |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1386 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1387 | name: "myjavalib", |
| 1388 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1389 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1390 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1391 | shared_library: true, |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1392 | public: { |
| 1393 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1394 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1395 | current_api: "sdk_library/public/myjavalib.txt", |
| 1396 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1397 | sdk_version: "none", |
| 1398 | }, |
| 1399 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1400 | `), |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1401 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1402 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1403 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1404 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1405 | `), |
| 1406 | checkMergeZips( |
| 1407 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1408 | ), |
| 1409 | ) |
| 1410 | } |
| 1411 | |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1412 | func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1413 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1414 | sdk { |
| 1415 | name: "mysdk", |
| 1416 | java_sdk_libs: ["myjavalib"], |
| 1417 | } |
| 1418 | |
| 1419 | java_sdk_library { |
| 1420 | name: "myjavalib", |
| 1421 | srcs: ["Test.java"], |
| 1422 | sdk_version: "module_current", |
| 1423 | public: { |
| 1424 | enabled: true, |
| 1425 | sdk_version: "module_current", |
| 1426 | }, |
| 1427 | } |
| 1428 | `) |
| 1429 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1430 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1431 | checkAndroidBpContents(` |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1432 | // This is auto-generated. DO NOT EDIT. |
| 1433 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1434 | apex_contributions_defaults { |
| 1435 | name: "mysdk.contributions", |
| 1436 | contents: ["prebuilt_myjavalib"], |
| 1437 | } |
| 1438 | |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1439 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1440 | name: "myjavalib", |
| 1441 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1442 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1443 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1444 | shared_library: true, |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1445 | public: { |
| 1446 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1447 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1448 | current_api: "sdk_library/public/myjavalib.txt", |
| 1449 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1450 | sdk_version: "module_current", |
| 1451 | }, |
| 1452 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1453 | `), |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1454 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1455 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1456 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1457 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1458 | `), |
| 1459 | checkMergeZips( |
| 1460 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1461 | ), |
| 1462 | ) |
| 1463 | } |
| 1464 | |
| 1465 | func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1466 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1467 | sdk { |
| 1468 | name: "mysdk", |
| 1469 | java_sdk_libs: ["myjavalib"], |
| 1470 | } |
| 1471 | |
| 1472 | java_sdk_library { |
| 1473 | name: "myjavalib", |
| 1474 | apex_available: ["//apex_available:anyapex"], |
| 1475 | srcs: ["Test.java"], |
| 1476 | sdk_version: "current", |
| 1477 | public: { |
| 1478 | enabled: true, |
| 1479 | }, |
| 1480 | system: { |
| 1481 | enabled: true, |
| 1482 | }, |
| 1483 | } |
| 1484 | `) |
| 1485 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1486 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1487 | checkAndroidBpContents(` |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1488 | // This is auto-generated. DO NOT EDIT. |
| 1489 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1490 | apex_contributions_defaults { |
| 1491 | name: "mysdk.contributions", |
| 1492 | contents: ["prebuilt_myjavalib"], |
| 1493 | } |
| 1494 | |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1495 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1496 | name: "myjavalib", |
| 1497 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1498 | visibility: ["//visibility:public"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1499 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1500 | shared_library: true, |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1501 | public: { |
| 1502 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1503 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1504 | current_api: "sdk_library/public/myjavalib.txt", |
| 1505 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1506 | sdk_version: "current", |
| 1507 | }, |
| 1508 | system: { |
| 1509 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1510 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1511 | current_api: "sdk_library/system/myjavalib.txt", |
| 1512 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1513 | sdk_version: "system_current", |
| 1514 | }, |
| 1515 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1516 | `), |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1517 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1518 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1519 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1520 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
| 1521 | .intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar |
| 1522 | .intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt |
| 1523 | .intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1524 | `), |
| 1525 | checkMergeZips( |
| 1526 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1527 | ".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip", |
| 1528 | ), |
| 1529 | ) |
| 1530 | } |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1531 | |
| 1532 | func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1533 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1534 | sdk { |
| 1535 | name: "mysdk", |
| 1536 | java_sdk_libs: ["myjavalib"], |
| 1537 | } |
| 1538 | |
| 1539 | java_sdk_library { |
| 1540 | name: "myjavalib", |
| 1541 | apex_available: ["//apex_available:anyapex"], |
| 1542 | srcs: ["Test.java"], |
| 1543 | sdk_version: "current", |
| 1544 | public: { |
| 1545 | enabled: true, |
| 1546 | }, |
| 1547 | system: { |
| 1548 | enabled: true, |
| 1549 | }, |
| 1550 | module_lib: { |
| 1551 | enabled: true, |
| 1552 | }, |
| 1553 | } |
| 1554 | `) |
| 1555 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1556 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1557 | checkAndroidBpContents(` |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1558 | // This is auto-generated. DO NOT EDIT. |
| 1559 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1560 | apex_contributions_defaults { |
| 1561 | name: "mysdk.contributions", |
| 1562 | contents: ["prebuilt_myjavalib"], |
| 1563 | } |
| 1564 | |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1565 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1566 | name: "myjavalib", |
| 1567 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1568 | visibility: ["//visibility:public"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1569 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1570 | shared_library: true, |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1571 | public: { |
| 1572 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1573 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1574 | current_api: "sdk_library/public/myjavalib.txt", |
| 1575 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1576 | sdk_version: "current", |
| 1577 | }, |
| 1578 | system: { |
| 1579 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1580 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1581 | current_api: "sdk_library/system/myjavalib.txt", |
| 1582 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1583 | sdk_version: "system_current", |
| 1584 | }, |
| 1585 | module_lib: { |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1586 | jars: ["sdk_library/module-lib/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1587 | stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"], |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1588 | current_api: "sdk_library/module-lib/myjavalib.txt", |
| 1589 | removed_api: "sdk_library/module-lib/myjavalib-removed.txt", |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1590 | sdk_version: "module_current", |
| 1591 | }, |
| 1592 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1593 | `), |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1594 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1595 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1596 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1597 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
| 1598 | .intermediates/myjavalib.stubs.exportable.system/android_common/combined/myjavalib.stubs.exportable.system.jar -> sdk_library/system/myjavalib-stubs.jar |
| 1599 | .intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt |
| 1600 | .intermediates/myjavalib.stubs.source.system/android_common/exportable/myjavalib.stubs.source.system_removed.txt -> sdk_library/system/myjavalib-removed.txt |
| 1601 | .intermediates/myjavalib.stubs.exportable.module_lib/android_common/combined/myjavalib.stubs.exportable.module_lib.jar -> sdk_library/module-lib/myjavalib-stubs.jar |
| 1602 | .intermediates/myjavalib.stubs.source.module_lib/android_common/exportable/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt |
| 1603 | .intermediates/myjavalib.stubs.source.module_lib/android_common/exportable/myjavalib.stubs.source.module_lib_removed.txt -> sdk_library/module-lib/myjavalib-removed.txt |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1604 | `), |
| 1605 | checkMergeZips( |
Paul Duffin | 74f1dcd | 2022-07-18 13:18:23 +0000 | [diff] [blame] | 1606 | ".intermediates/mysdk/common_os/tmp/sdk_library/module-lib/myjavalib_stub_sources.zip", |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1607 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1608 | ".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip", |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1609 | ), |
| 1610 | ) |
| 1611 | } |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1612 | |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1613 | func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1614 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1615 | sdk { |
| 1616 | name: "mysdk", |
| 1617 | java_sdk_libs: ["myjavalib"], |
| 1618 | } |
| 1619 | |
| 1620 | java_sdk_library { |
| 1621 | name: "myjavalib", |
| 1622 | apex_available: ["//apex_available:anyapex"], |
| 1623 | srcs: ["Test.java"], |
| 1624 | sdk_version: "current", |
| 1625 | public: { |
| 1626 | enabled: true, |
| 1627 | }, |
| 1628 | system_server: { |
| 1629 | enabled: true, |
| 1630 | }, |
| 1631 | } |
| 1632 | `) |
| 1633 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1634 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1635 | checkAndroidBpContents(` |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1636 | // This is auto-generated. DO NOT EDIT. |
| 1637 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1638 | apex_contributions_defaults { |
| 1639 | name: "mysdk.contributions", |
| 1640 | contents: ["prebuilt_myjavalib"], |
| 1641 | } |
| 1642 | |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1643 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1644 | name: "myjavalib", |
| 1645 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1646 | visibility: ["//visibility:public"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1647 | apex_available: ["//apex_available:anyapex"], |
| 1648 | shared_library: true, |
| 1649 | public: { |
| 1650 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1651 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1652 | current_api: "sdk_library/public/myjavalib.txt", |
| 1653 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1654 | sdk_version: "current", |
| 1655 | }, |
| 1656 | system_server: { |
| 1657 | jars: ["sdk_library/system-server/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1658 | stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1659 | current_api: "sdk_library/system-server/myjavalib.txt", |
| 1660 | removed_api: "sdk_library/system-server/myjavalib-removed.txt", |
| 1661 | sdk_version: "system_server_current", |
| 1662 | }, |
| 1663 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1664 | `), |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1665 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1666 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1667 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1668 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
| 1669 | .intermediates/myjavalib.stubs.exportable.system_server/android_common/combined/myjavalib.stubs.exportable.system_server.jar -> sdk_library/system-server/myjavalib-stubs.jar |
| 1670 | .intermediates/myjavalib.stubs.source.system_server/android_common/exportable/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt |
| 1671 | .intermediates/myjavalib.stubs.source.system_server/android_common/exportable/myjavalib.stubs.source.system_server_removed.txt -> sdk_library/system-server/myjavalib-removed.txt |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1672 | `), |
| 1673 | checkMergeZips( |
| 1674 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1675 | ".intermediates/mysdk/common_os/tmp/sdk_library/system-server/myjavalib_stub_sources.zip", |
| 1676 | ), |
| 1677 | ) |
| 1678 | } |
| 1679 | |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1680 | func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1681 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1682 | sdk { |
| 1683 | name: "mysdk", |
| 1684 | java_sdk_libs: ["myjavalib"], |
| 1685 | } |
| 1686 | |
| 1687 | java_sdk_library { |
| 1688 | name: "myjavalib", |
| 1689 | apex_available: ["//apex_available:anyapex"], |
| 1690 | srcs: ["Test.java"], |
| 1691 | sdk_version: "current", |
Paul Duffin | ee9ad5d | 2020-09-11 13:04:05 +0100 | [diff] [blame] | 1692 | naming_scheme: "default", |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1693 | public: { |
| 1694 | enabled: true, |
| 1695 | }, |
| 1696 | } |
| 1697 | `) |
| 1698 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1699 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1700 | checkAndroidBpContents(` |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1701 | // This is auto-generated. DO NOT EDIT. |
| 1702 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1703 | apex_contributions_defaults { |
| 1704 | name: "mysdk.contributions", |
| 1705 | contents: ["prebuilt_myjavalib"], |
| 1706 | } |
| 1707 | |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1708 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1709 | name: "myjavalib", |
| 1710 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1711 | visibility: ["//visibility:public"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1712 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | ee9ad5d | 2020-09-11 13:04:05 +0100 | [diff] [blame] | 1713 | naming_scheme: "default", |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1714 | shared_library: true, |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1715 | public: { |
| 1716 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1717 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1718 | current_api: "sdk_library/public/myjavalib.txt", |
| 1719 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1720 | sdk_version: "current", |
| 1721 | }, |
| 1722 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1723 | `), |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1724 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1725 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1726 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1727 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1728 | `), |
| 1729 | checkMergeZips( |
| 1730 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1731 | ), |
| 1732 | ) |
| 1733 | } |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1734 | |
| 1735 | func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) { |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 1736 | result := android.GroupFixturePreparers( |
| 1737 | prepareForSdkTestWithJavaSdkLibrary, |
| 1738 | android.FixtureAddFile("docs/known_doctags", nil), |
| 1739 | ).RunTestWithBp(t, ` |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1740 | sdk { |
| 1741 | name: "mysdk", |
| 1742 | java_sdk_libs: ["myjavalib"], |
| 1743 | } |
| 1744 | |
| 1745 | java_sdk_library { |
| 1746 | name: "myjavalib", |
| 1747 | srcs: ["Test.java"], |
| 1748 | sdk_version: "current", |
| 1749 | public: { |
| 1750 | enabled: true, |
| 1751 | }, |
| 1752 | doctag_files: ["docs/known_doctags"], |
| 1753 | } |
| 1754 | |
| 1755 | filegroup { |
| 1756 | name: "mygroup", |
| 1757 | srcs: [":myjavalib{.doctags}"], |
| 1758 | } |
| 1759 | `) |
| 1760 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1761 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | b01ac4b | 2022-05-24 20:10:05 +0000 | [diff] [blame] | 1762 | checkAndroidBpContents(` |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1763 | // This is auto-generated. DO NOT EDIT. |
| 1764 | |
Spandan Das | a5e26d3 | 2024-03-06 14:04:36 +0000 | [diff] [blame] | 1765 | apex_contributions_defaults { |
| 1766 | name: "mysdk.contributions", |
| 1767 | contents: ["prebuilt_myjavalib"], |
| 1768 | } |
| 1769 | |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1770 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1771 | name: "myjavalib", |
| 1772 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1773 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1774 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1775 | shared_library: true, |
| 1776 | doctag_files: ["doctags/docs/known_doctags"], |
| 1777 | public: { |
| 1778 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1779 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1780 | current_api: "sdk_library/public/myjavalib.txt", |
| 1781 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1782 | sdk_version: "current", |
| 1783 | }, |
| 1784 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1785 | `), |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1786 | checkAllCopyRules(` |
Jihoon Kang | f55a5f7 | 2024-01-08 08:56:20 +0000 | [diff] [blame] | 1787 | .intermediates/myjavalib.stubs.exportable/android_common/combined/myjavalib.stubs.exportable.jar -> sdk_library/public/myjavalib-stubs.jar |
| 1788 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1789 | .intermediates/myjavalib.stubs.source/android_common/exportable/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1790 | docs/known_doctags -> doctags/docs/known_doctags |
| 1791 | `), |
| 1792 | ) |
| 1793 | } |