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 | |
Paul Duffin | 6213170 | 2021-05-07 01:10:01 +0100 | [diff] [blame^] | 66 | package { |
| 67 | // A default list here prevents the license LSC from adding its own list which would |
| 68 | // be unnecessary as every module in the sdk already has its own licenses property. |
| 69 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 70 | } |
| 71 | |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 72 | java_import { |
| 73 | name: "myjavalib", |
| 74 | prefer: false, |
| 75 | visibility: ["//visibility:public"], |
| 76 | apex_available: ["//apex_available:platform"], |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame] | 77 | licenses: ["mysdk_mylicense"], |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 78 | jars: ["java/myjavalib.jar"], |
| 79 | } |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame] | 80 | |
| 81 | license { |
| 82 | name: "mysdk_mylicense", |
| 83 | visibility: ["//visibility:private"], |
| 84 | license_kinds: [ |
| 85 | "SPDX-license-identifier-Apache-2.0", |
| 86 | "legacy_unencumbered", |
| 87 | ], |
| 88 | license_text: [ |
| 89 | "licenses/NOTICE1", |
| 90 | "licenses/NOTICE2", |
| 91 | ], |
| 92 | } |
| 93 | `), |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 94 | checkVersionedAndroidBpContents(` |
| 95 | // This is auto-generated. DO NOT EDIT. |
| 96 | |
Paul Duffin | 6213170 | 2021-05-07 01:10:01 +0100 | [diff] [blame^] | 97 | package { |
| 98 | // A default list here prevents the license LSC from adding its own list which would |
| 99 | // be unnecessary as every module in the sdk already has its own licenses property. |
| 100 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 101 | } |
| 102 | |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 103 | java_import { |
| 104 | name: "mysdk_myjavalib@current", |
| 105 | sdk_member_name: "myjavalib", |
| 106 | visibility: ["//visibility:public"], |
| 107 | apex_available: ["//apex_available:platform"], |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame] | 108 | licenses: ["mysdk_mylicense@current"], |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 109 | jars: ["java/myjavalib.jar"], |
| 110 | } |
| 111 | |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame] | 112 | license { |
| 113 | name: "mysdk_mylicense@current", |
| 114 | sdk_member_name: "mylicense", |
| 115 | visibility: ["//visibility:private"], |
| 116 | license_kinds: [ |
| 117 | "SPDX-license-identifier-Apache-2.0", |
| 118 | "legacy_unencumbered", |
| 119 | ], |
| 120 | license_text: [ |
| 121 | "licenses/NOTICE1", |
| 122 | "licenses/NOTICE2", |
| 123 | ], |
| 124 | } |
| 125 | |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 126 | sdk_snapshot { |
| 127 | name: "mysdk@current", |
| 128 | visibility: ["//visibility:public"], |
| 129 | java_header_libs: ["mysdk_myjavalib@current"], |
| 130 | } |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame] | 131 | `), |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 132 | checkAllCopyRules(` |
| 133 | .intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar |
Paul Duffin | b0bb376 | 2021-05-06 16:48:05 +0100 | [diff] [blame] | 134 | NOTICE1 -> licenses/NOTICE1 |
| 135 | NOTICE2 -> licenses/NOTICE2 |
Paul Duffin | e96108d | 2021-05-06 16:39:27 +0100 | [diff] [blame] | 136 | `), |
| 137 | ) |
| 138 | } |