blob: 15ded36bde44b58c7c5075dde5c6219fd32628a9 [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",
38]
39
40// The Java files and their associated resources.
41core_resource_dirs = [
42 "luni/src/main/java",
43 "ojluni/src/main/resources/",
44]
45
46java_defaults {
47 name: "libcore_java_defaults",
48 javacflags: [
49 //"-Xlint:all",
50 //"-Xlint:-serial,-deprecation,-unchecked",
51 ],
52 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -080053 errorprone: {
54 javacflags: [
55 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -070056 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -080057 ],
58 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070059}
60
61//
62// Build for the target (device).
63//
64
65java_library {
66 name: "core-all",
67 defaults: ["libcore_java_defaults"],
68
69 srcs: [
70 ":openjdk_java_files",
71 ":non_openjdk_java_files",
72 ":android_icu4j_src_files",
73 ":openjdk_lambda_stub_files",
74 ],
Colin Crossec80f4f2018-08-15 21:17:11 -070075
76 no_standard_libs: true,
77 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -070078 openjdk9: {
79 srcs: ["luni/src/module/java/module-info.java"],
80 javacflags: ["--patch-module=java.base=."],
81 },
Colin Crossec80f4f2018-08-15 21:17:11 -070082
Colin Crossaf0b54c2017-09-27 17:22:32 -070083 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -070084 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -070085
86 required: [
87 "tzdata",
88 "tzlookup.xml",
89 ],
90
91 installable: false,
92}
93
Colin Crossa4d9fc42017-09-29 18:04:37 -070094java_system_modules {
95 name: "core-all-system-modules",
96 libs: ["core-all"],
97}
98
Colin Crossaf0b54c2017-09-27 17:22:32 -070099java_library {
100 name: "core-oj",
101 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700102 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700103 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700104
105 srcs: [":openjdk_java_files"],
106 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700107
108 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700109 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700110 system_modules: "core-all-system-modules",
111 openjdk9: {
112 javacflags: ["--patch-module=java.base=."],
113 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700114
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000115 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000116 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000117 "java.lang.Class",
118 "java.lang.Long",
119 "java.lang.Number",
120 "java.lang.Object",
121 "java.lang.String",
122 "java.lang.invoke.MethodHandle",
123 "java.lang.ref.Reference",
124 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000125 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000126 "java.util.HashMap",
127 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000128 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000129 ],
130 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700131
132 notice: "ojluni/NOTICE",
133
134 required: [
135 "tzdata",
136 "tzlookup.xml",
137 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700138
Colin Crossaf0b54c2017-09-27 17:22:32 -0700139}
140
141// Definitions to make the core library.
142java_library {
143 name: "core-libart",
144 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700145 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700146 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700147
148 srcs: [
149 ":non_openjdk_java_files",
150 ":android_icu4j_src_files",
151 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700152 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700153
Colin Crossec80f4f2018-08-15 21:17:11 -0700154 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700155 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700156 system_modules: "core-all-system-modules",
157 openjdk9: {
158 javacflags: ["--patch-module=java.base=."],
159 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700160
Pete Gillin80ebe872018-02-13 15:21:20 +0000161 jacoco: {
162 exclude_filter: [
163 "java.lang.DexCache",
164 "dalvik.system.ClassExt",
165 ],
166 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700167
168 required: [
169 "tzdata",
170 "tzlookup.xml",
171 ],
172}
173
Colin Cross3c6c2e22017-10-18 13:24:52 -0700174// A guaranteed unstripped version of core-oj and core-libart.
175// The build system may or may not strip the core-oj and core-libart jars,
176// but these will not be stripped. See b/24535627.
177java_library {
178 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700179 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700180 static_libs: ["core-oj"],
181 no_standard_libs: true,
182 libs: ["core-all"],
183 system_modules: "core-all-system-modules",
184 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800185 dex_preopt: {
186 enabled: false,
187 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700188 notice: "ojluni/NOTICE",
189 required: [
190 "tzdata",
191 "tzlookup.xml",
192 ],
193}
194
195java_library {
196 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700197 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700198 static_libs: ["core-libart"],
199 no_standard_libs: true,
200 libs: ["core-all"],
201 system_modules: "core-all-system-modules",
202 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800203 dex_preopt: {
204 enabled: false,
205 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700206 notice: "ojluni/NOTICE",
207 required: [
208 "tzdata",
209 "tzlookup.xml",
210 ],
211}
212
Colin Crossaf0b54c2017-09-27 17:22:32 -0700213// A library that exists to satisfy javac when
214// compiling source code that contains lambdas.
215java_library {
216 name: "core-lambda-stubs",
217 defaults: ["libcore_java_defaults"],
218
219 srcs: [
220 ":openjdk_lambda_stub_files",
221 ":openjdk_lambda_duplicate_stub_files",
222 ],
223
Colin Crossec80f4f2018-08-15 21:17:11 -0700224 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700225 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700226 system_modules: "core-all-system-modules",
227 openjdk9: {
228 javacflags: ["--patch-module=java.base=."],
229 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700230
231 notice: "ojluni/NOTICE",
232
233 installable: false,
234 include_srcs: true,
235}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700236
237java_system_modules {
238 name: "core-system-modules",
239 libs: [
240 "core-oj",
241 "core-libart",
242 "core-lambda-stubs",
243 ],
244}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700245
246// Build libcore test rules
247java_library_static {
248 name: "core-test-rules",
249 hostdex: true,
250 no_framework_libs: true,
251 srcs: [
252 "dalvik/test-rules/src/main/**/*.java",
253 "test-rules/src/main/**/*.java",
254 ],
255 static_libs: ["junit"],
256}
257
258// Make the core-tests-support library.
259java_library_static {
260 name: "core-tests-support",
261 hostdex: true,
262 no_framework_libs: true,
263 srcs: ["support/src/test/java/**/*.java"],
264 libs: [
265 "junit",
266 "bouncycastle",
267 ],
268 static_libs: [
269 "bouncycastle-bcpkix",
270 "bouncycastle-ocsp",
271 ],
272}
273
274// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700275java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700276 name: "jsr166-tests",
277 srcs: ["jsr166-tests/src/test/java/**/*.java"],
278 no_framework_libs: true,
279 libs: [
280 "junit",
281 ],
282}
Nan Zhang65f27a32018-01-05 10:41:46 -0800283
Colin Crossec80f4f2018-08-15 21:17:11 -0700284// Build a library just containing files from luni/src/test/filesystems for use in tests.
285java_library {
286 name: "filesystemstest",
287 compile_dex: true,
288 srcs: ["luni/src/test/filesystems/src/**/*.java"],
289 java_resource_dirs: ["luni/src/test/filesystems/resources"],
290 no_framework_libs: true,
291 errorprone: {
292 javacflags: ["-Xep:MissingOverride:OFF"],
293 },
294}
295
296// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
297java_library {
298 name: "parameter-metadata-test",
299 compile_dex: true,
300 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
301 no_framework_libs: true,
302 javacflags: ["-parameters"],
303 errorprone: {
304 javacflags: ["-Xep:MissingOverride:OFF"],
305 },
306}
307
308// Make the core-tests library.
309java_test {
310 name: "core-tests",
311 defaults: ["libcore_java_defaults"],
312 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100313 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700314 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 },
Simran Basi3be01e02018-08-21 17:53:49 -0700366
367 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700368}
369
370// Make the core-ojtests library.
371java_test {
372 name: "core-ojtests",
373 defaults: ["libcore_java_defaults"],
374 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100375 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700376
377 srcs: [
378 "ojluni/src/test/java/**/*.java",
379 ],
380 java_resource_dirs: [
381 "ojluni/src/test/java",
382 "ojluni/src/test/resources",
383 ],
384 libs: [
385 "okhttp",
386 "bouncycastle",
387 ],
388 static_libs: ["testng"],
389
390 // ojluni/src/test/java/util/stream/{bootlib,boottest}
391 // contains tests that are in packages from java.base;
392 // By default, OpenJDK 9's javac will only compile such
393 // code if it's declared to also be in java.base at
394 // compile time.
395 //
396 // For now, we use --patch-module to put all sources
397 // and dependencies from this make target into java.base;
398 // other source directories in this make target are in
399 // packages not from java.base; if this becomes a problem
400 // in future, this could be addressed eg. by splitting
401 // boot{lib,test} out into a separate make target,
402 // deleting those tests or moving them to a different
403 // package.
404 patch_module: "java.base",
405}
406
407// Make the core-ojtests-public library. Excludes any private API tests.
408java_test {
409 name: "core-ojtests-public",
410 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100411 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700412 srcs: [
413 "ojluni/src/test/java/**/*.java",
414 ],
415 // Filter out the following:
416 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
417 // and won't actually run, and
418 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
419 // excluding them means we don't need patch_module: "java.base"
420 exclude_srcs: [
421 "**/DeserializeMethodTest.java",
422 "**/SerializedLambdaTest.java",
423 "ojluni/src/test/java/util/stream/boot*/**/*",
424 ],
425 java_resource_dirs: [
426 "ojluni/src/test/java",
427 "ojluni/src/test/resources",
428 // Include source code as part of JAR
429 "ojluni/src/test/dist",
430 ],
431 libs: [
432 "bouncycastle",
433 "okhttp",
434 "testng",
435 ],
436}
437
Pete Gillin7db7faa2018-07-31 13:29:35 +0100438// Make the annotated stubs in ojluni/annotations available to metalava:
439droiddoc_exported_dir {
440 name: "ojluni-annotated-stubs",
441 path: "ojluni/annotations",
442}
443
Nan Zhang3824a822018-03-21 21:41:02 +0000444//
445// Local droiddoc for faster libcore testing
446//
447// Run with:
448// mm -j32 core-docs
449//
450// Main output:
Pete Gillincfd6db72018-08-13 16:35:18 +0100451// ../out/soong/.intermediates/libcore/core-docs/android_common/out/reference/packages.html
Nan Zhang3824a822018-03-21 21:41:02 +0000452//
453// All text for proofreading (or running tools over):
454// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
455//
456// TODO list of missing javadoc, etc:
Pete Gillincfd6db72018-08-13 16:35:18 +0100457// ../out/soong/.intermediates/libcore/core-docs/android_common/out/core-docs-todo.html
Nan Zhang3824a822018-03-21 21:41:02 +0000458//
Nan Zhang65f27a32018-01-05 10:41:46 -0800459droiddoc {
460 name: "core-docs",
461 srcs: [
462 ":openjdk_javadoc_files",
463 ":non_openjdk_javadoc_files",
464 ":android_icu4j_src_files_for_docs",
Nan Zhang65f27a32018-01-05 10:41:46 -0800465 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800466 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800467 hdf: [
468 "android.whichdoc offline",
469 ],
470 knowntags: [
471 "known_oj_tags.txt",
472 ],
473 proofread_file: "core-docs-proofread.txt",
474 todo_file: "core-docs-todo.html",
Nan Zhang68c55b42018-08-21 17:31:51 +0000475 metalava_enabled: true,
476 args: " --exclude-annotations --generate-documentation -offlinemode -title \"libcore\"",
Nan Zhang65f27a32018-01-05 10:41:46 -0800477}
Nan Zhangd55722b2018-02-27 15:08:20 -0800478
Nan Zhangb1510762018-06-22 10:49:18 -0700479droiddoc {
480 name: "metalava-dokka-core-docs",
481 srcs: [
482 ":openjdk_javadoc_files",
483 ":non_openjdk_javadoc_files",
484 ":android_icu4j_src_files_for_docs",
Nan Zhangb1510762018-06-22 10:49:18 -0700485 ],
486 metalava_enabled: true,
487 dokka_enabled: true,
488 args: "--generate-documentation"
489}
490
Nan Zhangd55722b2018-02-27 15:08:20 -0800491filegroup {
492 name: "known-oj-tags",
493 srcs: [
494 "known_oj_tags.txt",
495 ],
496}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700497
498droiddoc {
499 name: "core-current-stubs-gen-docs",
500 srcs: [
501 ":openjdk_javadoc_files",
502 ":non_openjdk_javadoc_files",
503 ":android_icu4j_src_files_for_docs",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700504 ],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700505 installable: false,
506 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000507 metalava_enabled: true,
508 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700509}
510
511java_library_static {
512 name: "core.current.stubs",
513 srcs: [
514 ":core-current-stubs-gen-docs",
515 ],
516 errorprone: {
517 javacflags: [
518 "-Xep:MissingOverride:OFF",
519 ],
520 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100521 openjdk9: {
522 javacflags: ["--patch-module=java.base=."],
523 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700524 no_standard_libs: true,
525 system_modules: "none",
526}