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