blob: 5808d1d27670fe1f4ad0af7b8b40008bee3de82e [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.
48core_resource_dirs = [
49 "luni/src/main/java",
50 "ojluni/src/main/resources/",
51]
52
Neil Fuller866ed4a2018-09-06 12:05:46 +010053// The source files that go into core-oj.
54filegroup {
55 name: "core_oj_java_files",
56 srcs: [":openjdk_java_files"],
57}
58
Neil Fullere32e2e12019-02-26 11:48:30 +000059// OpenJDK source is not annotated with @hide so we need this separate
Neil Fuller866ed4a2018-09-06 12:05:46 +010060// filegroup for just the parts that contribute to the API.
61filegroup {
62 name: "core_oj_api_files",
63 srcs: [":openjdk_javadoc_files"],
64}
65
66// The source files that go into core-libart.
67filegroup {
68 name: "core_libart_java_files",
69 srcs: [
70 ":non_openjdk_java_files",
71 ":android_icu4j_src_files",
72 ],
73}
74
Neil Fullere32e2e12019-02-26 11:48:30 +000075// Some parts of libart are not annotated with @hide so we need this separate
Neil Fuller866ed4a2018-09-06 12:05:46 +010076// filegroup for just the parts that contribute to the API.
77filegroup {
78 name: "core_libart_api_files",
79 srcs: [
80 ":non_openjdk_javadoc_files",
81 ":android_icu4j_src_files",
82 ],
83}
84
Neil Fullere32e2e12019-02-26 11:48:30 +000085// The set of files for the core library that have been marked up with @hide
86// for the public SDK APIs. Used from frameworks/base/ to indicate the source
87// files for inclusion in the public SDK docs.
88filegroup {
89 name: "core_public_api_files",
90 srcs: [
91 ":core_oj_api_files",
92 ":core_libart_api_files",
93 ":conscrypt_public_api_files",
94 ],
95}
96
Neil Fuller77e3f3b2018-10-19 10:22:32 +010097// The set of files for the core library that have been marked up with @hide and
98// API-related annotations. Note that this includes the intra-core and
99// core-platform APIs as well as the public APIs.
100//
Neil Fullere32e2e12019-02-26 11:48:30 +0000101// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are
102// annotated by applying annotations to the .annotated.java stubs files in
103// ojluni/annotated/mmodules and rather than in the original source. See the comments
104// in openjdk_java_files.bp for more details.
Neil Fuller866ed4a2018-09-06 12:05:46 +0100105filegroup {
106 name: "core_api_files",
107 srcs: [
Neil Fullerd129bc92018-09-26 11:12:58 +0100108 ":apache-xml_api_files",
Neil Fullera77f7102018-09-21 19:04:41 +0100109 ":bouncycastle_java_files",
Neil Fuller603e1a72018-09-25 11:55:41 +0100110 ":conscrypt_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100111 ":core_oj_api_files",
112 ":core_libart_api_files",
Neil Fuller641d5f92018-09-24 15:40:39 +0100113 ":okhttp_api_files",
Pete Gillinc9935b62018-09-25 14:42:40 +0100114 ":openjdk_mmodule_extra_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100115 ],
116}
117
Colin Crossaf0b54c2017-09-27 17:22:32 -0700118java_defaults {
119 name: "libcore_java_defaults",
120 javacflags: [
121 //"-Xlint:all",
122 //"-Xlint:-serial,-deprecation,-unchecked",
123 ],
124 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800125 errorprone: {
126 javacflags: [
Paul Duffinc31f6bb2019-05-15 12:32:44 +0100127 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
128 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800129 ],
130 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700131}
132
133//
134// Build for the target (device).
135//
136
Victor Chang7fef4052018-09-25 14:12:03 +0100137// Rule generating resource lib for android_icu4j.
138// In the downstream branch master-icu-dev, the resource files are generated.
139// This rule can't be moved external/icu because soong enforces that no_standard_libs:true can only
140// be used in libcore/ or development/
141java_library {
142 name: "android_icu4j_resources_lib",
143 java_resources: [":android_icu4j_resources"],
144 no_standard_libs: true,
145 system_modules: "none",
146}
147
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100148// A target used to bootstrap compilation for the core library.
149// See core-all-system-modules for more details.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700150java_library {
151 name: "core-all",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000152 visibility: [
153 "//external/apache-harmony:__subpackages__",
154 "//external/apache-xml",
155 "//external/bouncycastle",
156 "//external/conscrypt",
157 "//external/icu/android_icu4j",
158 "//external/okhttp",
159 "//libcore/mmodules/intracoreapi",
160 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700161 defaults: ["libcore_java_defaults"],
162
163 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100164 ":core_oj_java_files",
165 ":core_libart_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700166 ":openjdk_lambda_stub_files",
Pete Gillin54035812019-05-08 15:09:39 +0100167 ":openjdk_generated_annotation_stub_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700168 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700169
170 no_standard_libs: true,
171 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700172 openjdk9: {
173 srcs: ["luni/src/module/java/module-info.java"],
174 javacflags: ["--patch-module=java.base=."],
175 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700176
Colin Crossaf0b54c2017-09-27 17:22:32 -0700177 java_resource_dirs: core_resource_dirs,
Victor Chang7fef4052018-09-25 14:12:03 +0100178 static_libs: ["android_icu4j_resources_lib"],
Tobias Thiererde991232018-03-07 15:10:46 +0000179 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700180
Colin Crossaf0b54c2017-09-27 17:22:32 -0700181 installable: false,
182}
183
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100184// A system modules definition for use by core library targets only. It only
185// contains the core-all jar, which contains the classes that end up in core-oj,
186// core-libart as well as the lambda stubs needed to compile Java lambda code.
187// It does not contain other parts of core library like conscrypt, bouncycastle,
188// etc. This system_modules definition is used to bootstrap compilation for
189// other parts of the core library like core-oj, core-libart, conscrypt,
190// bouncycastle, etc.
191//
192// If you want to compile against the entire core library implementation, for
193// example to build core library tests, see "core-system-modules" instead.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700194java_system_modules {
195 name: "core-all-system-modules",
196 libs: ["core-all"],
197}
198
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100199// Contains the parts of core library associated with OpenJDK.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700200java_library {
201 name: "core-oj",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000202 visibility: [
203 "//art/build/apex",
204 "//external/wycheproof",
205 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700206 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700207 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700208 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700209
Neil Fuller866ed4a2018-09-06 12:05:46 +0100210 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700211 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700212
213 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700214 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700215 system_modules: "core-all-system-modules",
216 openjdk9: {
217 javacflags: ["--patch-module=java.base=."],
218 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700219
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000220 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000221 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000222 "java.lang.Class",
223 "java.lang.Long",
224 "java.lang.Number",
225 "java.lang.Object",
226 "java.lang.String",
227 "java.lang.invoke.MethodHandle",
228 "java.lang.ref.Reference",
229 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000230 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000231 "java.util.HashMap",
232 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000233 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000234 ],
235 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700236
237 notice: "ojluni/NOTICE",
238
Colin Crossaf0b54c2017-09-27 17:22:32 -0700239}
240
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100241// Contains parts of core library not associated with OpenJDK. Contains not
242// just java.*, javax.* code but also android.icu.*, android.system.* and
243// various internal libcore.* packages.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700244java_library {
245 name: "core-libart",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000246 visibility: [
247 "//art/build/apex",
248 "//external/robolectric-shadows",
249 "//external/wycheproof",
250 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700251 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700252 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700253 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700254
Neil Fuller866ed4a2018-09-06 12:05:46 +0100255 srcs: [":core_libart_java_files"],
Victor Chang7fef4052018-09-25 14:12:03 +0100256 static_libs: ["android_icu4j_resources_lib"],
Tobias Thiererde991232018-03-07 15:10:46 +0000257 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700258
Colin Crossec80f4f2018-08-15 21:17:11 -0700259 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700260 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700261 system_modules: "core-all-system-modules",
262 openjdk9: {
263 javacflags: ["--patch-module=java.base=."],
264 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700265
Pete Gillin80ebe872018-02-13 15:21:20 +0000266 jacoco: {
267 exclude_filter: [
268 "java.lang.DexCache",
269 "dalvik.system.ClassExt",
270 ],
271 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700272
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700273 target: {
274 hostdex: {
275 required: [
276 // Files used to simulate the /system and runtime APEX dir
277 // structure on host.
278 "tzdata_host",
279 "tzdata_host_runtime_apex",
280 "tzlookup.xml_host_runtime_apex",
281 "tz_version_host",
282 "tz_version_host_runtime_apex",
283 ],
284 },
285 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700286}
287
Paul Duffin7bb8d232018-10-23 11:48:38 +0100288// Provided solely to contribute information about which hidden parts of the
289// core-oj API are used by apps.
Paul Duffinc6bf27b2019-05-15 14:41:00 +0100290//
291// The build system determines that this library provides hiddenapi information
292// for the core-oj bootjar because its name is of the form <x>-hiddenapi, where
293// <x> is the name of a boot jar. That triggers the generation of a flags.csv
294// file which encapsulates information extracted from the UnsupportedAppUsage
295// annotations in the dex. The information from that file is then encoded into
296// the core-oj file.
297//
298// Usually, e.g. for core-libart, the UnsupportedAppUsage annotations are
299// added to the source that is compiled directly into the bootjar and the build
300// system extracts the information about UnsupportedAppUsage directly from
301// there.
302//
303// This approach of having separate annotated source and a separate build
304// target was taken for ojluni to avoid having to maintain local patches in the
305// ojluni source for UnsupportedAppUsage annotations as that would make it more
306// difficult to pull down changes from upstream.
307//
Paul Duffin7bb8d232018-10-23 11:48:38 +0100308java_library {
309 name: "core-oj-hiddenapi",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000310 // Do not allow this to be accessed from outside this directory.
311 visibility: ["//visibility:private"],
Paul Duffin7bb8d232018-10-23 11:48:38 +0100312 defaults: ["libcore_java_defaults"],
313 compile_dex: true,
314
315 srcs: [":openjdk_hiddenapi_javadoc_files"],
316
317 no_standard_libs: true,
318 libs: ["core-all"],
319 system_modules: "core-all-system-modules",
320 openjdk9: {
321 javacflags: ["--patch-module=java.base=."],
322 },
323}
324
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100325//
326// Guaranteed unstripped versions of core-oj and core-libart.
327//
Colin Cross3c6c2e22017-10-18 13:24:52 -0700328// The build system may or may not strip the core-oj and core-libart jars,
329// but these will not be stripped. See b/24535627.
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100330//
331
Colin Cross3c6c2e22017-10-18 13:24:52 -0700332java_library {
333 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700334 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700335 static_libs: ["core-oj"],
336 no_standard_libs: true,
337 libs: ["core-all"],
338 system_modules: "core-all-system-modules",
339 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800340 dex_preopt: {
341 enabled: false,
342 },
Tobias Thiererde991232018-03-07 15:10:46 +0000343 java_version: "1.9",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700344 notice: "ojluni/NOTICE",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700345}
346
347java_library {
348 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700349 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700350 static_libs: ["core-libart"],
351 no_standard_libs: true,
352 libs: ["core-all"],
353 system_modules: "core-all-system-modules",
354 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800355 dex_preopt: {
356 enabled: false,
357 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700358 notice: "ojluni/NOTICE",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700359}
360
Tobias Thierere0f8b312018-10-23 23:12:30 +0100361java_defaults {
362 name: "core_lambda_stubs_defaults",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700363 defaults: ["libcore_java_defaults"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100364 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700365
Colin Crossec80f4f2018-08-15 21:17:11 -0700366 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700367 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700368 system_modules: "core-all-system-modules",
369 openjdk9: {
370 javacflags: ["--patch-module=java.base=."],
371 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700372
373 notice: "ojluni/NOTICE",
374
375 installable: false,
376 include_srcs: true,
377}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700378
Tobias Thierere0f8b312018-10-23 23:12:30 +0100379// Creates a jar that exists to satisfy javac when compiling source code that
380// contains lambdas. This contains all classes / methods required by javac
381// when generating invoke-dynamic lambda implementation code, even those that
382// are also in the public SDK API from API level 26 onwards.
383java_library {
384 name: "core-lambda-stubs",
385 defaults: ["core_lambda_stubs_defaults"],
386 srcs: [
387 ":openjdk_lambda_stub_files",
388 ":openjdk_lambda_duplicate_stub_files",
389 ],
390}
391
392// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
393// because those classes are also part of the core library public SDK API
394// (since API level 26).
395java_library {
396 name: "core-lambda-stubs-for-system-modules",
397 defaults: ["core_lambda_stubs_defaults"],
398 srcs: [
399 ":openjdk_lambda_stub_files",
400 ],
401}
402
Pete Gillin54035812019-05-08 15:09:39 +0100403// Creates a jar that exists to satisfy javac when compiling source code that
404// contains @Generated annotations, which are produced by some code generation
405// tools (notably dagger) but aren't part of the Android API.
406// See http://b/123891440.
407java_library {
408 name: "core-generated-annotation-stubs",
409 defaults: ["libcore_java_defaults"],
410 srcs: [
411 ":openjdk_generated_annotation_stub_files",
412 ],
413 hostdex: true,
414 no_standard_libs: true,
415 libs: ["core-all"],
416 system_modules: "core-all-system-modules",
417 openjdk9: {
418 javacflags: ["--patch-module=java.base=."],
419 },
420 notice: "ojluni/NOTICE",
421 installable: false,
422 include_srcs: true,
423}
424
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100425// A system modules definition containing the implementations for the various
426// parts that make up the core library.
427//
428// This system module is intended for use by tests that may need access to
429// core library internals. It should not be generally used; most of the
430// platform build should build against API stubs instead. See
431// "core-platform-api-stubs-system-modules", which is the default used by the
432// Android build.
433//
434// This module also includes lambda stubs for compiling source containing
435// Java lambdas.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700436java_system_modules {
437 name: "core-system-modules",
438 libs: [
439 "core-oj",
440 "core-libart",
Neil Fullerb669ccb2018-10-04 23:10:27 +0100441 "bouncycastle",
442 "conscrypt",
443 "okhttp",
Neil Fuller05723a52018-10-19 10:55:05 +0100444 "apache-xml",
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100445 // This one is not on device but it's needed when javac compiles code
446 // containing lambdas.
Tobias Thierere0f8b312018-10-23 23:12:30 +0100447 "core-lambda-stubs-for-system-modules",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700448 ],
449}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700450
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100451// Builds libcore test rules
Colin Cross3c6c2e22017-10-18 13:24:52 -0700452java_library_static {
453 name: "core-test-rules",
454 hostdex: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700455 srcs: [
456 "dalvik/test-rules/src/main/**/*.java",
457 "test-rules/src/main/**/*.java",
458 ],
459 static_libs: ["junit"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100460
461 no_standard_libs: true,
462 libs: ["core-all"],
463 system_modules: "core-all-system-modules",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700464}
465
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100466// Builds the core-tests-support library used by various tests.
Colin Cross3c6c2e22017-10-18 13:24:52 -0700467java_library_static {
468 name: "core-tests-support",
469 hostdex: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700470 srcs: ["support/src/test/java/**/*.java"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100471
Neil Fuller4380ab22018-10-18 19:38:53 +0100472 no_framework_libs: true,
473 libs: ["junit"],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700474 static_libs: [
Neil Fullerde8b0862018-10-12 21:53:31 +0100475 "bouncycastle-unbundled",
476 "bouncycastle-bcpkix-unbundled",
477 "bouncycastle-ocsp-unbundled",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700478 ],
479}
480
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100481// Builds the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700482java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700483 name: "jsr166-tests",
484 srcs: ["jsr166-tests/src/test/java/**/*.java"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100485 no_standard_libs: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700486 libs: [
Neil Fuller4207c7f2018-10-10 14:01:40 +0100487 "core-all",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700488 "junit",
489 ],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100490 system_modules: "core-all-system-modules",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700491}
Nan Zhang65f27a32018-01-05 10:41:46 -0800492
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100493// Builds a library just containing files from luni/src/test/filesystems
494// for use in tests.
Colin Crossec80f4f2018-08-15 21:17:11 -0700495java_library {
496 name: "filesystemstest",
497 compile_dex: true,
498 srcs: ["luni/src/test/filesystems/src/**/*.java"],
499 java_resource_dirs: ["luni/src/test/filesystems/resources"],
500 no_framework_libs: true,
501 errorprone: {
502 javacflags: ["-Xep:MissingOverride:OFF"],
503 },
504}
505
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100506// Builds a library just containing files from luni/src/test/parameter_metadata
507// for use in tests.
Colin Crossec80f4f2018-08-15 21:17:11 -0700508java_library {
509 name: "parameter-metadata-test",
510 compile_dex: true,
511 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
512 no_framework_libs: true,
513 javacflags: ["-parameters"],
514 errorprone: {
515 javacflags: ["-Xep:MissingOverride:OFF"],
516 },
517}
518
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100519// Builds the core-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700520java_test {
521 name: "core-tests",
522 defaults: ["libcore_java_defaults"],
523 hostdex: true,
524 srcs: [
525 "dalvik/src/test/java/**/*.java",
526 "dalvik/test-rules/src/test/java/**/*.java",
527 "dom/src/test/java/**/*.java",
528 "harmony-tests/src/test/java/**/*.java",
529 "json/src/test/java/**/*.java",
530 "luni/src/test/java/**/*.java",
Paul Duffin4ba14532019-03-21 10:32:41 +0000531 "test-rules/src/test/java/**/*.java",
Colin Crossec80f4f2018-08-15 21:17:11 -0700532 "xml/src/test/java/**/*.java",
533 ],
534 exclude_srcs: [
535 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
536 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
537 ],
538
539 java_resource_dirs: [
540 "*/src/test/java",
541 "*/src/test/resources",
542 ],
543 exclude_java_resource_dirs: [
544 "ojluni/src/test/java",
545 "ojluni/src/test/resources",
546 ],
547
548 java_resources: [
Paul Duffin16a057f2019-05-13 12:20:55 +0100549 ":annotations-test",
Colin Crossec80f4f2018-08-15 21:17:11 -0700550 ":filesystemstest",
551 ":parameter-metadata-test",
552 ],
553
Neil Fuller4207c7f2018-10-10 14:01:40 +0100554 no_standard_libs: true,
555 libs: [
556 "core-all",
557 "okhttp",
558 "bouncycastle",
559 ],
560 system_modules: "core-all-system-modules",
561
Colin Crossec80f4f2018-08-15 21:17:11 -0700562 static_libs: [
563 "archive-patcher",
564 "core-test-rules",
565 "core-tests-support",
566 "junit-params",
567 "mockftpserver",
568 "mockito-target",
569 "mockwebserver",
570 "nist-pkix-tests",
571 "slf4j-jdk14",
572 "sqlite-jdbc",
573 "tzdata-testing",
Paul Duffina4df2372018-12-10 15:48:01 +0000574 "truth-prebuilt",
Colin Crossec80f4f2018-08-15 21:17:11 -0700575 ],
576
577 errorprone: {
578 javacflags: [
579 "-Xep:TryFailThrowable:ERROR",
580 "-Xep:ComparisonOutOfRange:ERROR",
581 ],
582 },
Simran Basi3be01e02018-08-21 17:53:49 -0700583
584 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700585}
586
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100587// Builds the core-ojtests library that contains test code from OpenJDK.
Colin Crossec80f4f2018-08-15 21:17:11 -0700588java_test {
589 name: "core-ojtests",
590 defaults: ["libcore_java_defaults"],
591 hostdex: true,
592
593 srcs: [
594 "ojluni/src/test/java/**/*.java",
595 ],
596 java_resource_dirs: [
597 "ojluni/src/test/java",
598 "ojluni/src/test/resources",
599 ],
Neil Fullerb669ccb2018-10-04 23:10:27 +0100600
Neil Fuller4207c7f2018-10-10 14:01:40 +0100601 no_standard_libs: true,
602 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: ["testng"],
610
611 // ojluni/src/test/java/util/stream/{bootlib,boottest}
612 // contains tests that are in packages from java.base;
613 // By default, OpenJDK 9's javac will only compile such
614 // code if it's declared to also be in java.base at
615 // compile time.
616 //
617 // For now, we use --patch-module to put all sources
618 // and dependencies from this make target into java.base;
619 // other source directories in this make target are in
620 // packages not from java.base; if this becomes a problem
621 // in future, this could be addressed eg. by splitting
622 // boot{lib,test} out into a separate make target,
623 // deleting those tests or moving them to a different
624 // package.
625 patch_module: "java.base",
626}
627
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100628// Builds the core-ojtests-public library. Excludes any private API tests.
629// Like core-ojtests but smaller.
Colin Crossec80f4f2018-08-15 21:17:11 -0700630java_test {
631 name: "core-ojtests-public",
632 defaults: ["libcore_java_defaults"],
633 srcs: [
634 "ojluni/src/test/java/**/*.java",
635 ],
636 // Filter out the following:
637 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
638 // and won't actually run, and
639 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
640 // excluding them means we don't need patch_module: "java.base"
641 exclude_srcs: [
642 "**/DeserializeMethodTest.java",
643 "**/SerializedLambdaTest.java",
644 "ojluni/src/test/java/util/stream/boot*/**/*",
645 ],
646 java_resource_dirs: [
647 "ojluni/src/test/java",
648 "ojluni/src/test/resources",
649 // Include source code as part of JAR
650 "ojluni/src/test/dist",
651 ],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100652
653 no_standard_libs: true,
654 libs: [
655 "core-all",
656 "bouncycastle",
657 "okhttp",
658 "testng",
659 ],
660 system_modules: "core-all-system-modules",
Colin Crossec80f4f2018-08-15 21:17:11 -0700661}
662
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100663// Exports annotated stubs source files in ojluni/annotations/sdk to make them
664// available to metalava. Used for nullability annotations in OpenJDK source.
Pete Gillin7db7faa2018-07-31 13:29:35 +0100665droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100666 name: "ojluni-annotated-sdk-stubs",
667 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100668}
Paul Duffin48ac7b62019-03-28 14:28:06 +0000669
Pete Gillin600c7cf2018-08-16 19:28:38 +0100670droiddoc_exported_dir {
671 name: "ojluni-annotated-nullability-stubs",
672 path: "ojluni/annotations/sdk/nullability",
673}
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100674
675// Exports annotated stubs source files in ojluni/annotations/mmodules to make
676// them available to metalava. Used for core platform API and intra-code API
677// annotations in OpenJDK source.
Pete Gillinc9935b62018-09-25 14:42:40 +0100678droiddoc_exported_dir {
679 name: "ojluni-annotated-mmodule-stubs",
680 path: "ojluni/annotations/mmodule",
681}
Pete Gillin7db7faa2018-07-31 13:29:35 +0100682
Neil Fuller6f16b462018-09-04 15:40:39 +0100683// A file containing the list of tags that are "known" to us from the OpenJdk
684// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800685filegroup {
686 name: "known-oj-tags",
687 srcs: [
688 "known_oj_tags.txt",
689 ],
690}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700691
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100692// Generates stubs for the parts of the public SDK API provided by the core
693// library.
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000694//
695// Only for use by core.current.stubs target below.
Nan Zhangf0207602018-09-10 18:57:38 -0700696droidstubs {
697 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100698 srcs: [":core_api_files"],
Tobias Thiererde991232018-03-07 15:10:46 +0000699 java_version: "1.9",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700700 installable: false,
701 no_framework_libs: true,
Paul Duffinc31f6bb2019-05-15 12:32:44 +0100702 args: " --exclude-annotations " +
703 "--hide-annotation libcore.api.Hide",
Neil Fullerbe9258e2018-09-24 17:11:27 +0100704 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700705}
706
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000707// A stubs target containing the parts of the public SDK API provided by the
708// core library.
709//
710// Don't use this directly, use "sdk_version: core_current".
711java_library {
712 name: "core.current.stubs",
713 srcs: [":core-current-stubs-gen"],
714 errorprone: {
715 javacflags: [
716 "-Xep:MissingOverride:OFF",
717 ],
718 },
719 openjdk9: {
720 javacflags: ["--patch-module=java.base=."],
721 },
722 no_standard_libs: true,
723 system_modules: "none",
Paul Duffin65641182019-04-08 10:24:23 +0100724
725 dist: {
726 targets: [
727 "sdk",
728 "win_sdk",
729 ],
730 },
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000731}
732
Pete Gillin600c7cf2018-08-16 19:28:38 +0100733// Target for validating nullability annotations for correctness and
734// completeness. To check that there are no nullability errors:
735// make core-current-stubs-nullability-validation
736// To check that there are only the expected nullability warnings:
737// make core-current-stubs-nullability-validation-check-nullability-warnings
738// To update the the list of known expected nullability warnings:
739// make core-current-stubs-nullability-validation-update-nullability-warnings
740droidstubs {
741 name: "core-current-stubs-nullability-validation",
742 srcs: [":core_api_files"],
743 installable: false,
744 no_framework_libs: true,
745 annotations_enabled: true,
746 args: "--hide-annotation libcore.api.Hide " +
747 "--validate-nullability-from-merged-stubs ",
748 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
749 merge_annotations_dirs: [
750 "metalava-manual",
751 // N.B. Stubs in this filegroup will be validated:
752 "ojluni-annotated-nullability-stubs",
753 ],
Pete Gillinc5f179b2018-11-14 18:42:19 +0000754 // The list of classes which have nullability annotations included in the source.
755 // (This is in addition to those which have annotations in the merged stubs.)
756 validate_nullability_from_list: "nullability_annotated_classes.txt",
Pete Gillin600c7cf2018-08-16 19:28:38 +0100757 // The expected set of warnings about missing annotations:
758 check_nullability_warnings: "nullability_warnings.txt",
759}
760
Neil Fullere784ef22018-11-16 15:54:30 +0000761// A host library containing time zone related classes. Used for
762// host-side tools and tests that have to deal with Android
763// time zone data.
764java_library_host {
765 name: "timezone-host",
766 srcs: [":timezone_host_files"],
767}
Andrei Onea24892e22019-04-16 16:48:37 +0100768
769// The source files that contain the UnsupportedAppUsage annotation and its dependencies.
770filegroup {
771 name: "unsupportedappusage_annotation_files",
772 srcs: [
773 "dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java",
774 "dalvik/src/main/java/dalvik/system/VersionCodes.java",
775 "luni/src/main/java/libcore/api/CorePlatformApi.java",
776 "luni/src/main/java/libcore/api/IntraCoreApi.java",
777 ],
Neil Fuller86345d72019-04-25 09:15:32 +0100778}