Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 1 | // Copyright (C) 2021 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" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | ) |
| 22 | |
| 23 | func TestSnapshotWithPackageDefaultLicense(t *testing.T) { |
| 24 | result := android.GroupFixturePreparers( |
| 25 | prepareForSdkTestWithJava, |
| 26 | android.PrepareForTestWithLicenses, |
| 27 | android.PrepareForTestWithLicenseDefaultModules, |
| 28 | android.MockFS{ |
| 29 | "NOTICE1": nil, |
| 30 | "NOTICE2": nil, |
| 31 | }.AddToFixture(), |
| 32 | ).RunTestWithBp(t, ` |
| 33 | package { |
| 34 | default_applicable_licenses: ["mylicense"], |
| 35 | } |
| 36 | |
| 37 | license { |
| 38 | name: "mylicense", |
| 39 | license_kinds: [ |
| 40 | "SPDX-license-identifier-Apache-2.0", |
| 41 | "legacy_unencumbered", |
| 42 | ], |
| 43 | license_text: [ |
| 44 | "NOTICE1", |
| 45 | "NOTICE2", |
| 46 | ], |
| 47 | } |
| 48 | |
| 49 | sdk { |
| 50 | name: "mysdk", |
| 51 | java_header_libs: ["myjavalib"], |
| 52 | } |
| 53 | |
| 54 | java_library { |
| 55 | name: "myjavalib", |
| 56 | srcs: ["Test.java"], |
| 57 | system_modules: "none", |
| 58 | sdk_version: "none", |
| 59 | } |
| 60 | `) |
| 61 | |
| 62 | CheckSnapshot(t, result, "mysdk", "", |
| 63 | checkUnversionedAndroidBpContents(` |
| 64 | // This is auto-generated. DO NOT EDIT. |
| 65 | |
| 66 | java_import { |
| 67 | name: "myjavalib", |
| 68 | prefer: false, |
| 69 | visibility: ["//visibility:public"], |
| 70 | apex_available: ["//apex_available:platform"], |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame^] | 71 | licenses: ["mysdk_mylicense"], |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 72 | jars: ["java/myjavalib.jar"], |
| 73 | } |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame^] | 74 | |
| 75 | license { |
| 76 | name: "mysdk_mylicense", |
| 77 | visibility: ["//visibility:private"], |
| 78 | license_kinds: [ |
| 79 | "SPDX-license-identifier-Apache-2.0", |
| 80 | "legacy_unencumbered", |
| 81 | ], |
| 82 | license_text: [ |
| 83 | "licenses/NOTICE1", |
| 84 | "licenses/NOTICE2", |
| 85 | ], |
| 86 | } |
| 87 | `), |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 88 | checkVersionedAndroidBpContents(` |
| 89 | // This is auto-generated. DO NOT EDIT. |
| 90 | |
| 91 | java_import { |
| 92 | name: "mysdk_myjavalib@current", |
| 93 | sdk_member_name: "myjavalib", |
| 94 | visibility: ["//visibility:public"], |
| 95 | apex_available: ["//apex_available:platform"], |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame^] | 96 | licenses: ["mysdk_mylicense@current"], |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 97 | jars: ["java/myjavalib.jar"], |
| 98 | } |
| 99 | |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame^] | 100 | license { |
| 101 | name: "mysdk_mylicense@current", |
| 102 | sdk_member_name: "mylicense", |
| 103 | visibility: ["//visibility:private"], |
| 104 | license_kinds: [ |
| 105 | "SPDX-license-identifier-Apache-2.0", |
| 106 | "legacy_unencumbered", |
| 107 | ], |
| 108 | license_text: [ |
| 109 | "licenses/NOTICE1", |
| 110 | "licenses/NOTICE2", |
| 111 | ], |
| 112 | } |
| 113 | |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 114 | sdk_snapshot { |
| 115 | name: "mysdk@current", |
| 116 | visibility: ["//visibility:public"], |
| 117 | java_header_libs: ["mysdk_myjavalib@current"], |
| 118 | } |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame^] | 119 | `), |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 120 | checkAllCopyRules(` |
| 121 | .intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame^] | 122 | NOTICE1 -> licenses/NOTICE1 |
| 123 | NOTICE2 -> licenses/NOTICE2 |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 124 | `), |
| 125 | ) |
| 126 | } |