blob: c8044fcfdb297768de183620bed8716471e23a69 [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
Victor Chang7fef4052018-09-25 14:12:03 +0100118// Rule generating resource lib for android_icu4j.
119// In the downstream branch master-icu-dev, the resource files are generated.
120// This rule can't be moved external/icu because soong enforces that no_standard_libs:true can only
121// be used in libcore/ or development/
122java_library {
123 name: "android_icu4j_resources_lib",
124 java_resources: [":android_icu4j_resources"],
125 no_standard_libs: true,
126 system_modules: "none",
127}
128
Colin Crossaf0b54c2017-09-27 17:22:32 -0700129java_library {
130 name: "core-all",
131 defaults: ["libcore_java_defaults"],
132
133 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100134 ":core_oj_java_files",
135 ":core_libart_java_files",
136 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700137 ":openjdk_lambda_stub_files",
138 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700139
140 no_standard_libs: true,
141 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700142 openjdk9: {
143 srcs: ["luni/src/module/java/module-info.java"],
144 javacflags: ["--patch-module=java.base=."],
145 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700146
Colin Crossaf0b54c2017-09-27 17:22:32 -0700147 java_resource_dirs: core_resource_dirs,
Victor Chang7fef4052018-09-25 14:12:03 +0100148 static_libs: ["android_icu4j_resources_lib"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700149
150 required: [
151 "tzdata",
152 "tzlookup.xml",
153 ],
154
155 installable: false,
156}
157
Colin Crossa4d9fc42017-09-29 18:04:37 -0700158java_system_modules {
159 name: "core-all-system-modules",
160 libs: ["core-all"],
161}
162
Colin Crossaf0b54c2017-09-27 17:22:32 -0700163java_library {
164 name: "core-oj",
165 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700166 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700167 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700168
Neil Fuller866ed4a2018-09-06 12:05:46 +0100169 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700170 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700171
172 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700173 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700174 system_modules: "core-all-system-modules",
175 openjdk9: {
176 javacflags: ["--patch-module=java.base=."],
177 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700178
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000179 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000180 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000181 "java.lang.Class",
182 "java.lang.Long",
183 "java.lang.Number",
184 "java.lang.Object",
185 "java.lang.String",
186 "java.lang.invoke.MethodHandle",
187 "java.lang.ref.Reference",
188 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000189 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000190 "java.util.HashMap",
191 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000192 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000193 ],
194 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700195
196 notice: "ojluni/NOTICE",
197
198 required: [
199 "tzdata",
200 "tzlookup.xml",
201 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700202
Colin Crossaf0b54c2017-09-27 17:22:32 -0700203}
204
205// Definitions to make the core library.
206java_library {
207 name: "core-libart",
208 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700209 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700210 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700211
Neil Fuller866ed4a2018-09-06 12:05:46 +0100212 srcs: [":core_libart_java_files"],
Victor Chang7fef4052018-09-25 14:12:03 +0100213 static_libs: ["android_icu4j_resources_lib"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700214
Colin Crossec80f4f2018-08-15 21:17:11 -0700215 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700216 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700217 system_modules: "core-all-system-modules",
218 openjdk9: {
219 javacflags: ["--patch-module=java.base=."],
220 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700221
Pete Gillin80ebe872018-02-13 15:21:20 +0000222 jacoco: {
223 exclude_filter: [
224 "java.lang.DexCache",
225 "dalvik.system.ClassExt",
226 ],
227 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700228
229 required: [
230 "tzdata",
231 "tzlookup.xml",
232 ],
233}
234
Colin Cross3c6c2e22017-10-18 13:24:52 -0700235// A guaranteed unstripped version of core-oj and core-libart.
236// The build system may or may not strip the core-oj and core-libart jars,
237// but these will not be stripped. See b/24535627.
238java_library {
239 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700240 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700241 static_libs: ["core-oj"],
242 no_standard_libs: true,
243 libs: ["core-all"],
244 system_modules: "core-all-system-modules",
245 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800246 dex_preopt: {
247 enabled: false,
248 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700249 notice: "ojluni/NOTICE",
250 required: [
251 "tzdata",
252 "tzlookup.xml",
253 ],
254}
255
256java_library {
257 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700258 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700259 static_libs: ["core-libart"],
260 no_standard_libs: true,
261 libs: ["core-all"],
262 system_modules: "core-all-system-modules",
263 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800264 dex_preopt: {
265 enabled: false,
266 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700267 notice: "ojluni/NOTICE",
268 required: [
269 "tzdata",
270 "tzlookup.xml",
271 ],
272}
273
Colin Crossaf0b54c2017-09-27 17:22:32 -0700274// A library that exists to satisfy javac when
275// compiling source code that contains lambdas.
276java_library {
277 name: "core-lambda-stubs",
278 defaults: ["libcore_java_defaults"],
279
280 srcs: [
281 ":openjdk_lambda_stub_files",
282 ":openjdk_lambda_duplicate_stub_files",
283 ],
284
Colin Crossec80f4f2018-08-15 21:17:11 -0700285 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700286 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700287 system_modules: "core-all-system-modules",
288 openjdk9: {
289 javacflags: ["--patch-module=java.base=."],
290 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700291
292 notice: "ojluni/NOTICE",
293
294 installable: false,
295 include_srcs: true,
296}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700297
Neil Fuller866ed4a2018-09-06 12:05:46 +0100298// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700299java_system_modules {
300 name: "core-system-modules",
301 libs: [
302 "core-oj",
303 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100304 "core-simple",
305 // This one is not on device but it's needed when javac compiles code
306 // containing lambdas.
307 "core-lambda-stubs"
Colin Crossa4d9fc42017-09-29 18:04:37 -0700308 ],
309}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700310
311// Build libcore test rules
312java_library_static {
313 name: "core-test-rules",
314 hostdex: true,
315 no_framework_libs: true,
316 srcs: [
317 "dalvik/test-rules/src/main/**/*.java",
318 "test-rules/src/main/**/*.java",
319 ],
320 static_libs: ["junit"],
321}
322
323// Make the core-tests-support library.
324java_library_static {
325 name: "core-tests-support",
326 hostdex: true,
327 no_framework_libs: true,
328 srcs: ["support/src/test/java/**/*.java"],
329 libs: [
330 "junit",
331 "bouncycastle",
332 ],
333 static_libs: [
334 "bouncycastle-bcpkix",
335 "bouncycastle-ocsp",
336 ],
337}
338
339// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700340java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700341 name: "jsr166-tests",
342 srcs: ["jsr166-tests/src/test/java/**/*.java"],
343 no_framework_libs: true,
344 libs: [
345 "junit",
346 ],
347}
Nan Zhang65f27a32018-01-05 10:41:46 -0800348
Colin Crossec80f4f2018-08-15 21:17:11 -0700349// Build a library just containing files from luni/src/test/filesystems for use in tests.
350java_library {
351 name: "filesystemstest",
352 compile_dex: true,
353 srcs: ["luni/src/test/filesystems/src/**/*.java"],
354 java_resource_dirs: ["luni/src/test/filesystems/resources"],
355 no_framework_libs: true,
356 errorprone: {
357 javacflags: ["-Xep:MissingOverride:OFF"],
358 },
359}
360
361// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
362java_library {
363 name: "parameter-metadata-test",
364 compile_dex: true,
365 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
366 no_framework_libs: true,
367 javacflags: ["-parameters"],
368 errorprone: {
369 javacflags: ["-Xep:MissingOverride:OFF"],
370 },
371}
372
373// Make the core-tests library.
374java_test {
375 name: "core-tests",
376 defaults: ["libcore_java_defaults"],
377 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100378 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700379 srcs: [
380 "dalvik/src/test/java/**/*.java",
381 "dalvik/test-rules/src/test/java/**/*.java",
382 "dom/src/test/java/**/*.java",
383 "harmony-tests/src/test/java/**/*.java",
384 "json/src/test/java/**/*.java",
385 "luni/src/test/java/**/*.java",
386 "xml/src/test/java/**/*.java",
387 ],
388 exclude_srcs: [
389 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
390 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
391 ],
392
393 java_resource_dirs: [
394 "*/src/test/java",
395 "*/src/test/resources",
396 ],
397 exclude_java_resource_dirs: [
398 "ojluni/src/test/java",
399 "ojluni/src/test/resources",
400 ],
401
402 java_resources: [
403 ":filesystemstest",
404 ":parameter-metadata-test",
405 ],
406
407 libs: [
408 "okhttp",
409 "bouncycastle",
410 ],
411 static_libs: [
412 "archive-patcher",
413 "core-test-rules",
414 "core-tests-support",
415 "junit-params",
416 "mockftpserver",
417 "mockito-target",
418 "mockwebserver",
419 "nist-pkix-tests",
420 "slf4j-jdk14",
421 "sqlite-jdbc",
422 "tzdata-testing",
423 ],
424
425 errorprone: {
426 javacflags: [
427 "-Xep:TryFailThrowable:ERROR",
428 "-Xep:ComparisonOutOfRange:ERROR",
429 ],
430 },
Simran Basi3be01e02018-08-21 17:53:49 -0700431
432 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700433}
434
435// Make the core-ojtests library.
436java_test {
437 name: "core-ojtests",
438 defaults: ["libcore_java_defaults"],
439 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100440 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700441
442 srcs: [
443 "ojluni/src/test/java/**/*.java",
444 ],
445 java_resource_dirs: [
446 "ojluni/src/test/java",
447 "ojluni/src/test/resources",
448 ],
449 libs: [
450 "okhttp",
451 "bouncycastle",
452 ],
453 static_libs: ["testng"],
454
455 // ojluni/src/test/java/util/stream/{bootlib,boottest}
456 // contains tests that are in packages from java.base;
457 // By default, OpenJDK 9's javac will only compile such
458 // code if it's declared to also be in java.base at
459 // compile time.
460 //
461 // For now, we use --patch-module to put all sources
462 // and dependencies from this make target into java.base;
463 // other source directories in this make target are in
464 // packages not from java.base; if this becomes a problem
465 // in future, this could be addressed eg. by splitting
466 // boot{lib,test} out into a separate make target,
467 // deleting those tests or moving them to a different
468 // package.
469 patch_module: "java.base",
470}
471
472// Make the core-ojtests-public library. Excludes any private API tests.
473java_test {
474 name: "core-ojtests-public",
475 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100476 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700477 srcs: [
478 "ojluni/src/test/java/**/*.java",
479 ],
480 // Filter out the following:
481 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
482 // and won't actually run, and
483 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
484 // excluding them means we don't need patch_module: "java.base"
485 exclude_srcs: [
486 "**/DeserializeMethodTest.java",
487 "**/SerializedLambdaTest.java",
488 "ojluni/src/test/java/util/stream/boot*/**/*",
489 ],
490 java_resource_dirs: [
491 "ojluni/src/test/java",
492 "ojluni/src/test/resources",
493 // Include source code as part of JAR
494 "ojluni/src/test/dist",
495 ],
496 libs: [
497 "bouncycastle",
498 "okhttp",
499 "testng",
500 ],
501}
502
Pete Gillin7db7faa2018-07-31 13:29:35 +0100503// Make the annotated stubs in ojluni/annotations available to metalava:
504droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100505 name: "ojluni-annotated-sdk-stubs",
506 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100507}
Pete Gillinc9935b62018-09-25 14:42:40 +0100508droiddoc_exported_dir {
509 name: "ojluni-annotated-mmodule-stubs",
510 path: "ojluni/annotations/mmodule",
511}
Pete Gillin7db7faa2018-07-31 13:29:35 +0100512
Neil Fuller6f16b462018-09-04 15:40:39 +0100513// A file containing the list of tags that are "known" to us from the OpenJdk
514// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800515filegroup {
516 name: "known-oj-tags",
517 srcs: [
518 "known_oj_tags.txt",
519 ],
520}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700521
Neil Fullera6ba3592018-09-21 13:19:37 +0100522// Stubs for the parts of the public SDK API provided by the core libraries.
Nan Zhangf0207602018-09-10 18:57:38 -0700523droidstubs {
524 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100525 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700526 installable: false,
527 no_framework_libs: true,
Neil Fullerbe9258e2018-09-24 17:11:27 +0100528 args: " --exclude-annotations "
529 + "--hide-annotation libcore.api.Hide",
530 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700531}
532
Neil Fullera6ba3592018-09-21 13:19:37 +0100533// A library containing the parts of the public SDK API provided by the core libraries.
534// Don't use this directly, use "sdk_version: core_current".
535java_library {
Nan Zhang602fc0e2018-03-22 16:14:22 -0700536 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700537 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700538 errorprone: {
539 javacflags: [
540 "-Xep:MissingOverride:OFF",
541 ],
542 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100543 openjdk9: {
544 javacflags: ["--patch-module=java.base=."],
545 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700546 no_standard_libs: true,
547 system_modules: "none",
548}