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 | 1267d87 | 2021-04-16 17:21:36 +0100 | [diff] [blame] | 1092 | func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) { |
| 1093 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
| 1094 | sdk { |
| 1095 | name: "mysdk", |
| 1096 | java_sdk_libs: ["myjavalib"], |
| 1097 | } |
| 1098 | |
| 1099 | java_sdk_library { |
| 1100 | name: "myjavalib", |
| 1101 | srcs: ["Test.java"], |
| 1102 | sdk_version: "current", |
| 1103 | shared_library: false, |
| 1104 | compile_dex: true, |
| 1105 | public: { |
| 1106 | enabled: true, |
| 1107 | }, |
| 1108 | system: { |
| 1109 | enabled: true, |
| 1110 | }, |
| 1111 | } |
| 1112 | `) |
| 1113 | |
| 1114 | CheckSnapshot(t, result, "mysdk", "", |
| 1115 | checkUnversionedAndroidBpContents(` |
| 1116 | // This is auto-generated. DO NOT EDIT. |
| 1117 | |
| 1118 | java_sdk_library_import { |
| 1119 | name: "myjavalib", |
| 1120 | prefer: false, |
| 1121 | visibility: ["//visibility:public"], |
| 1122 | apex_available: ["//apex_available:platform"], |
| 1123 | shared_library: false, |
| 1124 | compile_dex: true, |
| 1125 | public: { |
| 1126 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
| 1127 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
| 1128 | current_api: "sdk_library/public/myjavalib.txt", |
| 1129 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1130 | sdk_version: "current", |
| 1131 | }, |
| 1132 | system: { |
| 1133 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
| 1134 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
| 1135 | current_api: "sdk_library/system/myjavalib.txt", |
| 1136 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1137 | sdk_version: "system_current", |
| 1138 | }, |
| 1139 | } |
| 1140 | `), |
| 1141 | snapshotTestChecker(checkSnapshotWithSourcePreferred, func(t *testing.T, result *android.TestResult) { |
| 1142 | ctx := android.ModuleInstallPathContextForTesting(result.Config) |
| 1143 | dexJarBuildPath := func(name string, kind android.SdkKind) string { |
| 1144 | dep := result.Module(name, "android_common").(java.SdkLibraryDependency) |
| 1145 | path := dep.SdkApiStubDexJar(ctx, kind) |
| 1146 | return path.RelativeToTop().String() |
| 1147 | } |
| 1148 | |
| 1149 | dexJarPath := dexJarBuildPath("myjavalib", android.SdkPublic) |
| 1150 | android.AssertStringEquals(t, "source dex public stubs jar build path", "out/soong/.intermediates/myjavalib.stubs/android_common/dex/myjavalib.stubs.jar", dexJarPath) |
| 1151 | |
| 1152 | dexJarPath = dexJarBuildPath("myjavalib", android.SdkSystem) |
| 1153 | systemDexJar := "out/soong/.intermediates/myjavalib.stubs.system/android_common/dex/myjavalib.stubs.system.jar" |
| 1154 | android.AssertStringEquals(t, "source dex system stubs jar build path", systemDexJar, dexJarPath) |
| 1155 | |
| 1156 | // This should fall back to system as module is not available. |
| 1157 | dexJarPath = dexJarBuildPath("myjavalib", android.SdkModule) |
| 1158 | android.AssertStringEquals(t, "source dex module stubs jar build path", systemDexJar, dexJarPath) |
| 1159 | |
| 1160 | dexJarPath = dexJarBuildPath(android.PrebuiltNameFromSource("myjavalib"), android.SdkPublic) |
| 1161 | android.AssertStringEquals(t, "prebuilt dex public stubs jar build path", "out/soong/.intermediates/snapshot/prebuilt_myjavalib.stubs/android_common/dex/myjavalib.stubs.jar", dexJarPath) |
| 1162 | }), |
| 1163 | ) |
| 1164 | } |
| 1165 | |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1166 | func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1167 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1168 | sdk { |
| 1169 | name: "mysdk", |
| 1170 | java_sdk_libs: ["myjavalib"], |
| 1171 | } |
| 1172 | |
| 1173 | java_sdk_library { |
| 1174 | name: "myjavalib", |
| 1175 | srcs: ["Test.java"], |
| 1176 | sdk_version: "none", |
| 1177 | system_modules: "none", |
| 1178 | } |
| 1179 | `) |
| 1180 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1181 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1182 | checkUnversionedAndroidBpContents(` |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1183 | // This is auto-generated. DO NOT EDIT. |
| 1184 | |
| 1185 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1186 | name: "myjavalib", |
| 1187 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1188 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1189 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1190 | shared_library: true, |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1191 | public: { |
| 1192 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1193 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1194 | current_api: "sdk_library/public/myjavalib.txt", |
| 1195 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1196 | sdk_version: "none", |
| 1197 | }, |
| 1198 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1199 | `), |
| 1200 | checkVersionedAndroidBpContents(` |
| 1201 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1202 | |
| 1203 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1204 | name: "mysdk_myjavalib@current", |
| 1205 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1206 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1207 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1208 | shared_library: true, |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1209 | public: { |
| 1210 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1211 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1212 | current_api: "sdk_library/public/myjavalib.txt", |
| 1213 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1214 | sdk_version: "none", |
| 1215 | }, |
| 1216 | } |
| 1217 | |
| 1218 | sdk_snapshot { |
| 1219 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1220 | visibility: ["//visibility:public"], |
Paul Duffin | 780c5f4 | 2020-05-12 15:52:55 +0100 | [diff] [blame] | 1221 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1222 | } |
| 1223 | `), |
| 1224 | checkAllCopyRules(` |
| 1225 | .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] | 1226 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1227 | .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] | 1228 | `), |
| 1229 | checkMergeZips( |
| 1230 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1231 | ), |
| 1232 | ) |
| 1233 | } |
| 1234 | |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1235 | func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1236 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1237 | sdk { |
| 1238 | name: "mysdk", |
| 1239 | java_sdk_libs: ["myjavalib"], |
| 1240 | } |
| 1241 | |
| 1242 | java_sdk_library { |
| 1243 | name: "myjavalib", |
| 1244 | srcs: ["Test.java"], |
| 1245 | sdk_version: "module_current", |
| 1246 | public: { |
| 1247 | enabled: true, |
| 1248 | sdk_version: "module_current", |
| 1249 | }, |
| 1250 | } |
| 1251 | `) |
| 1252 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1253 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1254 | checkUnversionedAndroidBpContents(` |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1255 | // This is auto-generated. DO NOT EDIT. |
| 1256 | |
| 1257 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1258 | name: "myjavalib", |
| 1259 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1260 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1261 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1262 | shared_library: true, |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1263 | public: { |
| 1264 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1265 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1266 | current_api: "sdk_library/public/myjavalib.txt", |
| 1267 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1268 | sdk_version: "module_current", |
| 1269 | }, |
| 1270 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1271 | `), |
| 1272 | checkVersionedAndroidBpContents(` |
| 1273 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1274 | |
| 1275 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1276 | name: "mysdk_myjavalib@current", |
| 1277 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1278 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1279 | apex_available: ["//apex_available:platform"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1280 | shared_library: true, |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1281 | public: { |
| 1282 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1283 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1284 | current_api: "sdk_library/public/myjavalib.txt", |
| 1285 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1286 | sdk_version: "module_current", |
| 1287 | }, |
| 1288 | } |
| 1289 | |
| 1290 | sdk_snapshot { |
| 1291 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1292 | visibility: ["//visibility:public"], |
Paul Duffin | 87a05a3 | 2020-05-12 11:50:28 +0100 | [diff] [blame] | 1293 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1294 | } |
| 1295 | `), |
| 1296 | checkAllCopyRules(` |
| 1297 | .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] | 1298 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1299 | .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] | 1300 | `), |
| 1301 | checkMergeZips( |
| 1302 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1303 | ), |
| 1304 | ) |
| 1305 | } |
| 1306 | |
| 1307 | func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1308 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1309 | sdk { |
| 1310 | name: "mysdk", |
| 1311 | java_sdk_libs: ["myjavalib"], |
| 1312 | } |
| 1313 | |
| 1314 | java_sdk_library { |
| 1315 | name: "myjavalib", |
| 1316 | apex_available: ["//apex_available:anyapex"], |
| 1317 | srcs: ["Test.java"], |
| 1318 | sdk_version: "current", |
| 1319 | public: { |
| 1320 | enabled: true, |
| 1321 | }, |
| 1322 | system: { |
| 1323 | enabled: true, |
| 1324 | }, |
| 1325 | } |
| 1326 | `) |
| 1327 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1328 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1329 | checkUnversionedAndroidBpContents(` |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1330 | // This is auto-generated. DO NOT EDIT. |
| 1331 | |
| 1332 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1333 | name: "myjavalib", |
| 1334 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1335 | visibility: ["//visibility:public"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1336 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1337 | shared_library: true, |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1338 | public: { |
| 1339 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1340 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1341 | current_api: "sdk_library/public/myjavalib.txt", |
| 1342 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1343 | sdk_version: "current", |
| 1344 | }, |
| 1345 | system: { |
| 1346 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1347 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1348 | current_api: "sdk_library/system/myjavalib.txt", |
| 1349 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1350 | sdk_version: "system_current", |
| 1351 | }, |
| 1352 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1353 | `), |
| 1354 | checkVersionedAndroidBpContents(` |
| 1355 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1356 | |
| 1357 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1358 | name: "mysdk_myjavalib@current", |
| 1359 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1360 | visibility: ["//visibility:public"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1361 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1362 | shared_library: true, |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1363 | public: { |
| 1364 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1365 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1366 | current_api: "sdk_library/public/myjavalib.txt", |
| 1367 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1368 | sdk_version: "current", |
| 1369 | }, |
| 1370 | system: { |
| 1371 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1372 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1373 | current_api: "sdk_library/system/myjavalib.txt", |
| 1374 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1375 | sdk_version: "system_current", |
| 1376 | }, |
| 1377 | } |
| 1378 | |
| 1379 | sdk_snapshot { |
| 1380 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1381 | visibility: ["//visibility:public"], |
Paul Duffin | 3375e35 | 2020-04-28 10:44:03 +0100 | [diff] [blame] | 1382 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1383 | } |
| 1384 | `), |
| 1385 | checkAllCopyRules(` |
| 1386 | .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] | 1387 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1388 | .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] | 1389 | .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] | 1390 | .intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt |
| 1391 | .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] | 1392 | `), |
| 1393 | checkMergeZips( |
| 1394 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1395 | ".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip", |
| 1396 | ), |
| 1397 | ) |
| 1398 | } |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1399 | |
| 1400 | func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1401 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1402 | sdk { |
| 1403 | name: "mysdk", |
| 1404 | java_sdk_libs: ["myjavalib"], |
| 1405 | } |
| 1406 | |
| 1407 | java_sdk_library { |
| 1408 | name: "myjavalib", |
| 1409 | apex_available: ["//apex_available:anyapex"], |
| 1410 | srcs: ["Test.java"], |
| 1411 | sdk_version: "current", |
| 1412 | public: { |
| 1413 | enabled: true, |
| 1414 | }, |
| 1415 | system: { |
| 1416 | enabled: true, |
| 1417 | }, |
| 1418 | module_lib: { |
| 1419 | enabled: true, |
| 1420 | }, |
| 1421 | } |
| 1422 | `) |
| 1423 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1424 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1425 | checkUnversionedAndroidBpContents(` |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1426 | // This is auto-generated. DO NOT EDIT. |
| 1427 | |
| 1428 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1429 | name: "myjavalib", |
| 1430 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1431 | visibility: ["//visibility:public"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1432 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1433 | shared_library: true, |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1434 | public: { |
| 1435 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1436 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1437 | current_api: "sdk_library/public/myjavalib.txt", |
| 1438 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1439 | sdk_version: "current", |
| 1440 | }, |
| 1441 | system: { |
| 1442 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1443 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1444 | current_api: "sdk_library/system/myjavalib.txt", |
| 1445 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1446 | sdk_version: "system_current", |
| 1447 | }, |
| 1448 | module_lib: { |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1449 | jars: ["sdk_library/module-lib/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1450 | stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"], |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1451 | current_api: "sdk_library/module-lib/myjavalib.txt", |
| 1452 | removed_api: "sdk_library/module-lib/myjavalib-removed.txt", |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1453 | sdk_version: "module_current", |
| 1454 | }, |
| 1455 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1456 | `), |
| 1457 | checkVersionedAndroidBpContents(` |
| 1458 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1459 | |
| 1460 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1461 | name: "mysdk_myjavalib@current", |
| 1462 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1463 | visibility: ["//visibility:public"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1464 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1465 | shared_library: true, |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1466 | public: { |
| 1467 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1468 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1469 | current_api: "sdk_library/public/myjavalib.txt", |
| 1470 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1471 | sdk_version: "current", |
| 1472 | }, |
| 1473 | system: { |
| 1474 | jars: ["sdk_library/system/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1475 | stub_srcs: ["sdk_library/system/myjavalib_stub_sources"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1476 | current_api: "sdk_library/system/myjavalib.txt", |
| 1477 | removed_api: "sdk_library/system/myjavalib-removed.txt", |
| 1478 | sdk_version: "system_current", |
| 1479 | }, |
| 1480 | module_lib: { |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1481 | jars: ["sdk_library/module-lib/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1482 | stub_srcs: ["sdk_library/module-lib/myjavalib_stub_sources"], |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1483 | current_api: "sdk_library/module-lib/myjavalib.txt", |
| 1484 | removed_api: "sdk_library/module-lib/myjavalib-removed.txt", |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1485 | sdk_version: "module_current", |
| 1486 | }, |
| 1487 | } |
| 1488 | |
| 1489 | sdk_snapshot { |
| 1490 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1491 | visibility: ["//visibility:public"], |
Paul Duffin | 8f265b9 | 2020-04-28 14:13:56 +0100 | [diff] [blame] | 1492 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1493 | } |
| 1494 | `), |
| 1495 | checkAllCopyRules(` |
| 1496 | .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] | 1497 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1498 | .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] | 1499 | .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] | 1500 | .intermediates/myjavalib.stubs.source.system/android_common/metalava/myjavalib.stubs.source.system_api.txt -> sdk_library/system/myjavalib.txt |
| 1501 | .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] | 1502 | .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] | 1503 | .intermediates/myjavalib.stubs.source.module_lib/android_common/metalava/myjavalib.stubs.source.module_lib_api.txt -> sdk_library/module-lib/myjavalib.txt |
| 1504 | .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] | 1505 | `), |
| 1506 | checkMergeZips( |
| 1507 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1508 | ".intermediates/mysdk/common_os/tmp/sdk_library/system/myjavalib_stub_sources.zip", |
Paul Duffin | 6b836ba | 2020-05-13 19:19:49 +0100 | [diff] [blame] | 1509 | ".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] | 1510 | ), |
| 1511 | ) |
| 1512 | } |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1513 | |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1514 | func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1515 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1516 | sdk { |
| 1517 | name: "mysdk", |
| 1518 | java_sdk_libs: ["myjavalib"], |
| 1519 | } |
| 1520 | |
| 1521 | java_sdk_library { |
| 1522 | name: "myjavalib", |
| 1523 | apex_available: ["//apex_available:anyapex"], |
| 1524 | srcs: ["Test.java"], |
| 1525 | sdk_version: "current", |
| 1526 | public: { |
| 1527 | enabled: true, |
| 1528 | }, |
| 1529 | system_server: { |
| 1530 | enabled: true, |
| 1531 | }, |
| 1532 | } |
| 1533 | `) |
| 1534 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1535 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1536 | checkUnversionedAndroidBpContents(` |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1537 | // This is auto-generated. DO NOT EDIT. |
| 1538 | |
| 1539 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1540 | name: "myjavalib", |
| 1541 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1542 | visibility: ["//visibility:public"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1543 | apex_available: ["//apex_available:anyapex"], |
| 1544 | shared_library: true, |
| 1545 | public: { |
| 1546 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1547 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1548 | current_api: "sdk_library/public/myjavalib.txt", |
| 1549 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1550 | sdk_version: "current", |
| 1551 | }, |
| 1552 | system_server: { |
| 1553 | jars: ["sdk_library/system-server/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1554 | stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1555 | current_api: "sdk_library/system-server/myjavalib.txt", |
| 1556 | removed_api: "sdk_library/system-server/myjavalib-removed.txt", |
| 1557 | sdk_version: "system_server_current", |
| 1558 | }, |
| 1559 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1560 | `), |
| 1561 | checkVersionedAndroidBpContents(` |
| 1562 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1563 | |
| 1564 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1565 | name: "mysdk_myjavalib@current", |
| 1566 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1567 | visibility: ["//visibility:public"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1568 | apex_available: ["//apex_available:anyapex"], |
| 1569 | shared_library: true, |
| 1570 | public: { |
| 1571 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1572 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1573 | current_api: "sdk_library/public/myjavalib.txt", |
| 1574 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1575 | sdk_version: "current", |
| 1576 | }, |
| 1577 | system_server: { |
| 1578 | jars: ["sdk_library/system-server/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1579 | stub_srcs: ["sdk_library/system-server/myjavalib_stub_sources"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1580 | current_api: "sdk_library/system-server/myjavalib.txt", |
| 1581 | removed_api: "sdk_library/system-server/myjavalib-removed.txt", |
| 1582 | sdk_version: "system_server_current", |
| 1583 | }, |
| 1584 | } |
| 1585 | |
| 1586 | sdk_snapshot { |
| 1587 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1588 | visibility: ["//visibility:public"], |
Paul Duffin | 0c5bae5 | 2020-06-02 13:00:08 +0100 | [diff] [blame] | 1589 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1590 | } |
| 1591 | `), |
| 1592 | checkAllCopyRules(` |
| 1593 | .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] | 1594 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1595 | .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] | 1596 | .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] | 1597 | .intermediates/myjavalib.stubs.source.system_server/android_common/metalava/myjavalib.stubs.source.system_server_api.txt -> sdk_library/system-server/myjavalib.txt |
| 1598 | .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] | 1599 | `), |
| 1600 | checkMergeZips( |
| 1601 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1602 | ".intermediates/mysdk/common_os/tmp/sdk_library/system-server/myjavalib_stub_sources.zip", |
| 1603 | ), |
| 1604 | ) |
| 1605 | } |
| 1606 | |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1607 | func TestSnapshotWithJavaSdkLibrary_NamingScheme(t *testing.T) { |
Paul Duffin | 9ec86b1 | 2021-03-15 11:17:52 +0000 | [diff] [blame] | 1608 | result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, ` |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1609 | sdk { |
| 1610 | name: "mysdk", |
| 1611 | java_sdk_libs: ["myjavalib"], |
| 1612 | } |
| 1613 | |
| 1614 | java_sdk_library { |
| 1615 | name: "myjavalib", |
| 1616 | apex_available: ["//apex_available:anyapex"], |
| 1617 | srcs: ["Test.java"], |
| 1618 | sdk_version: "current", |
Paul Duffin | ee9ad5d | 2020-09-11 13:04:05 +0100 | [diff] [blame] | 1619 | naming_scheme: "default", |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1620 | public: { |
| 1621 | enabled: true, |
| 1622 | }, |
| 1623 | } |
| 1624 | `) |
| 1625 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1626 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1627 | checkUnversionedAndroidBpContents(` |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1628 | // This is auto-generated. DO NOT EDIT. |
| 1629 | |
| 1630 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1631 | name: "myjavalib", |
| 1632 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1633 | visibility: ["//visibility:public"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1634 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | ee9ad5d | 2020-09-11 13:04:05 +0100 | [diff] [blame] | 1635 | naming_scheme: "default", |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1636 | shared_library: true, |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1637 | public: { |
| 1638 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1639 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1640 | current_api: "sdk_library/public/myjavalib.txt", |
| 1641 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1642 | sdk_version: "current", |
| 1643 | }, |
| 1644 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1645 | `), |
| 1646 | checkVersionedAndroidBpContents(` |
| 1647 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1648 | |
| 1649 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1650 | name: "mysdk_myjavalib@current", |
| 1651 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1652 | visibility: ["//visibility:public"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1653 | apex_available: ["//apex_available:anyapex"], |
Paul Duffin | ee9ad5d | 2020-09-11 13:04:05 +0100 | [diff] [blame] | 1654 | naming_scheme: "default", |
Paul Duffin | d7eb1c2 | 2020-05-26 20:57:10 +0100 | [diff] [blame] | 1655 | shared_library: true, |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1656 | public: { |
| 1657 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1658 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1659 | current_api: "sdk_library/public/myjavalib.txt", |
| 1660 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1661 | sdk_version: "current", |
| 1662 | }, |
| 1663 | } |
| 1664 | |
| 1665 | sdk_snapshot { |
| 1666 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1667 | visibility: ["//visibility:public"], |
Paul Duffin | f7a6433 | 2020-05-13 16:54:55 +0100 | [diff] [blame] | 1668 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1669 | } |
| 1670 | `), |
| 1671 | checkAllCopyRules(` |
Paul Duffin | ee9ad5d | 2020-09-11 13:04:05 +0100 | [diff] [blame] | 1672 | .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] | 1673 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1674 | .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] | 1675 | `), |
| 1676 | checkMergeZips( |
| 1677 | ".intermediates/mysdk/common_os/tmp/sdk_library/public/myjavalib_stub_sources.zip", |
| 1678 | ), |
| 1679 | ) |
| 1680 | } |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1681 | |
| 1682 | func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) { |
Paul Duffin | db462dd | 2021-03-21 22:01:55 +0000 | [diff] [blame] | 1683 | result := android.GroupFixturePreparers( |
| 1684 | prepareForSdkTestWithJavaSdkLibrary, |
| 1685 | android.FixtureAddFile("docs/known_doctags", nil), |
| 1686 | ).RunTestWithBp(t, ` |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1687 | sdk { |
| 1688 | name: "mysdk", |
| 1689 | java_sdk_libs: ["myjavalib"], |
| 1690 | } |
| 1691 | |
| 1692 | java_sdk_library { |
| 1693 | name: "myjavalib", |
| 1694 | srcs: ["Test.java"], |
| 1695 | sdk_version: "current", |
| 1696 | public: { |
| 1697 | enabled: true, |
| 1698 | }, |
| 1699 | doctag_files: ["docs/known_doctags"], |
| 1700 | } |
| 1701 | |
| 1702 | filegroup { |
| 1703 | name: "mygroup", |
| 1704 | srcs: [":myjavalib{.doctags}"], |
| 1705 | } |
| 1706 | `) |
| 1707 | |
Paul Duffin | 36474d3 | 2021-03-12 12:19:43 +0000 | [diff] [blame] | 1708 | CheckSnapshot(t, result, "mysdk", "", |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1709 | checkUnversionedAndroidBpContents(` |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1710 | // This is auto-generated. DO NOT EDIT. |
| 1711 | |
| 1712 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1713 | name: "myjavalib", |
| 1714 | prefer: false, |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1715 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1716 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1717 | shared_library: true, |
| 1718 | doctag_files: ["doctags/docs/known_doctags"], |
| 1719 | public: { |
| 1720 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1721 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1722 | current_api: "sdk_library/public/myjavalib.txt", |
| 1723 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1724 | sdk_version: "current", |
| 1725 | }, |
| 1726 | } |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1727 | `), |
| 1728 | checkVersionedAndroidBpContents(` |
| 1729 | // This is auto-generated. DO NOT EDIT. |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1730 | |
| 1731 | java_sdk_library_import { |
Paul Duffin | e138188 | 2021-04-16 17:05:10 +0100 | [diff] [blame] | 1732 | name: "mysdk_myjavalib@current", |
| 1733 | sdk_member_name: "myjavalib", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1734 | visibility: ["//visibility:public"], |
Martin Stjernholm | 1e04109 | 2020-11-03 00:11:09 +0000 | [diff] [blame] | 1735 | apex_available: ["//apex_available:platform"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1736 | shared_library: true, |
| 1737 | doctag_files: ["doctags/docs/known_doctags"], |
| 1738 | public: { |
| 1739 | jars: ["sdk_library/public/myjavalib-stubs.jar"], |
Paul Duffin | ab5ac8f | 2020-11-18 16:37:35 +0000 | [diff] [blame] | 1740 | stub_srcs: ["sdk_library/public/myjavalib_stub_sources"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1741 | current_api: "sdk_library/public/myjavalib.txt", |
| 1742 | removed_api: "sdk_library/public/myjavalib-removed.txt", |
| 1743 | sdk_version: "current", |
| 1744 | }, |
| 1745 | } |
| 1746 | |
| 1747 | sdk_snapshot { |
| 1748 | name: "mysdk@current", |
Paul Duffin | d99d997 | 2020-09-29 16:00:55 +0100 | [diff] [blame] | 1749 | visibility: ["//visibility:public"], |
Paul Duffin | a2ae7e0 | 2020-09-11 11:55:00 +0100 | [diff] [blame] | 1750 | java_sdk_libs: ["mysdk_myjavalib@current"], |
| 1751 | } |
| 1752 | `), |
| 1753 | checkAllCopyRules(` |
| 1754 | .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] | 1755 | .intermediates/myjavalib.stubs.source/android_common/metalava/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt |
| 1756 | .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] | 1757 | docs/known_doctags -> doctags/docs/known_doctags |
| 1758 | `), |
| 1759 | ) |
| 1760 | } |