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