blob: 295b09fd0ea4c89fe9b297276fb50e095157a602 [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,
314 srcs: [
315 "dalvik/src/test/java/**/*.java",
316 "dalvik/test-rules/src/test/java/**/*.java",
317 "dom/src/test/java/**/*.java",
318 "harmony-tests/src/test/java/**/*.java",
319 "json/src/test/java/**/*.java",
320 "luni/src/test/java/**/*.java",
321 "xml/src/test/java/**/*.java",
322 ],
323 exclude_srcs: [
324 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
325 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
326 ],
327
328 java_resource_dirs: [
329 "*/src/test/java",
330 "*/src/test/resources",
331 ],
332 exclude_java_resource_dirs: [
333 "ojluni/src/test/java",
334 "ojluni/src/test/resources",
335 ],
336
337 java_resources: [
338 ":filesystemstest",
339 ":parameter-metadata-test",
340 ],
341
342 libs: [
343 "okhttp",
344 "bouncycastle",
345 ],
346 static_libs: [
347 "archive-patcher",
348 "core-test-rules",
349 "core-tests-support",
350 "junit-params",
351 "mockftpserver",
352 "mockito-target",
353 "mockwebserver",
354 "nist-pkix-tests",
355 "slf4j-jdk14",
356 "sqlite-jdbc",
357 "tzdata-testing",
358 ],
359
360 errorprone: {
361 javacflags: [
362 "-Xep:TryFailThrowable:ERROR",
363 "-Xep:ComparisonOutOfRange:ERROR",
364 ],
365 },
366}
367
368// Make the core-ojtests library.
369java_test {
370 name: "core-ojtests",
371 defaults: ["libcore_java_defaults"],
372 hostdex: true,
373
374 srcs: [
375 "ojluni/src/test/java/**/*.java",
376 ],
377 java_resource_dirs: [
378 "ojluni/src/test/java",
379 "ojluni/src/test/resources",
380 ],
381 libs: [
382 "okhttp",
383 "bouncycastle",
384 ],
385 static_libs: ["testng"],
386
387 // ojluni/src/test/java/util/stream/{bootlib,boottest}
388 // contains tests that are in packages from java.base;
389 // By default, OpenJDK 9's javac will only compile such
390 // code if it's declared to also be in java.base at
391 // compile time.
392 //
393 // For now, we use --patch-module to put all sources
394 // and dependencies from this make target into java.base;
395 // other source directories in this make target are in
396 // packages not from java.base; if this becomes a problem
397 // in future, this could be addressed eg. by splitting
398 // boot{lib,test} out into a separate make target,
399 // deleting those tests or moving them to a different
400 // package.
401 patch_module: "java.base",
402}
403
404// Make the core-ojtests-public library. Excludes any private API tests.
405java_test {
406 name: "core-ojtests-public",
407 defaults: ["libcore_java_defaults"],
408 srcs: [
409 "ojluni/src/test/java/**/*.java",
410 ],
411 // Filter out the following:
412 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
413 // and won't actually run, and
414 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
415 // excluding them means we don't need patch_module: "java.base"
416 exclude_srcs: [
417 "**/DeserializeMethodTest.java",
418 "**/SerializedLambdaTest.java",
419 "ojluni/src/test/java/util/stream/boot*/**/*",
420 ],
421 java_resource_dirs: [
422 "ojluni/src/test/java",
423 "ojluni/src/test/resources",
424 // Include source code as part of JAR
425 "ojluni/src/test/dist",
426 ],
427 libs: [
428 "bouncycastle",
429 "okhttp",
430 "testng",
431 ],
432}
433
Nan Zhang65f27a32018-01-05 10:41:46 -0800434genrule {
435 name: "gen-ojluni-jaif-annotated-srcs",
436 tools: [
437 "gen-annotated-java-files-bp",
438 "soong_zip",
439 ],
440 tool_files: [
441 ":insert-annotations-to-source",
442 "annotations/ojluni.jaif",
443 ],
444 srcs: [
445 ":annotated_ojluni_files",
446 ],
447 cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800448 "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800449 "(echo -e \"********************\" >&2; " +
450 " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " +
451 " 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 -0800452 " echo -e \"********************\" >&2; exit 1) ) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800453 "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800454 "(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 -0800455 "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
456 out: [
457 "ojluni_jaif_annotated_srcs.srcjar",
458 ],
459}
460
Pete Gillin7db7faa2018-07-31 13:29:35 +0100461// Make the annotated stubs in ojluni/annotations available to metalava:
462droiddoc_exported_dir {
463 name: "ojluni-annotated-stubs",
464 path: "ojluni/annotations",
465}
466
Nan Zhang3824a822018-03-21 21:41:02 +0000467//
468// Local droiddoc for faster libcore testing
469//
470// Run with:
471// mm -j32 core-docs
472//
473// Main output:
Pete Gillincfd6db72018-08-13 16:35:18 +0100474// ../out/soong/.intermediates/libcore/core-docs/android_common/out/reference/packages.html
Nan Zhang3824a822018-03-21 21:41:02 +0000475//
476// All text for proofreading (or running tools over):
477// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
478//
479// TODO list of missing javadoc, etc:
Pete Gillincfd6db72018-08-13 16:35:18 +0100480// ../out/soong/.intermediates/libcore/core-docs/android_common/out/core-docs-todo.html
Nan Zhang3824a822018-03-21 21:41:02 +0000481//
Nan Zhang65f27a32018-01-05 10:41:46 -0800482droiddoc {
483 name: "core-docs",
484 srcs: [
485 ":openjdk_javadoc_files",
486 ":non_openjdk_javadoc_files",
487 ":android_icu4j_src_files_for_docs",
488 ":gen-ojluni-jaif-annotated-srcs",
489 ],
490 exclude_srcs: [
491 ":annotated_ojluni_files",
492 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800493 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800494 hdf: [
495 "android.whichdoc offline",
496 ],
497 knowntags: [
498 "known_oj_tags.txt",
499 ],
500 proofread_file: "core-docs-proofread.txt",
501 todo_file: "core-docs-todo.html",
502 args: "-offlinemode -title \"libcore\"",
503}
Nan Zhangd55722b2018-02-27 15:08:20 -0800504
505filegroup {
506 name: "known-oj-tags",
507 srcs: [
508 "known_oj_tags.txt",
509 ],
510}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700511
512droiddoc {
513 name: "core-current-stubs-gen-docs",
514 srcs: [
515 ":openjdk_javadoc_files",
516 ":non_openjdk_javadoc_files",
517 ":android_icu4j_src_files_for_docs",
518 ":gen-ojluni-jaif-annotated-srcs",
519 ],
520 exclude_srcs: [
521 ":annotated_ojluni_files",
522 ],
523 custom_template: "droiddoc-templates-sdk",
524 installable: false,
525 no_framework_libs: true,
526 args: "-nodocs",
527}
528
529java_library_static {
530 name: "core.current.stubs",
531 srcs: [
532 ":core-current-stubs-gen-docs",
533 ],
534 errorprone: {
535 javacflags: [
536 "-Xep:MissingOverride:OFF",
537 ],
538 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100539 openjdk9: {
540 javacflags: ["--patch-module=java.base=."],
541 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700542 no_standard_libs: true,
543 system_modules: "none",
544}