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