blob: 559cb74ac103d764141e5561d38dc56bfbcff6f9 [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//
16// Definitions for building the Java library and associated tests.
17//
18
Neil Fullercf756882018-08-28 18:42:22 +010019// libcore has some sub-directories that follow a common structure:
20// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni,
21// support, xml, xmlpull.
Colin Crossaf0b54c2017-09-27 17:22:32 -070022//
Neil Fullercf756882018-08-28 18:42:22 +010023// The structure of these is generally:
Colin Crossaf0b54c2017-09-27 17:22:32 -070024//
25// src/
26// main/ # To be shipped on every device.
27// java/ # Java source for library code.
Neil Fullercf756882018-08-28 18:42:22 +010028// native/ # C/C++ source for library code.
Colin Crossaf0b54c2017-09-27 17:22:32 -070029// resources/ # Support files.
30// test/ # Built only on demand, for testing.
31// java/ # Java source for tests.
Neil Fullercf756882018-08-28 18:42:22 +010032// native/ # C/C++ source for tests (rare).
Colin Crossaf0b54c2017-09-27 17:22:32 -070033// resources/ # Support files.
34//
Neil Fullercf756882018-08-28 18:42:22 +010035// All subdirectories are optional.
Colin Crossaf0b54c2017-09-27 17:22:32 -070036
37build = [
38 "openjdk_java_files.bp",
39 "non_openjdk_java_files.bp",
40]
41
42// The Java files and their associated resources.
43core_resource_dirs = [
44 "luni/src/main/java",
45 "ojluni/src/main/resources/",
46]
47
Neil Fuller866ed4a2018-09-06 12:05:46 +010048// The source files that go into core-oj.
49filegroup {
50 name: "core_oj_java_files",
51 srcs: [":openjdk_java_files"],
52}
53
54// OpenJDK source is not annotated with @hide so we need a separate
55// filegroup for just the parts that contribute to the API.
56filegroup {
57 name: "core_oj_api_files",
58 srcs: [":openjdk_javadoc_files"],
59}
60
61// The source files that go into core-libart.
62filegroup {
63 name: "core_libart_java_files",
64 srcs: [
65 ":non_openjdk_java_files",
66 ":android_icu4j_src_files",
67 ],
68}
69
70// Some parts of libart are not annotated with @hide so we need a separate
71// filegroup for just the parts that contribute to the API.
72filegroup {
73 name: "core_libart_api_files",
74 srcs: [
75 ":non_openjdk_javadoc_files",
76 ":android_icu4j_src_files",
77 ],
78}
79
80// The set of files in core that have been marked up with @hide and API-related
Pete Gillinc9935b62018-09-25 14:42:40 +010081// annotations. Note that this includes the intra-core and core-platform APIs as
82// well as the public APIs. Some source files in :openjdk_mmodule_extra_files
83// are annotated by applying annotation to the .annotated.java stubs files in
84// ojluni/annotated/mmodules and rather than in the original source. See the
85// comments in openjdk_java_files.bp for more details.
Neil Fuller866ed4a2018-09-06 12:05:46 +010086filegroup {
87 name: "core_api_files",
88 srcs: [
Neil Fullera77f7102018-09-21 19:04:41 +010089 ":bouncycastle_java_files",
Neil Fuller603e1a72018-09-25 11:55:41 +010090 ":conscrypt_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010091 ":core_oj_api_files",
92 ":core_libart_api_files",
93 ":core_simple_java_files",
Neil Fuller641d5f92018-09-24 15:40:39 +010094 ":okhttp_api_files",
Pete Gillinc9935b62018-09-25 14:42:40 +010095 ":openjdk_mmodule_extra_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010096 ],
97}
98
Colin Crossaf0b54c2017-09-27 17:22:32 -070099java_defaults {
100 name: "libcore_java_defaults",
101 javacflags: [
102 //"-Xlint:all",
103 //"-Xlint:-serial,-deprecation,-unchecked",
104 ],
105 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800106 errorprone: {
107 javacflags: [
108 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -0700109 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800110 ],
111 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700112}
113
114//
115// Build for the target (device).
116//
117
118java_library {
119 name: "core-all",
120 defaults: ["libcore_java_defaults"],
121
122 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100123 ":core_oj_java_files",
124 ":core_libart_java_files",
125 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700126 ":openjdk_lambda_stub_files",
127 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700128
129 no_standard_libs: true,
130 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700131 openjdk9: {
132 srcs: ["luni/src/module/java/module-info.java"],
133 javacflags: ["--patch-module=java.base=."],
134 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700135
Colin Crossaf0b54c2017-09-27 17:22:32 -0700136 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -0700137 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700138
139 required: [
140 "tzdata",
141 "tzlookup.xml",
142 ],
143
144 installable: false,
145}
146
Colin Crossa4d9fc42017-09-29 18:04:37 -0700147java_system_modules {
148 name: "core-all-system-modules",
149 libs: ["core-all"],
150}
151
Colin Crossaf0b54c2017-09-27 17:22:32 -0700152java_library {
153 name: "core-oj",
154 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700155 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700156 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700157
Neil Fuller866ed4a2018-09-06 12:05:46 +0100158 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700159 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700160
161 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700162 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700163 system_modules: "core-all-system-modules",
164 openjdk9: {
165 javacflags: ["--patch-module=java.base=."],
166 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700167
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000168 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000169 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000170 "java.lang.Class",
171 "java.lang.Long",
172 "java.lang.Number",
173 "java.lang.Object",
174 "java.lang.String",
175 "java.lang.invoke.MethodHandle",
176 "java.lang.ref.Reference",
177 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000178 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000179 "java.util.HashMap",
180 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000181 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000182 ],
183 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700184
185 notice: "ojluni/NOTICE",
186
187 required: [
188 "tzdata",
189 "tzlookup.xml",
190 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700191
Colin Crossaf0b54c2017-09-27 17:22:32 -0700192}
193
194// Definitions to make the core library.
195java_library {
196 name: "core-libart",
197 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700198 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700199 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700200
Neil Fuller866ed4a2018-09-06 12:05:46 +0100201 srcs: [":core_libart_java_files"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700202 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700203
Colin Crossec80f4f2018-08-15 21:17:11 -0700204 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700205 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700206 system_modules: "core-all-system-modules",
207 openjdk9: {
208 javacflags: ["--patch-module=java.base=."],
209 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700210
Pete Gillin80ebe872018-02-13 15:21:20 +0000211 jacoco: {
212 exclude_filter: [
213 "java.lang.DexCache",
214 "dalvik.system.ClassExt",
215 ],
216 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700217
218 required: [
219 "tzdata",
220 "tzlookup.xml",
221 ],
222}
223
Colin Cross3c6c2e22017-10-18 13:24:52 -0700224// A guaranteed unstripped version of core-oj and core-libart.
225// The build system may or may not strip the core-oj and core-libart jars,
226// but these will not be stripped. See b/24535627.
227java_library {
228 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700229 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700230 static_libs: ["core-oj"],
231 no_standard_libs: true,
232 libs: ["core-all"],
233 system_modules: "core-all-system-modules",
234 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800235 dex_preopt: {
236 enabled: false,
237 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700238 notice: "ojluni/NOTICE",
239 required: [
240 "tzdata",
241 "tzlookup.xml",
242 ],
243}
244
245java_library {
246 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700247 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700248 static_libs: ["core-libart"],
249 no_standard_libs: true,
250 libs: ["core-all"],
251 system_modules: "core-all-system-modules",
252 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800253 dex_preopt: {
254 enabled: false,
255 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700256 notice: "ojluni/NOTICE",
257 required: [
258 "tzdata",
259 "tzlookup.xml",
260 ],
261}
262
Colin Crossaf0b54c2017-09-27 17:22:32 -0700263// A library that exists to satisfy javac when
264// compiling source code that contains lambdas.
265java_library {
266 name: "core-lambda-stubs",
267 defaults: ["libcore_java_defaults"],
268
269 srcs: [
270 ":openjdk_lambda_stub_files",
271 ":openjdk_lambda_duplicate_stub_files",
272 ],
273
Colin Crossec80f4f2018-08-15 21:17:11 -0700274 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700275 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700276 system_modules: "core-all-system-modules",
277 openjdk9: {
278 javacflags: ["--patch-module=java.base=."],
279 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700280
281 notice: "ojluni/NOTICE",
282
283 installable: false,
284 include_srcs: true,
285}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700286
Neil Fuller866ed4a2018-09-06 12:05:46 +0100287// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700288java_system_modules {
289 name: "core-system-modules",
290 libs: [
291 "core-oj",
292 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100293 "core-simple",
294 // This one is not on device but it's needed when javac compiles code
295 // containing lambdas.
296 "core-lambda-stubs"
Colin Crossa4d9fc42017-09-29 18:04:37 -0700297 ],
298}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700299
300// Build libcore test rules
301java_library_static {
302 name: "core-test-rules",
303 hostdex: true,
304 no_framework_libs: true,
305 srcs: [
306 "dalvik/test-rules/src/main/**/*.java",
307 "test-rules/src/main/**/*.java",
308 ],
309 static_libs: ["junit"],
310}
311
312// Make the core-tests-support library.
313java_library_static {
314 name: "core-tests-support",
315 hostdex: true,
316 no_framework_libs: true,
317 srcs: ["support/src/test/java/**/*.java"],
318 libs: [
319 "junit",
320 "bouncycastle",
321 ],
322 static_libs: [
323 "bouncycastle-bcpkix",
324 "bouncycastle-ocsp",
325 ],
326}
327
328// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700329java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700330 name: "jsr166-tests",
331 srcs: ["jsr166-tests/src/test/java/**/*.java"],
332 no_framework_libs: true,
333 libs: [
334 "junit",
335 ],
336}
Nan Zhang65f27a32018-01-05 10:41:46 -0800337
Colin Crossec80f4f2018-08-15 21:17:11 -0700338// Build a library just containing files from luni/src/test/filesystems for use in tests.
339java_library {
340 name: "filesystemstest",
341 compile_dex: true,
342 srcs: ["luni/src/test/filesystems/src/**/*.java"],
343 java_resource_dirs: ["luni/src/test/filesystems/resources"],
344 no_framework_libs: true,
345 errorprone: {
346 javacflags: ["-Xep:MissingOverride:OFF"],
347 },
348}
349
350// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
351java_library {
352 name: "parameter-metadata-test",
353 compile_dex: true,
354 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
355 no_framework_libs: true,
356 javacflags: ["-parameters"],
357 errorprone: {
358 javacflags: ["-Xep:MissingOverride:OFF"],
359 },
360}
361
362// Make the core-tests library.
363java_test {
364 name: "core-tests",
365 defaults: ["libcore_java_defaults"],
366 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100367 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700368 srcs: [
369 "dalvik/src/test/java/**/*.java",
370 "dalvik/test-rules/src/test/java/**/*.java",
371 "dom/src/test/java/**/*.java",
372 "harmony-tests/src/test/java/**/*.java",
373 "json/src/test/java/**/*.java",
374 "luni/src/test/java/**/*.java",
375 "xml/src/test/java/**/*.java",
376 ],
377 exclude_srcs: [
378 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
379 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
380 ],
381
382 java_resource_dirs: [
383 "*/src/test/java",
384 "*/src/test/resources",
385 ],
386 exclude_java_resource_dirs: [
387 "ojluni/src/test/java",
388 "ojluni/src/test/resources",
389 ],
390
391 java_resources: [
392 ":filesystemstest",
393 ":parameter-metadata-test",
394 ],
395
396 libs: [
397 "okhttp",
398 "bouncycastle",
399 ],
400 static_libs: [
401 "archive-patcher",
402 "core-test-rules",
403 "core-tests-support",
404 "junit-params",
405 "mockftpserver",
406 "mockito-target",
407 "mockwebserver",
408 "nist-pkix-tests",
409 "slf4j-jdk14",
410 "sqlite-jdbc",
411 "tzdata-testing",
412 ],
413
414 errorprone: {
415 javacflags: [
416 "-Xep:TryFailThrowable:ERROR",
417 "-Xep:ComparisonOutOfRange:ERROR",
418 ],
419 },
Simran Basi3be01e02018-08-21 17:53:49 -0700420
421 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700422}
423
424// Make the core-ojtests library.
425java_test {
426 name: "core-ojtests",
427 defaults: ["libcore_java_defaults"],
428 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100429 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700430
431 srcs: [
432 "ojluni/src/test/java/**/*.java",
433 ],
434 java_resource_dirs: [
435 "ojluni/src/test/java",
436 "ojluni/src/test/resources",
437 ],
438 libs: [
439 "okhttp",
440 "bouncycastle",
441 ],
442 static_libs: ["testng"],
443
444 // ojluni/src/test/java/util/stream/{bootlib,boottest}
445 // contains tests that are in packages from java.base;
446 // By default, OpenJDK 9's javac will only compile such
447 // code if it's declared to also be in java.base at
448 // compile time.
449 //
450 // For now, we use --patch-module to put all sources
451 // and dependencies from this make target into java.base;
452 // other source directories in this make target are in
453 // packages not from java.base; if this becomes a problem
454 // in future, this could be addressed eg. by splitting
455 // boot{lib,test} out into a separate make target,
456 // deleting those tests or moving them to a different
457 // package.
458 patch_module: "java.base",
459}
460
461// Make the core-ojtests-public library. Excludes any private API tests.
462java_test {
463 name: "core-ojtests-public",
464 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100465 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700466 srcs: [
467 "ojluni/src/test/java/**/*.java",
468 ],
469 // Filter out the following:
470 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
471 // and won't actually run, and
472 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
473 // excluding them means we don't need patch_module: "java.base"
474 exclude_srcs: [
475 "**/DeserializeMethodTest.java",
476 "**/SerializedLambdaTest.java",
477 "ojluni/src/test/java/util/stream/boot*/**/*",
478 ],
479 java_resource_dirs: [
480 "ojluni/src/test/java",
481 "ojluni/src/test/resources",
482 // Include source code as part of JAR
483 "ojluni/src/test/dist",
484 ],
485 libs: [
486 "bouncycastle",
487 "okhttp",
488 "testng",
489 ],
490}
491
Pete Gillin7db7faa2018-07-31 13:29:35 +0100492// Make the annotated stubs in ojluni/annotations available to metalava:
493droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100494 name: "ojluni-annotated-sdk-stubs",
495 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100496}
Pete Gillinc9935b62018-09-25 14:42:40 +0100497droiddoc_exported_dir {
498 name: "ojluni-annotated-mmodule-stubs",
499 path: "ojluni/annotations/mmodule",
500}
Pete Gillin7db7faa2018-07-31 13:29:35 +0100501
Neil Fuller6f16b462018-09-04 15:40:39 +0100502// A file containing the list of tags that are "known" to us from the OpenJdk
503// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800504filegroup {
505 name: "known-oj-tags",
506 srcs: [
507 "known_oj_tags.txt",
508 ],
509}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700510
Neil Fullera6ba3592018-09-21 13:19:37 +0100511// Stubs for the parts of the public SDK API provided by the core libraries.
Nan Zhangf0207602018-09-10 18:57:38 -0700512droidstubs {
513 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100514 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700515 installable: false,
516 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000517 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700518}
519
Neil Fullera6ba3592018-09-21 13:19:37 +0100520// A library containing the parts of the public SDK API provided by the core libraries.
521// Don't use this directly, use "sdk_version: core_current".
522java_library {
Nan Zhang602fc0e2018-03-22 16:14:22 -0700523 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700524 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700525 errorprone: {
526 javacflags: [
527 "-Xep:MissingOverride:OFF",
528 ],
529 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100530 openjdk9: {
531 javacflags: ["--patch-module=java.base=."],
532 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700533 no_standard_libs: true,
534 system_modules: "none",
535}