blob: 754f01961ed427d55e7352f1cee6f3c7b31dc4cd [file] [log] [blame]
Paul Duffine96108d2021-05-06 16:39:27 +01001// 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
15package sdk
16
17import (
18 "testing"
19
20 "android/soong/android"
21)
22
23func 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", "",
Paul Duffinb01ac4b2022-05-24 20:10:05 +000063 checkAndroidBpContents(`
Paul Duffine96108d2021-05-06 16:39:27 +010064// This is auto-generated. DO NOT EDIT.
65
Paul Duffin62131702021-05-07 01:10:01 +010066package {
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
Spandan Dasa5e26d32024-03-06 14:04:36 +000072apex_contributions_defaults {
73 name: "mysdk.contributions",
74 contents: ["prebuilt_myjavalib"],
75}
76
Paul Duffine96108d2021-05-06 16:39:27 +010077java_import {
78 name: "myjavalib",
79 prefer: false,
80 visibility: ["//visibility:public"],
81 apex_available: ["//apex_available:platform"],
Paul Duffinb0bb3762021-05-06 16:48:05 +010082 licenses: ["mysdk_mylicense"],
Paul Duffine96108d2021-05-06 16:39:27 +010083 jars: ["java/myjavalib.jar"],
84}
Paul Duffinb0bb3762021-05-06 16:48:05 +010085
86license {
87 name: "mysdk_mylicense",
88 visibility: ["//visibility:private"],
89 license_kinds: [
90 "SPDX-license-identifier-Apache-2.0",
91 "legacy_unencumbered",
92 ],
93 license_text: [
94 "licenses/NOTICE1",
95 "licenses/NOTICE2",
96 ],
97}
98 `),
Paul Duffine96108d2021-05-06 16:39:27 +010099 checkAllCopyRules(`
100.intermediates/myjavalib/android_common/turbine-combined/myjavalib.jar -> java/myjavalib.jar
Paul Duffinb0bb3762021-05-06 16:48:05 +0100101NOTICE1 -> licenses/NOTICE1
102NOTICE2 -> licenses/NOTICE2
Paul Duffine96108d2021-05-06 16:39:27 +0100103`),
104 )
105}