blob: 824626aaf42a35ee43c3d29715a23865c603a6da [file] [log] [blame]
Colin Crossaf0b54c2017-09-27 17:22:32 -07001// Copyright (C) 2007 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//
Neil Fuller77e3f3b2018-10-19 10:22:32 +010016// Definitions for building the Android core library and associated tests.
Colin Crossaf0b54c2017-09-27 17:22:32 -070017//
18
Neil Fuller77e3f3b2018-10-19 10:22:32 +010019// The Android core library provides low-level APIs for use by the rest of the
20// Android software stack. It is made up of various parts, some of which can be
21// found in libcore/ and other parts that can be found in various external/
22// directories. See the "core-system-modules" definition for the parts.
23
Neil Fullercf756882018-08-28 18:42:22 +010024// libcore has some sub-directories that follow a common structure:
25// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni,
26// support, xml, xmlpull.
Colin Crossaf0b54c2017-09-27 17:22:32 -070027//
Neil Fullercf756882018-08-28 18:42:22 +010028// The structure of these is generally:
Colin Crossaf0b54c2017-09-27 17:22:32 -070029//
30// src/
31// main/ # To be shipped on every device.
32// java/ # Java source for library code.
Neil Fullercf756882018-08-28 18:42:22 +010033// native/ # C/C++ source for library code.
Colin Crossaf0b54c2017-09-27 17:22:32 -070034// resources/ # Support files.
35// test/ # Built only on demand, for testing.
36// java/ # Java source for tests.
Neil Fullercf756882018-08-28 18:42:22 +010037// native/ # C/C++ source for tests (rare).
Colin Crossaf0b54c2017-09-27 17:22:32 -070038// resources/ # Support files.
39//
Neil Fullercf756882018-08-28 18:42:22 +010040// All subdirectories are optional.
Colin Crossaf0b54c2017-09-27 17:22:32 -070041
42build = [
43 "openjdk_java_files.bp",
44 "non_openjdk_java_files.bp",
45]
46
47// The Java files and their associated resources.
Tobias Thierer79eea262019-08-01 14:05:11 +010048filegroup {
49 name: "core-luni-resources",
50 visibility: [
51 "//libcore:__subpackages__",
52 ],
53 path: "luni/src/main/java/",
54 srcs: [
55 "luni/src/main/java/libcore/net/mime.types",
56 "luni/src/main/java/libcore/net/android.mime.types",
57 "luni/src/main/java/libcore/net/mime.types.README",
58 "luni/src/main/java/java/util/logging/logging.properties",
59 "luni/src/main/java/java/security/security.properties",
60 ],
61}
62
63filegroup {
64 name: "core-ojluni-resources",
65 visibility: [
66 "//libcore:__subpackages__",
67 ],
68 path: "ojluni/src/main/resources/",
69 srcs: [
70 "ojluni/src/main/resources/**/*",
71 ],
72}
73
74core_resources = [
75 ":core-luni-resources",
76 ":core-ojluni-resources",
Colin Crossaf0b54c2017-09-27 17:22:32 -070077]
78
Neil Fuller866ed4a2018-09-06 12:05:46 +010079// The source files that go into core-oj.
80filegroup {
81 name: "core_oj_java_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +010082 visibility: [
83 "//libcore:__subpackages__",
84 ],
Neil Fuller866ed4a2018-09-06 12:05:46 +010085 srcs: [":openjdk_java_files"],
86}
87
Neil Fullere32e2e12019-02-26 11:48:30 +000088// OpenJDK source is not annotated with @hide so we need this separate
Neil Fuller866ed4a2018-09-06 12:05:46 +010089// filegroup for just the parts that contribute to the API.
90filegroup {
91 name: "core_oj_api_files",
92 srcs: [":openjdk_javadoc_files"],
93}
94
95// The source files that go into core-libart.
96filegroup {
97 name: "core_libart_java_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +010098 visibility: [
99 "//libcore:__subpackages__",
100 ],
Neil Fuller866ed4a2018-09-06 12:05:46 +0100101 srcs: [
102 ":non_openjdk_java_files",
103 ":android_icu4j_src_files",
104 ],
105}
106
Neil Fullere32e2e12019-02-26 11:48:30 +0000107// Some parts of libart are not annotated with @hide so we need this separate
Neil Fuller866ed4a2018-09-06 12:05:46 +0100108// filegroup for just the parts that contribute to the API.
109filegroup {
110 name: "core_libart_api_files",
111 srcs: [
112 ":non_openjdk_javadoc_files",
113 ":android_icu4j_src_files",
114 ],
115}
116
Neil Fullere32e2e12019-02-26 11:48:30 +0000117// The set of files for the core library that have been marked up with @hide
118// for the public SDK APIs. Used from frameworks/base/ to indicate the source
119// files for inclusion in the public SDK docs.
120filegroup {
121 name: "core_public_api_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100122 visibility: [
123 "//frameworks/base",
124 ],
Neil Fullere32e2e12019-02-26 11:48:30 +0000125 srcs: [
126 ":core_oj_api_files",
127 ":core_libart_api_files",
128 ":conscrypt_public_api_files",
129 ],
130}
131
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100132// The set of files for the core library that have been marked up with @hide and
133// API-related annotations. Note that this includes the intra-core and
134// core-platform APIs as well as the public APIs.
135//
Neil Fullere32e2e12019-02-26 11:48:30 +0000136// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are
137// annotated by applying annotations to the .annotated.java stubs files in
138// ojluni/annotated/mmodules and rather than in the original source. See the comments
139// in openjdk_java_files.bp for more details.
Neil Fuller866ed4a2018-09-06 12:05:46 +0100140filegroup {
141 name: "core_api_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100142 visibility: [
143 "//libcore:__subpackages__",
144 ],
Neil Fuller866ed4a2018-09-06 12:05:46 +0100145 srcs: [
Neil Fullerd129bc92018-09-26 11:12:58 +0100146 ":apache-xml_api_files",
Neil Fullera77f7102018-09-21 19:04:41 +0100147 ":bouncycastle_java_files",
Neil Fuller603e1a72018-09-25 11:55:41 +0100148 ":conscrypt_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100149 ":core_oj_api_files",
150 ":core_libart_api_files",
Neil Fuller641d5f92018-09-24 15:40:39 +0100151 ":okhttp_api_files",
Pete Gillinc9935b62018-09-25 14:42:40 +0100152 ":openjdk_mmodule_extra_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100153 ],
154}
155
Colin Crossaf0b54c2017-09-27 17:22:32 -0700156java_defaults {
157 name: "libcore_java_defaults",
158 javacflags: [
159 //"-Xlint:all",
160 //"-Xlint:-serial,-deprecation,-unchecked",
161 ],
162 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800163 errorprone: {
164 javacflags: [
Paul Duffinc31f6bb2019-05-15 12:32:44 +0100165 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
166 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800167 ],
168 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700169}
170
171//
172// Build for the target (device).
173//
174
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100175// Visibility of core-all* build modules; we restrict visibility of core-all deliberately to
176// a small set of build modules that the core library team control. See core-all-system-modules
177// for more details.
178core_all_visibility = [
179 "//external/apache-harmony:__subpackages__",
180 "//external/apache-xml",
181 "//external/bouncycastle",
182 "//external/conscrypt",
183 "//external/icu/android_icu4j",
184 "//external/okhttp",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100185 "//libcore:__subpackages__",
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100186]
187
Tobias Thierer52331642019-05-29 12:11:39 +0000188// A target used to bootstrap compilation for the core library.
189// See core-all-system-modules for more details.
190java_library {
191 name: "core-all",
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100192 visibility: core_all_visibility,
Tobias Thierer52331642019-05-29 12:11:39 +0000193 defaults: ["libcore_java_defaults"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700194
195 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100196 ":core_oj_java_files",
197 ":core_libart_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700198 ":openjdk_lambda_stub_files",
Pete Gillin54035812019-05-08 15:09:39 +0100199 ":openjdk_generated_annotation_stub_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700200 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700201
Paul Duffin83c25382019-06-07 14:10:49 +0100202 sdk_version: "none",
Colin Crossec80f4f2018-08-15 21:17:11 -0700203 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700204 openjdk9: {
205 srcs: ["luni/src/module/java/module-info.java"],
206 javacflags: ["--patch-module=java.base=."],
207 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700208
Tobias Thierer79eea262019-08-01 14:05:11 +0100209 java_resources: core_resources,
Victor Chang7fef4052018-09-25 14:12:03 +0100210 static_libs: ["android_icu4j_resources_lib"],
Tobias Thiererde991232018-03-07 15:10:46 +0000211 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700212
Colin Crossaf0b54c2017-09-27 17:22:32 -0700213 installable: false,
214}
215
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100216// A system modules definition for use by core library targets only. It only
217// contains the core-all jar, which contains the classes that end up in core-oj,
218// core-libart as well as the lambda stubs needed to compile Java lambda code.
219// It does not contain other parts of core library like conscrypt, bouncycastle,
220// etc. This system_modules definition is used to bootstrap compilation for
221// other parts of the core library like core-oj, core-libart, conscrypt,
222// bouncycastle, etc.
223//
224// If you want to compile against the entire core library implementation, for
225// example to build core library tests, see "core-system-modules" instead.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700226java_system_modules {
227 name: "core-all-system-modules",
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100228 visibility: core_all_visibility,
Colin Crossa4d9fc42017-09-29 18:04:37 -0700229 libs: ["core-all"],
230}
231
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100232// Contains the parts of core library associated with OpenJDK.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700233java_library {
234 name: "core-oj",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000235 visibility: [
236 "//art/build/apex",
237 "//external/wycheproof",
Paul Duffin94f70232019-05-22 16:22:29 +0100238 "//libcore/benchmarks",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000239 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700240 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700241 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700242 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700243
Neil Fuller866ed4a2018-09-06 12:05:46 +0100244 srcs: [":core_oj_java_files"],
Tobias Thierer79eea262019-08-01 14:05:11 +0100245 java_resources: core_resources,
Colin Crossec80f4f2018-08-15 21:17:11 -0700246
Paul Duffin83c25382019-06-07 14:10:49 +0100247 sdk_version: "none",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700248 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700249 system_modules: "core-all-system-modules",
250 openjdk9: {
251 javacflags: ["--patch-module=java.base=."],
252 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700253
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000254 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000255 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000256 "java.lang.Class",
257 "java.lang.Long",
258 "java.lang.Number",
259 "java.lang.Object",
260 "java.lang.String",
261 "java.lang.invoke.MethodHandle",
262 "java.lang.ref.Reference",
263 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000264 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000265 "java.util.HashMap",
266 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000267 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000268 ],
269 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700270
271 notice: "ojluni/NOTICE",
272
Colin Crossaf0b54c2017-09-27 17:22:32 -0700273}
274
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100275// Contains parts of core library not associated with OpenJDK. Contains not
276// just java.*, javax.* code but also android.icu.*, android.system.* and
277// various internal libcore.* packages.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700278java_library {
279 name: "core-libart",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000280 visibility: [
281 "//art/build/apex",
282 "//external/robolectric-shadows",
283 "//external/wycheproof",
Paul Duffin94f70232019-05-22 16:22:29 +0100284 "//libcore/benchmarks",
Colin Crossf0ef6252019-05-31 08:26:47 -0700285 "//frameworks/layoutlib",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000286 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700287 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700288 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700289 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700290
Neil Fuller866ed4a2018-09-06 12:05:46 +0100291 srcs: [":core_libart_java_files"],
Victor Chang7fef4052018-09-25 14:12:03 +0100292 static_libs: ["android_icu4j_resources_lib"],
Tobias Thiererde991232018-03-07 15:10:46 +0000293 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700294
Paul Duffin83c25382019-06-07 14:10:49 +0100295 sdk_version: "none",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700296 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700297 system_modules: "core-all-system-modules",
298 openjdk9: {
299 javacflags: ["--patch-module=java.base=."],
300 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700301
Pete Gillin80ebe872018-02-13 15:21:20 +0000302 jacoco: {
303 exclude_filter: [
304 "java.lang.DexCache",
305 "dalvik.system.ClassExt",
306 ],
307 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700308
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700309 target: {
310 hostdex: {
311 required: [
Neil Fuller53c5f032019-06-05 13:47:39 +0100312 // Files used to simulate the /system, runtime APEX and tzdata
313 // APEX dir structure on host.
314 "icu_tzdata.dat_host_tzdata_apex",
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700315 "tzdata_host",
Neil Fuller53c5f032019-06-05 13:47:39 +0100316 "tzdata_host_tzdata_apex",
Neil Fuller53c5f032019-06-05 13:47:39 +0100317 "tzlookup.xml_host_tzdata_apex",
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700318 "tz_version_host",
Neil Fuller53c5f032019-06-05 13:47:39 +0100319 "tz_version_host_tzdata_apex",
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700320 ],
321 },
322 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700323}
324
Paul Duffin7bb8d232018-10-23 11:48:38 +0100325// Provided solely to contribute information about which hidden parts of the
326// core-oj API are used by apps.
Paul Duffinc6bf27b2019-05-15 14:41:00 +0100327//
328// The build system determines that this library provides hiddenapi information
329// for the core-oj bootjar because its name is of the form <x>-hiddenapi, where
330// <x> is the name of a boot jar. That triggers the generation of a flags.csv
331// file which encapsulates information extracted from the UnsupportedAppUsage
332// annotations in the dex. The information from that file is then encoded into
333// the core-oj file.
334//
335// Usually, e.g. for core-libart, the UnsupportedAppUsage annotations are
336// added to the source that is compiled directly into the bootjar and the build
337// system extracts the information about UnsupportedAppUsage directly from
338// there.
339//
340// This approach of having separate annotated source and a separate build
341// target was taken for ojluni to avoid having to maintain local patches in the
342// ojluni source for UnsupportedAppUsage annotations as that would make it more
343// difficult to pull down changes from upstream.
344//
Paul Duffin7bb8d232018-10-23 11:48:38 +0100345java_library {
346 name: "core-oj-hiddenapi",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000347 // Do not allow this to be accessed from outside this directory.
348 visibility: ["//visibility:private"],
Paul Duffin7bb8d232018-10-23 11:48:38 +0100349 defaults: ["libcore_java_defaults"],
350 compile_dex: true,
351
352 srcs: [":openjdk_hiddenapi_javadoc_files"],
353
Paul Duffin83c25382019-06-07 14:10:49 +0100354 sdk_version: "none",
Paul Duffin7bb8d232018-10-23 11:48:38 +0100355 libs: ["core-all"],
356 system_modules: "core-all-system-modules",
357 openjdk9: {
358 javacflags: ["--patch-module=java.base=."],
359 },
360}
361
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100362//
363// Guaranteed unstripped versions of core-oj and core-libart.
364//
Colin Cross3c6c2e22017-10-18 13:24:52 -0700365// The build system may or may not strip the core-oj and core-libart jars,
366// but these will not be stripped. See b/24535627.
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100367//
368
Colin Cross3c6c2e22017-10-18 13:24:52 -0700369java_library {
370 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700371 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700372 static_libs: ["core-oj"],
Paul Duffin83c25382019-06-07 14:10:49 +0100373 sdk_version: "none",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700374 libs: ["core-all"],
375 system_modules: "core-all-system-modules",
376 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800377 dex_preopt: {
378 enabled: false,
379 },
Tobias Thiererde991232018-03-07 15:10:46 +0000380 java_version: "1.9",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700381 notice: "ojluni/NOTICE",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700382}
383
384java_library {
385 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700386 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700387 static_libs: ["core-libart"],
Paul Duffin83c25382019-06-07 14:10:49 +0100388 sdk_version: "none",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700389 libs: ["core-all"],
390 system_modules: "core-all-system-modules",
391 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800392 dex_preopt: {
393 enabled: false,
394 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700395 notice: "ojluni/NOTICE",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700396}
397
Tobias Thierere0f8b312018-10-23 23:12:30 +0100398java_defaults {
399 name: "core_lambda_stubs_defaults",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700400 defaults: ["libcore_java_defaults"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100401 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700402
Paul Duffin83c25382019-06-07 14:10:49 +0100403 sdk_version: "none",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700404 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700405 system_modules: "core-all-system-modules",
406 openjdk9: {
407 javacflags: ["--patch-module=java.base=."],
408 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700409
410 notice: "ojluni/NOTICE",
411
412 installable: false,
413 include_srcs: true,
414}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700415
Tobias Thierere0f8b312018-10-23 23:12:30 +0100416// Creates a jar that exists to satisfy javac when compiling source code that
417// contains lambdas. This contains all classes / methods required by javac
418// when generating invoke-dynamic lambda implementation code, even those that
419// are also in the public SDK API from API level 26 onwards.
420java_library {
421 name: "core-lambda-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100422 visibility: ["//visibility:public"],
Tobias Thierere0f8b312018-10-23 23:12:30 +0100423 defaults: ["core_lambda_stubs_defaults"],
424 srcs: [
425 ":openjdk_lambda_stub_files",
426 ":openjdk_lambda_duplicate_stub_files",
427 ],
428}
429
430// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
431// because those classes are also part of the core library public SDK API
432// (since API level 26).
433java_library {
434 name: "core-lambda-stubs-for-system-modules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100435 visibility: [
436 "//libcore/mmodules/core_platform_api",
437 ],
Tobias Thierere0f8b312018-10-23 23:12:30 +0100438 defaults: ["core_lambda_stubs_defaults"],
439 srcs: [
440 ":openjdk_lambda_stub_files",
441 ],
442}
443
Pete Gillin54035812019-05-08 15:09:39 +0100444// Creates a jar that exists to satisfy javac when compiling source code that
445// contains @Generated annotations, which are produced by some code generation
446// tools (notably dagger) but aren't part of the Android API.
447// See http://b/123891440.
448java_library {
449 name: "core-generated-annotation-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100450 visibility: [
451 "//libcore/mmodules/core_platform_api",
452 ],
Pete Gillin54035812019-05-08 15:09:39 +0100453 defaults: ["libcore_java_defaults"],
454 srcs: [
455 ":openjdk_generated_annotation_stub_files",
456 ],
457 hostdex: true,
Paul Duffin83c25382019-06-07 14:10:49 +0100458 sdk_version: "none",
Pete Gillin54035812019-05-08 15:09:39 +0100459 libs: ["core-all"],
460 system_modules: "core-all-system-modules",
461 openjdk9: {
462 javacflags: ["--patch-module=java.base=."],
463 },
464 notice: "ojluni/NOTICE",
465 installable: false,
466 include_srcs: true,
467}
468
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100469// A system modules definition containing the implementations for the various
470// parts that make up the core library.
471//
472// This system module is intended for use by tests that may need access to
473// core library internals. It should not be generally used; most of the
474// platform build should build against API stubs instead. See
475// "core-platform-api-stubs-system-modules", which is the default used by the
476// Android build.
477//
478// This module also includes lambda stubs for compiling source containing
479// Java lambdas.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700480java_system_modules {
481 name: "core-system-modules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100482 visibility: ["//visibility:public"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700483 libs: [
484 "core-oj",
485 "core-libart",
Neil Fullerb669ccb2018-10-04 23:10:27 +0100486 "bouncycastle",
487 "conscrypt",
488 "okhttp",
Neil Fuller05723a52018-10-19 10:55:05 +0100489 "apache-xml",
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100490 // This one is not on device but it's needed when javac compiles code
491 // containing lambdas.
Tobias Thierere0f8b312018-10-23 23:12:30 +0100492 "core-lambda-stubs-for-system-modules",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700493 ],
494}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700495
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100496// Builds libcore test rules
Colin Cross3c6c2e22017-10-18 13:24:52 -0700497java_library_static {
498 name: "core-test-rules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100499 visibility: [
500 "//frameworks/base/location/tests/locationtests",
501 ],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700502 hostdex: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700503 srcs: [
504 "dalvik/test-rules/src/main/**/*.java",
505 "test-rules/src/main/**/*.java",
506 ],
507 static_libs: ["junit"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100508
Paul Duffin83c25382019-06-07 14:10:49 +0100509 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100510 libs: ["core-all"],
511 system_modules: "core-all-system-modules",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700512}
513
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100514// Builds the core-tests-support library used by various tests.
Colin Cross3c6c2e22017-10-18 13:24:52 -0700515java_library_static {
516 name: "core-tests-support",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100517 visibility: [
518 "//cts/apps/CtsVerifier",
519 "//cts/tests/tests/keystore",
520 "//cts/tests/tests/net",
521 "//cts/tests/tests/net/api23Test",
522 "//external/apache-harmony",
523 "//frameworks/base/core/tests/coretests",
524 "//libcore/benchmarks",
525 "//packages/apps/KeyChain/tests",
526 "//system/timezone/distro/core",
527 ],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700528 hostdex: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700529 srcs: ["support/src/test/java/**/*.java"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100530
Paul Duffin53c491f2019-06-12 13:48:14 +0100531 sdk_version: "core_platform",
Neil Fuller4380ab22018-10-18 19:38:53 +0100532 libs: ["junit"],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700533 static_libs: [
Neil Fullerde8b0862018-10-12 21:53:31 +0100534 "bouncycastle-unbundled",
535 "bouncycastle-bcpkix-unbundled",
536 "bouncycastle-ocsp-unbundled",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700537 ],
538}
539
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100540// Builds the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700541java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700542 name: "jsr166-tests",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100543 visibility: [
544 "//cts/tests/libcore/jsr166",
545 ],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700546 srcs: ["jsr166-tests/src/test/java/**/*.java"],
Paul Duffin83c25382019-06-07 14:10:49 +0100547 sdk_version: "none",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700548 libs: [
Neil Fuller4207c7f2018-10-10 14:01:40 +0100549 "core-all",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700550 "junit",
551 ],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100552 system_modules: "core-all-system-modules",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700553}
Nan Zhang65f27a32018-01-05 10:41:46 -0800554
Pete Gillinec902b82019-06-26 17:23:00 +0100555// A filegroup that provides access to a source file for a toolchain test that
556// checks Java 9 language features are handled properly by JarJar.
557filegroup {
558 name: "core-java-9-language-features-source",
559 srcs: ["luni/src/main/java/libcore/internal/Java9LanguageFeatures.java"],
560 visibility: ["//libcore/luni/src/test/java9language"],
561}
562
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100563// Builds the core-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700564java_test {
565 name: "core-tests",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100566 visibility: [
567 "//cts/tests/libcore/luni",
568 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700569 defaults: ["libcore_java_defaults"],
570 hostdex: true,
571 srcs: [
572 "dalvik/src/test/java/**/*.java",
573 "dalvik/test-rules/src/test/java/**/*.java",
574 "dom/src/test/java/**/*.java",
575 "harmony-tests/src/test/java/**/*.java",
576 "json/src/test/java/**/*.java",
577 "luni/src/test/java/**/*.java",
Paul Duffin4ba14532019-03-21 10:32:41 +0000578 "test-rules/src/test/java/**/*.java",
Colin Crossec80f4f2018-08-15 21:17:11 -0700579 "xml/src/test/java/**/*.java",
580 ],
581 exclude_srcs: [
582 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
583 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
584 ],
585
586 java_resource_dirs: [
587 "*/src/test/java",
588 "*/src/test/resources",
589 ],
590 exclude_java_resource_dirs: [
591 "ojluni/src/test/java",
592 "ojluni/src/test/resources",
593 ],
594
595 java_resources: [
Paul Duffin16a057f2019-05-13 12:20:55 +0100596 ":annotations-test",
Colin Crossec80f4f2018-08-15 21:17:11 -0700597 ":filesystemstest",
598 ":parameter-metadata-test",
599 ],
600
Paul Duffin83c25382019-06-07 14:10:49 +0100601 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100602 libs: [
603 "core-all",
604 "okhttp",
605 "bouncycastle",
606 ],
607 system_modules: "core-all-system-modules",
608
Colin Crossec80f4f2018-08-15 21:17:11 -0700609 static_libs: [
610 "archive-patcher",
Pete Gillin05a43202019-06-27 14:41:21 +0100611 "core-java-9-language-tests",
Colin Crossec80f4f2018-08-15 21:17:11 -0700612 "core-test-rules",
613 "core-tests-support",
614 "junit-params",
615 "mockftpserver",
616 "mockito-target",
617 "mockwebserver",
618 "nist-pkix-tests",
619 "slf4j-jdk14",
620 "sqlite-jdbc",
621 "tzdata-testing",
Paul Duffina4df2372018-12-10 15:48:01 +0000622 "truth-prebuilt",
Colin Crossec80f4f2018-08-15 21:17:11 -0700623 ],
624
625 errorprone: {
626 javacflags: [
627 "-Xep:TryFailThrowable:ERROR",
628 "-Xep:ComparisonOutOfRange:ERROR",
629 ],
630 },
Simran Basi3be01e02018-08-21 17:53:49 -0700631
632 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700633}
634
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100635// Builds the core-ojtests library that contains test code from OpenJDK.
Colin Crossec80f4f2018-08-15 21:17:11 -0700636java_test {
637 name: "core-ojtests",
638 defaults: ["libcore_java_defaults"],
639 hostdex: true,
640
641 srcs: [
642 "ojluni/src/test/java/**/*.java",
643 ],
644 java_resource_dirs: [
645 "ojluni/src/test/java",
646 "ojluni/src/test/resources",
647 ],
Neil Fullerb669ccb2018-10-04 23:10:27 +0100648
Paul Duffin83c25382019-06-07 14:10:49 +0100649 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100650 libs: [
651 "core-all",
652 "okhttp",
653 "bouncycastle",
654 ],
655 system_modules: "core-all-system-modules",
656
Colin Crossec80f4f2018-08-15 21:17:11 -0700657 static_libs: ["testng"],
658
659 // ojluni/src/test/java/util/stream/{bootlib,boottest}
660 // contains tests that are in packages from java.base;
661 // By default, OpenJDK 9's javac will only compile such
662 // code if it's declared to also be in java.base at
663 // compile time.
664 //
665 // For now, we use --patch-module to put all sources
666 // and dependencies from this make target into java.base;
667 // other source directories in this make target are in
668 // packages not from java.base; if this becomes a problem
669 // in future, this could be addressed eg. by splitting
670 // boot{lib,test} out into a separate make target,
671 // deleting those tests or moving them to a different
672 // package.
673 patch_module: "java.base",
674}
675
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100676// Builds the core-ojtests-public library. Excludes any private API tests.
677// Like core-ojtests but smaller.
Colin Crossec80f4f2018-08-15 21:17:11 -0700678java_test {
679 name: "core-ojtests-public",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100680 visibility: [
681 "//cts/tests/libcore/ojluni",
682 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700683 defaults: ["libcore_java_defaults"],
684 srcs: [
685 "ojluni/src/test/java/**/*.java",
686 ],
687 // Filter out the following:
688 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
689 // and won't actually run, and
690 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
691 // excluding them means we don't need patch_module: "java.base"
692 exclude_srcs: [
693 "**/DeserializeMethodTest.java",
694 "**/SerializedLambdaTest.java",
695 "ojluni/src/test/java/util/stream/boot*/**/*",
696 ],
697 java_resource_dirs: [
698 "ojluni/src/test/java",
699 "ojluni/src/test/resources",
700 // Include source code as part of JAR
701 "ojluni/src/test/dist",
702 ],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100703
Paul Duffin83c25382019-06-07 14:10:49 +0100704 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100705 libs: [
706 "core-all",
707 "bouncycastle",
708 "okhttp",
709 "testng",
710 ],
711 system_modules: "core-all-system-modules",
Colin Crossec80f4f2018-08-15 21:17:11 -0700712}
713
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100714// Exports annotated stubs source files in ojluni/annotations/sdk to make them
715// available to metalava. Used for nullability annotations in OpenJDK source.
Pete Gillin7db7faa2018-07-31 13:29:35 +0100716droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100717 name: "ojluni-annotated-sdk-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100718 visibility: [
719 "//frameworks/base",
720 ],
Pete Gillin0728b742018-09-17 15:41:45 +0100721 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100722}
Paul Duffin48ac7b62019-03-28 14:28:06 +0000723
Pete Gillin600c7cf2018-08-16 19:28:38 +0100724droiddoc_exported_dir {
725 name: "ojluni-annotated-nullability-stubs",
726 path: "ojluni/annotations/sdk/nullability",
727}
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100728
729// Exports annotated stubs source files in ojluni/annotations/mmodules to make
Paul Duffinc241d6a2019-06-25 15:40:29 +0100730// them available to metalava. Used for core platform API and intra-core API
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100731// annotations in OpenJDK source.
Pete Gillinc9935b62018-09-25 14:42:40 +0100732droiddoc_exported_dir {
733 name: "ojluni-annotated-mmodule-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100734 visibility: [
735 "//libcore/mmodules/core_platform_api",
736 "//libcore/mmodules/intracoreapi",
737 ],
Pete Gillinc9935b62018-09-25 14:42:40 +0100738 path: "ojluni/annotations/mmodule",
739}
Pete Gillin7db7faa2018-07-31 13:29:35 +0100740
Neil Fuller6f16b462018-09-04 15:40:39 +0100741// A file containing the list of tags that are "known" to us from the OpenJdk
742// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800743filegroup {
744 name: "known-oj-tags",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100745 visibility: [
746 "//frameworks/base",
747 ],
Nan Zhangd55722b2018-02-27 15:08:20 -0800748 srcs: [
749 "known_oj_tags.txt",
750 ],
751}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700752
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100753// Generates stubs for the parts of the public SDK API provided by the core
754// library.
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000755//
756// Only for use by core.current.stubs target below.
Nan Zhangf0207602018-09-10 18:57:38 -0700757droidstubs {
758 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100759 srcs: [":core_api_files"],
Tobias Thiererde991232018-03-07 15:10:46 +0000760 java_version: "1.9",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700761 installable: false,
Paul Duffin419b2422019-06-25 15:42:05 +0100762 sdk_version: "none",
Paul Duffinc31f6bb2019-05-15 12:32:44 +0100763 args: " --exclude-annotations " +
764 "--hide-annotation libcore.api.Hide",
Neil Fullerbe9258e2018-09-24 17:11:27 +0100765 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700766}
767
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000768// A stubs target containing the parts of the public SDK API provided by the
769// core library.
770//
771// Don't use this directly, use "sdk_version: core_current".
772java_library {
773 name: "core.current.stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100774 visibility: ["//visibility:public"],
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000775 srcs: [":core-current-stubs-gen"],
776 errorprone: {
777 javacflags: [
778 "-Xep:MissingOverride:OFF",
779 ],
780 },
781 openjdk9: {
782 javacflags: ["--patch-module=java.base=."],
783 },
Paul Duffin83c25382019-06-07 14:10:49 +0100784 sdk_version: "none",
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000785 system_modules: "none",
Paul Duffin65641182019-04-08 10:24:23 +0100786
787 dist: {
788 targets: [
789 "sdk",
790 "win_sdk",
791 ],
792 },
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000793}
794
Neil Fuller61dabbf2018-10-21 22:53:18 +0100795// Used when compiling higher-level code against core.current.stubs.
796java_system_modules {
797 name: "core-current-stubs-system-modules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100798 visibility: ["//visibility:public"],
Neil Fuller61dabbf2018-10-21 22:53:18 +0100799 libs: [
800 "core.current.stubs",
801 // This one is not on device but it's needed when javac compiles code
802 // containing lambdas.
803 "core-lambda-stubs-for-system-modules",
804 // This one is not on device but it's needed when javac compiles code
805 // containing @Generated annotations produced by some code generation
806 // tools.
807 // See http://b/123891440.
808 "core-generated-annotation-stubs",
809 ],
810}
811
Pete Gillin600c7cf2018-08-16 19:28:38 +0100812// Target for validating nullability annotations for correctness and
813// completeness. To check that there are no nullability errors:
814// make core-current-stubs-nullability-validation
815// To check that there are only the expected nullability warnings:
816// make core-current-stubs-nullability-validation-check-nullability-warnings
817// To update the the list of known expected nullability warnings:
818// make core-current-stubs-nullability-validation-update-nullability-warnings
819droidstubs {
820 name: "core-current-stubs-nullability-validation",
821 srcs: [":core_api_files"],
822 installable: false,
Paul Duffin419b2422019-06-25 15:42:05 +0100823 sdk_version: "none",
Pete Gillin600c7cf2018-08-16 19:28:38 +0100824 annotations_enabled: true,
825 args: "--hide-annotation libcore.api.Hide " +
826 "--validate-nullability-from-merged-stubs ",
827 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
828 merge_annotations_dirs: [
829 "metalava-manual",
830 // N.B. Stubs in this filegroup will be validated:
831 "ojluni-annotated-nullability-stubs",
832 ],
Pete Gillinc5f179b2018-11-14 18:42:19 +0000833 // The list of classes which have nullability annotations included in the source.
834 // (This is in addition to those which have annotations in the merged stubs.)
835 validate_nullability_from_list: "nullability_annotated_classes.txt",
Pete Gillin600c7cf2018-08-16 19:28:38 +0100836 // The expected set of warnings about missing annotations:
837 check_nullability_warnings: "nullability_warnings.txt",
838}
839
Neil Fullere784ef22018-11-16 15:54:30 +0000840// A host library containing time zone related classes. Used for
841// host-side tools and tests that have to deal with Android
842// time zone data.
843java_library_host {
844 name: "timezone-host",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100845 visibility: [
846 "//system/timezone/distro/core",
847 ],
Neil Fullere784ef22018-11-16 15:54:30 +0000848 srcs: [":timezone_host_files"],
849}
Andrei Onea24892e22019-04-16 16:48:37 +0100850
851// The source files that contain the UnsupportedAppUsage annotation and its dependencies.
852filegroup {
853 name: "unsupportedappusage_annotation_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100854 visibility: [
855 "//frameworks/base",
856 ],
Andrei Onea24892e22019-04-16 16:48:37 +0100857 srcs: [
858 "dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java",
859 "dalvik/src/main/java/dalvik/system/VersionCodes.java",
860 "luni/src/main/java/libcore/api/CorePlatformApi.java",
861 "luni/src/main/java/libcore/api/IntraCoreApi.java",
862 ],
Neil Fuller86345d72019-04-25 09:15:32 +0100863}