xref: /aosp_15_r20/external/guava/Android.bp (revision fb5080426417cab6bd44d0ed3f37e47d42859579)
1// Copyright (C) 2010 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 {
16    default_applicable_licenses: ["external_guava_license"],
17}
18
19// Added automatically by a large-scale-change that took the approach of
20// 'apply every license found to every target'. While this makes sure we respect
21// every license restriction, it may not be entirely correct.
22//
23// e.g. GPL in an MIT project might only apply to the contrib/ directory.
24//
25// Please consider splitting the single license below into multiple licenses,
26// taking care not to lose any license_kind information, and overriding the
27// default license using the 'licenses: [...]' property on targets as needed.
28//
29// For unused files, consider creating a 'fileGroup' with "//visibility:private"
30// to attach the license to, and including a comment whether the files may be
31// used in the current project.
32//
33// large-scale-change included anything that looked like it might be a license
34// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
35//
36// Please consider removing redundant or irrelevant files from 'license_text:'.
37// See: http://go/android-license-faq
38license {
39    name: "external_guava_license",
40    visibility: [":__subpackages__"],
41    license_kinds: [
42        "SPDX-license-identifier-Apache-2.0",
43        "SPDX-license-identifier-CC0-1.0",
44        "legacy_unencumbered",
45    ],
46    license_text: [
47        "NOTICE",
48    ],
49}
50
51// Instructions for updating the guava version
52//
53// Guava updates must be merged to AOSP first. Make sure you are not using a
54// shallow copy of the Android tree to run the following instructions:
55//
56// 1. File a bug to generate a branch with the version you want to update to.
57//    You can use b/209469232 as starting point. This step will generate an
58//    upstream branch.
59// 2. Create your work branch using `repo start <your_branch_name>`.
60// 3. Fetch the upstream branch using `git fetch aosp <upstream_branch_name>`.
61// 4. Run the merge using `git merge FETCH_HEAD`.
62// 5. Update the METADATA file in this directory to reflect your changes.
63//
64// Note: When running `repo upload` to generate the CL, repo will produce a
65// warning about the number of commits you are trying to upload. This is
66// expected, and you can accept safely (a single gerrit "merge commit" change
67// will be created).
68
69java_library {
70    name: "guava",
71    host_supported: true,
72    hostdex: true,
73    sdk_version: "core_current",
74    target: {
75        android: {
76            static_libs: ["guava-android"],
77        },
78        host: {
79            static_libs: ["guava-jre"],
80        },
81        windows: {
82            static_libs: ["guava-jre"],
83            enabled: true,
84        },
85    },
86    apex_available: [
87        "//apex_available:platform",
88        "//apex_available:anyapex",
89    ],
90}
91
92java_library {
93    name: "guava-both",
94    host_supported: true,
95    sdk_version: "core_current",
96    srcs: ["futures/failureaccess/**/*.java"],
97    static_libs: ["jsr305"],
98    libs: [
99        "guava-android-annotation-stubs",
100        "error_prone_annotations",
101    ],
102    java_version: "1.8",
103    target: {
104        windows: {
105            enabled: true,
106        },
107    },
108}
109
110java_library_host {
111    name: "guava-jre",
112    srcs: ["guava/src/**/*.java"],
113    static_libs: ["guava-both"],
114    libs: [
115        "guava-android-annotation-stubs",
116        "error_prone_annotations",
117    ],
118    java_version: "1.8",
119    errorprone: {
120        javacflags: [
121            "-Xep:NoCanIgnoreReturnValueOnClasses:WARN",
122        ],
123    },
124    target: {
125        windows: {
126            enabled: true,
127        },
128    },
129}
130
131java_library_host {
132    name: "guava-testlib",
133    srcs: ["guava-testlib/src/**/*.java"],
134    libs: [
135        "error_prone_annotations",
136        "guava",
137        "guava-android-annotation-stubs",
138        "jsr305",
139        "junit",
140    ],
141    java_version: "1.8",
142    errorprone: {
143        javacflags: [
144            "-Xep:ReturnValueIgnored:WARN",
145            "-Xep:BareDotMetacharacter:WARN",
146        ],
147    },
148}
149
150// Guava for Android can't compile against an Android bootclasspath, compile
151// it for the host and then use it on the device.  It uses reflection to
152// prevent calling into methods that don't exist on Android.
153java_library_host {
154    name: "guava-android-host",
155    srcs: ["android/guava/src/**/*.java"],
156    static_libs: ["guava-both"],
157    libs: [
158        "guava-android-annotation-stubs",
159        "error_prone_annotations",
160    ],
161    java_version: "1.8",
162    errorprone: {
163        javacflags: [
164            "-Xep:NoCanIgnoreReturnValueOnClasses:WARN",
165        ],
166    },
167    target: {
168        windows: {
169            enabled: true,
170        },
171    },
172}
173
174java_host_for_device {
175    name: "guava-android",
176    libs: ["guava-android-host"],
177}
178
179// Compile dummy implementations of annotations used by guava but not
180// present in the Android tree.
181// 30 may not be the lowest min_sdk_version, but the min sdk version
182// for permission controller.
183java_library {
184    name: "guava-android-annotation-stubs",
185    host_supported: true,
186    // b/267831518: Pin tradefed and dependencies to Java 11.
187    java_version: "11",
188    sdk_version: "core_current",
189    min_sdk_version: "30",
190    srcs: ["android-annotation-stubs/src/**/*.java"],
191    apex_available: [
192        "//apex_available:platform",
193        "//apex_available:anyapex",
194    ],
195    target: {
196        windows: {
197            enabled: true,
198        },
199    },
200    is_stubs_module: true,
201}
202
203// Compile guava testlib
204java_library_host {
205    name: "guava-android-testlib-host",
206    srcs: ["android/guava-testlib/src/**/*.java"],
207    libs: [
208        "error_prone_annotations",
209        "guava-android-annotation-stubs",
210        "guava-android-host",
211        "junit",
212    ],
213    java_version: "1.8",
214    errorprone: {
215        javacflags: [
216            "-Xep:ReturnValueIgnored:WARN",
217            "-Xep:BareDotMetacharacter:WARN",
218        ],
219    },
220}
221
222java_host_for_device {
223    name: "guava-android-testlib",
224    libs: ["guava-android-testlib-host"],
225}
226