blob: 64eb5a780d6f59cf46e82cadfd9b98e83720c4fa [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
19// libcore is divided into modules.
20//
21// The structure of each module is:
22//
23// src/
24// main/ # To be shipped on every device.
25// java/ # Java source for library code.
26// native/ # C++ source for library code.
27// resources/ # Support files.
28// test/ # Built only on demand, for testing.
29// java/ # Java source for tests.
30// native/ # C++ source for tests (rare).
31// resources/ # Support files.
32//
33// All subdirectories are optional
34
35build = [
36 "openjdk_java_files.bp",
37 "non_openjdk_java_files.bp",
Colin Crossfb7218e2017-10-27 17:50:42 +000038 "annotated_java_files.bp",
Colin Crossaf0b54c2017-09-27 17:22:32 -070039]
40
41// The Java files and their associated resources.
42core_resource_dirs = [
43 "luni/src/main/java",
44 "ojluni/src/main/resources/",
45]
46
47java_defaults {
48 name: "libcore_java_defaults",
49 javacflags: [
50 //"-Xlint:all",
51 //"-Xlint:-serial,-deprecation,-unchecked",
52 ],
53 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -080054 errorprone: {
55 javacflags: [
56 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -070057 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -080058 ],
59 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070060}
61
62//
63// Build for the target (device).
64//
65
66java_library {
67 name: "core-all",
68 defaults: ["libcore_java_defaults"],
69
70 srcs: [
71 ":openjdk_java_files",
72 ":non_openjdk_java_files",
73 ":android_icu4j_src_files",
74 ":openjdk_lambda_stub_files",
75 ],
Colin Crossec80f4f2018-08-15 21:17:11 -070076
77 no_standard_libs: true,
78 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -070079 openjdk9: {
80 srcs: ["luni/src/module/java/module-info.java"],
81 javacflags: ["--patch-module=java.base=."],
82 },
Colin Crossec80f4f2018-08-15 21:17:11 -070083
Colin Crossaf0b54c2017-09-27 17:22:32 -070084 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -070085 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -070086
87 required: [
88 "tzdata",
89 "tzlookup.xml",
90 ],
91
92 installable: false,
93}
94
Colin Crossa4d9fc42017-09-29 18:04:37 -070095java_system_modules {
96 name: "core-all-system-modules",
97 libs: ["core-all"],
98}
99
Colin Crossaf0b54c2017-09-27 17:22:32 -0700100java_library {
101 name: "core-oj",
102 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700103 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700104 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700105
106 srcs: [":openjdk_java_files"],
107 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700108
109 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700110 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700111 system_modules: "core-all-system-modules",
112 openjdk9: {
113 javacflags: ["--patch-module=java.base=."],
114 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700115
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000116 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000117 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000118 "java.lang.Class",
119 "java.lang.Long",
120 "java.lang.Number",
121 "java.lang.Object",
122 "java.lang.String",
123 "java.lang.invoke.MethodHandle",
124 "java.lang.ref.Reference",
125 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000126 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000127 "java.util.HashMap",
128 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000129 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000130 ],
131 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700132
133 notice: "ojluni/NOTICE",
134
135 required: [
136 "tzdata",
137 "tzlookup.xml",
138 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700139
Colin Crossaf0b54c2017-09-27 17:22:32 -0700140}
141
142// Definitions to make the core library.
143java_library {
144 name: "core-libart",
145 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700146 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700147 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700148
149 srcs: [
150 ":non_openjdk_java_files",
151 ":android_icu4j_src_files",
152 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700153 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700154
Colin Crossec80f4f2018-08-15 21:17:11 -0700155 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700156 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700157 system_modules: "core-all-system-modules",
158 openjdk9: {
159 javacflags: ["--patch-module=java.base=."],
160 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700161
Pete Gillin80ebe872018-02-13 15:21:20 +0000162 jacoco: {
163 exclude_filter: [
164 "java.lang.DexCache",
165 "dalvik.system.ClassExt",
166 ],
167 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700168
169 required: [
170 "tzdata",
171 "tzlookup.xml",
172 ],
173}
174
Colin Cross3c6c2e22017-10-18 13:24:52 -0700175// A guaranteed unstripped version of core-oj and core-libart.
176// The build system may or may not strip the core-oj and core-libart jars,
177// but these will not be stripped. See b/24535627.
178java_library {
179 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700180 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700181 static_libs: ["core-oj"],
182 no_standard_libs: true,
183 libs: ["core-all"],
184 system_modules: "core-all-system-modules",
185 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800186 dex_preopt: {
187 enabled: false,
188 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700189 notice: "ojluni/NOTICE",
190 required: [
191 "tzdata",
192 "tzlookup.xml",
193 ],
194}
195
196java_library {
197 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700198 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700199 static_libs: ["core-libart"],
200 no_standard_libs: true,
201 libs: ["core-all"],
202 system_modules: "core-all-system-modules",
203 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800204 dex_preopt: {
205 enabled: false,
206 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700207 notice: "ojluni/NOTICE",
208 required: [
209 "tzdata",
210 "tzlookup.xml",
211 ],
212}
213
Colin Crossaf0b54c2017-09-27 17:22:32 -0700214// A library that exists to satisfy javac when
215// compiling source code that contains lambdas.
216java_library {
217 name: "core-lambda-stubs",
218 defaults: ["libcore_java_defaults"],
219
220 srcs: [
221 ":openjdk_lambda_stub_files",
222 ":openjdk_lambda_duplicate_stub_files",
223 ],
224
Colin Crossec80f4f2018-08-15 21:17:11 -0700225 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700226 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700227 system_modules: "core-all-system-modules",
228 openjdk9: {
229 javacflags: ["--patch-module=java.base=."],
230 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700231
232 notice: "ojluni/NOTICE",
233
234 installable: false,
235 include_srcs: true,
236}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700237
238java_system_modules {
239 name: "core-system-modules",
240 libs: [
241 "core-oj",
242 "core-libart",
243 "core-lambda-stubs",
244 ],
245}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700246
247// Build libcore test rules
248java_library_static {
249 name: "core-test-rules",
250 hostdex: true,
251 no_framework_libs: true,
252 srcs: [
253 "dalvik/test-rules/src/main/**/*.java",
254 "test-rules/src/main/**/*.java",
255 ],
256 static_libs: ["junit"],
257}
258
259// Make the core-tests-support library.
260java_library_static {
261 name: "core-tests-support",
262 hostdex: true,
263 no_framework_libs: true,
264 srcs: ["support/src/test/java/**/*.java"],
265 libs: [
266 "junit",
267 "bouncycastle",
268 ],
269 static_libs: [
270 "bouncycastle-bcpkix",
271 "bouncycastle-ocsp",
272 ],
273}
274
275// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700276java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700277 name: "jsr166-tests",
278 srcs: ["jsr166-tests/src/test/java/**/*.java"],
279 no_framework_libs: true,
280 libs: [
281 "junit",
282 ],
283}
Nan Zhang65f27a32018-01-05 10:41:46 -0800284
Colin Crossec80f4f2018-08-15 21:17:11 -0700285// Build a library just containing files from luni/src/test/filesystems for use in tests.
286java_library {
287 name: "filesystemstest",
288 compile_dex: true,
289 srcs: ["luni/src/test/filesystems/src/**/*.java"],
290 java_resource_dirs: ["luni/src/test/filesystems/resources"],
291 no_framework_libs: true,
292 errorprone: {
293 javacflags: ["-Xep:MissingOverride:OFF"],
294 },
295}
296
297// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
298java_library {
299 name: "parameter-metadata-test",
300 compile_dex: true,
301 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
302 no_framework_libs: true,
303 javacflags: ["-parameters"],
304 errorprone: {
305 javacflags: ["-Xep:MissingOverride:OFF"],
306 },
307}
308
309// Make the core-tests library.
310java_test {
311 name: "core-tests",
312 defaults: ["libcore_java_defaults"],
313 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100314 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700315 srcs: [
316 "dalvik/src/test/java/**/*.java",
317 "dalvik/test-rules/src/test/java/**/*.java",
318 "dom/src/test/java/**/*.java",
319 "harmony-tests/src/test/java/**/*.java",
320 "json/src/test/java/**/*.java",
321 "luni/src/test/java/**/*.java",
322 "xml/src/test/java/**/*.java",
323 ],
324 exclude_srcs: [
325 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
326 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
327 ],
328
329 java_resource_dirs: [
330 "*/src/test/java",
331 "*/src/test/resources",
332 ],
333 exclude_java_resource_dirs: [
334 "ojluni/src/test/java",
335 "ojluni/src/test/resources",
336 ],
337
338 java_resources: [
339 ":filesystemstest",
340 ":parameter-metadata-test",
341 ],
342
343 libs: [
344 "okhttp",
345 "bouncycastle",
346 ],
347 static_libs: [
348 "archive-patcher",
349 "core-test-rules",
350 "core-tests-support",
351 "junit-params",
352 "mockftpserver",
353 "mockito-target",
354 "mockwebserver",
355 "nist-pkix-tests",
356 "slf4j-jdk14",
357 "sqlite-jdbc",
358 "tzdata-testing",
359 ],
360
361 errorprone: {
362 javacflags: [
363 "-Xep:TryFailThrowable:ERROR",
364 "-Xep:ComparisonOutOfRange:ERROR",
365 ],
366 },
367}
368
369// Make the core-ojtests library.
370java_test {
371 name: "core-ojtests",
372 defaults: ["libcore_java_defaults"],
373 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100374 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700375
376 srcs: [
377 "ojluni/src/test/java/**/*.java",
378 ],
379 java_resource_dirs: [
380 "ojluni/src/test/java",
381 "ojluni/src/test/resources",
382 ],
383 libs: [
384 "okhttp",
385 "bouncycastle",
386 ],
387 static_libs: ["testng"],
388
389 // ojluni/src/test/java/util/stream/{bootlib,boottest}
390 // contains tests that are in packages from java.base;
391 // By default, OpenJDK 9's javac will only compile such
392 // code if it's declared to also be in java.base at
393 // compile time.
394 //
395 // For now, we use --patch-module to put all sources
396 // and dependencies from this make target into java.base;
397 // other source directories in this make target are in
398 // packages not from java.base; if this becomes a problem
399 // in future, this could be addressed eg. by splitting
400 // boot{lib,test} out into a separate make target,
401 // deleting those tests or moving them to a different
402 // package.
403 patch_module: "java.base",
404}
405
406// Make the core-ojtests-public library. Excludes any private API tests.
407java_test {
408 name: "core-ojtests-public",
409 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100410 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700411 srcs: [
412 "ojluni/src/test/java/**/*.java",
413 ],
414 // Filter out the following:
415 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
416 // and won't actually run, and
417 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
418 // excluding them means we don't need patch_module: "java.base"
419 exclude_srcs: [
420 "**/DeserializeMethodTest.java",
421 "**/SerializedLambdaTest.java",
422 "ojluni/src/test/java/util/stream/boot*/**/*",
423 ],
424 java_resource_dirs: [
425 "ojluni/src/test/java",
426 "ojluni/src/test/resources",
427 // Include source code as part of JAR
428 "ojluni/src/test/dist",
429 ],
430 libs: [
431 "bouncycastle",
432 "okhttp",
433 "testng",
434 ],
435}
436
Nan Zhang65f27a32018-01-05 10:41:46 -0800437genrule {
438 name: "gen-ojluni-jaif-annotated-srcs",
439 tools: [
440 "gen-annotated-java-files-bp",
441 "soong_zip",
442 ],
443 tool_files: [
444 ":insert-annotations-to-source",
445 "annotations/ojluni.jaif",
446 ],
447 srcs: [
448 ":annotated_ojluni_files",
449 ],
450 cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800451 "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800452 "(echo -e \"********************\" >&2; " +
453 " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " +
454 " echo -e \"libcore/annotations/generate_annotated_java_files.py libcore/annotations/ojluni.jaif > libcore/annotated_java_files.bp\" >&2; " +
Nan Zhang8c561442018-02-27 17:21:49 -0800455 " echo -e \"********************\" >&2; exit 1) ) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800456 "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800457 "(external/annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -d $(genDir) $(location annotations/ojluni.jaif) $(in)) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800458 "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
459 out: [
460 "ojluni_jaif_annotated_srcs.srcjar",
461 ],
462}
463
Pete Gillin7db7faa2018-07-31 13:29:35 +0100464// Make the annotated stubs in ojluni/annotations available to metalava:
465droiddoc_exported_dir {
466 name: "ojluni-annotated-stubs",
467 path: "ojluni/annotations",
468}
469
Nan Zhang3824a822018-03-21 21:41:02 +0000470//
471// Local droiddoc for faster libcore testing
472//
473// Run with:
474// mm -j32 core-docs
475//
476// Main output:
Pete Gillincfd6db72018-08-13 16:35:18 +0100477// ../out/soong/.intermediates/libcore/core-docs/android_common/out/reference/packages.html
Nan Zhang3824a822018-03-21 21:41:02 +0000478//
479// All text for proofreading (or running tools over):
480// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
481//
482// TODO list of missing javadoc, etc:
Pete Gillincfd6db72018-08-13 16:35:18 +0100483// ../out/soong/.intermediates/libcore/core-docs/android_common/out/core-docs-todo.html
Nan Zhang3824a822018-03-21 21:41:02 +0000484//
Nan Zhang65f27a32018-01-05 10:41:46 -0800485droiddoc {
486 name: "core-docs",
487 srcs: [
488 ":openjdk_javadoc_files",
489 ":non_openjdk_javadoc_files",
490 ":android_icu4j_src_files_for_docs",
491 ":gen-ojluni-jaif-annotated-srcs",
492 ],
493 exclude_srcs: [
494 ":annotated_ojluni_files",
495 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800496 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800497 hdf: [
498 "android.whichdoc offline",
499 ],
500 knowntags: [
501 "known_oj_tags.txt",
502 ],
503 proofread_file: "core-docs-proofread.txt",
504 todo_file: "core-docs-todo.html",
Nan Zhang68c55b42018-08-21 17:31:51 +0000505 metalava_enabled: true,
506 args: " --exclude-annotations --generate-documentation -offlinemode -title \"libcore\"",
Nan Zhang65f27a32018-01-05 10:41:46 -0800507}
Nan Zhangd55722b2018-02-27 15:08:20 -0800508
509filegroup {
510 name: "known-oj-tags",
511 srcs: [
512 "known_oj_tags.txt",
513 ],
514}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700515
516droiddoc {
517 name: "core-current-stubs-gen-docs",
518 srcs: [
519 ":openjdk_javadoc_files",
520 ":non_openjdk_javadoc_files",
521 ":android_icu4j_src_files_for_docs",
522 ":gen-ojluni-jaif-annotated-srcs",
523 ],
524 exclude_srcs: [
525 ":annotated_ojluni_files",
526 ],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700527 installable: false,
528 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000529 metalava_enabled: true,
530 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700531}
532
533java_library_static {
534 name: "core.current.stubs",
535 srcs: [
536 ":core-current-stubs-gen-docs",
537 ],
538 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}