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