blob: a337a54b8f9119d1dc7ff02c80db60d66c9805da [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
81// annotations.
82filegroup {
83 name: "core_api_files",
84 srcs: [
85 ":core_oj_api_files",
86 ":core_libart_api_files",
87 ":core_simple_java_files",
88 ],
89}
90
Colin Crossaf0b54c2017-09-27 17:22:32 -070091java_defaults {
92 name: "libcore_java_defaults",
93 javacflags: [
94 //"-Xlint:all",
95 //"-Xlint:-serial,-deprecation,-unchecked",
96 ],
97 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -080098 errorprone: {
99 javacflags: [
100 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -0700101 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800102 ],
103 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700104}
105
106//
107// Build for the target (device).
108//
109
110java_library {
111 name: "core-all",
112 defaults: ["libcore_java_defaults"],
113
114 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100115 ":core_oj_java_files",
116 ":core_libart_java_files",
117 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700118 ":openjdk_lambda_stub_files",
119 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700120
121 no_standard_libs: true,
122 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700123 openjdk9: {
124 srcs: ["luni/src/module/java/module-info.java"],
125 javacflags: ["--patch-module=java.base=."],
126 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700127
Colin Crossaf0b54c2017-09-27 17:22:32 -0700128 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -0700129 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700130
131 required: [
132 "tzdata",
133 "tzlookup.xml",
134 ],
135
136 installable: false,
137}
138
Colin Crossa4d9fc42017-09-29 18:04:37 -0700139java_system_modules {
140 name: "core-all-system-modules",
141 libs: ["core-all"],
142}
143
Colin Crossaf0b54c2017-09-27 17:22:32 -0700144java_library {
145 name: "core-oj",
146 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700147 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700148 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700149
Neil Fuller866ed4a2018-09-06 12:05:46 +0100150 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700151 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700152
153 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700154 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700155 system_modules: "core-all-system-modules",
156 openjdk9: {
157 javacflags: ["--patch-module=java.base=."],
158 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700159
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000160 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000161 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000162 "java.lang.Class",
163 "java.lang.Long",
164 "java.lang.Number",
165 "java.lang.Object",
166 "java.lang.String",
167 "java.lang.invoke.MethodHandle",
168 "java.lang.ref.Reference",
169 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000170 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000171 "java.util.HashMap",
172 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000173 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000174 ],
175 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700176
177 notice: "ojluni/NOTICE",
178
179 required: [
180 "tzdata",
181 "tzlookup.xml",
182 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700183
Colin Crossaf0b54c2017-09-27 17:22:32 -0700184}
185
186// Definitions to make the core library.
187java_library {
188 name: "core-libart",
189 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700190 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700191 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700192
Neil Fuller866ed4a2018-09-06 12:05:46 +0100193 srcs: [":core_libart_java_files"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700194 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700195
Colin Crossec80f4f2018-08-15 21:17:11 -0700196 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700197 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700198 system_modules: "core-all-system-modules",
199 openjdk9: {
200 javacflags: ["--patch-module=java.base=."],
201 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700202
Pete Gillin80ebe872018-02-13 15:21:20 +0000203 jacoco: {
204 exclude_filter: [
205 "java.lang.DexCache",
206 "dalvik.system.ClassExt",
207 ],
208 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700209
210 required: [
211 "tzdata",
212 "tzlookup.xml",
213 ],
214}
215
Colin Cross3c6c2e22017-10-18 13:24:52 -0700216// A guaranteed unstripped version of core-oj and core-libart.
217// The build system may or may not strip the core-oj and core-libart jars,
218// but these will not be stripped. See b/24535627.
219java_library {
220 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700221 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700222 static_libs: ["core-oj"],
223 no_standard_libs: true,
224 libs: ["core-all"],
225 system_modules: "core-all-system-modules",
226 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800227 dex_preopt: {
228 enabled: false,
229 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700230 notice: "ojluni/NOTICE",
231 required: [
232 "tzdata",
233 "tzlookup.xml",
234 ],
235}
236
237java_library {
238 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700239 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700240 static_libs: ["core-libart"],
241 no_standard_libs: true,
242 libs: ["core-all"],
243 system_modules: "core-all-system-modules",
244 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800245 dex_preopt: {
246 enabled: false,
247 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700248 notice: "ojluni/NOTICE",
249 required: [
250 "tzdata",
251 "tzlookup.xml",
252 ],
253}
254
Colin Crossaf0b54c2017-09-27 17:22:32 -0700255// A library that exists to satisfy javac when
256// compiling source code that contains lambdas.
257java_library {
258 name: "core-lambda-stubs",
259 defaults: ["libcore_java_defaults"],
260
261 srcs: [
262 ":openjdk_lambda_stub_files",
263 ":openjdk_lambda_duplicate_stub_files",
264 ],
265
Colin Crossec80f4f2018-08-15 21:17:11 -0700266 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700267 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700268 system_modules: "core-all-system-modules",
269 openjdk9: {
270 javacflags: ["--patch-module=java.base=."],
271 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700272
273 notice: "ojluni/NOTICE",
274
275 installable: false,
276 include_srcs: true,
277}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700278
Neil Fuller866ed4a2018-09-06 12:05:46 +0100279// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700280java_system_modules {
281 name: "core-system-modules",
282 libs: [
283 "core-oj",
284 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100285 "core-simple",
286 // This one is not on device but it's needed when javac compiles code
287 // containing lambdas.
288 "core-lambda-stubs"
Colin Crossa4d9fc42017-09-29 18:04:37 -0700289 ],
290}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700291
292// Build libcore test rules
293java_library_static {
294 name: "core-test-rules",
295 hostdex: true,
296 no_framework_libs: true,
297 srcs: [
298 "dalvik/test-rules/src/main/**/*.java",
299 "test-rules/src/main/**/*.java",
300 ],
301 static_libs: ["junit"],
302}
303
304// Make the core-tests-support library.
305java_library_static {
306 name: "core-tests-support",
307 hostdex: true,
308 no_framework_libs: true,
309 srcs: ["support/src/test/java/**/*.java"],
310 libs: [
311 "junit",
312 "bouncycastle",
313 ],
314 static_libs: [
315 "bouncycastle-bcpkix",
316 "bouncycastle-ocsp",
317 ],
318}
319
320// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700321java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700322 name: "jsr166-tests",
323 srcs: ["jsr166-tests/src/test/java/**/*.java"],
324 no_framework_libs: true,
325 libs: [
326 "junit",
327 ],
328}
Nan Zhang65f27a32018-01-05 10:41:46 -0800329
Colin Crossec80f4f2018-08-15 21:17:11 -0700330// Build a library just containing files from luni/src/test/filesystems for use in tests.
331java_library {
332 name: "filesystemstest",
333 compile_dex: true,
334 srcs: ["luni/src/test/filesystems/src/**/*.java"],
335 java_resource_dirs: ["luni/src/test/filesystems/resources"],
336 no_framework_libs: true,
337 errorprone: {
338 javacflags: ["-Xep:MissingOverride:OFF"],
339 },
340}
341
342// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
343java_library {
344 name: "parameter-metadata-test",
345 compile_dex: true,
346 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
347 no_framework_libs: true,
348 javacflags: ["-parameters"],
349 errorprone: {
350 javacflags: ["-Xep:MissingOverride:OFF"],
351 },
352}
353
354// Make the core-tests library.
355java_test {
356 name: "core-tests",
357 defaults: ["libcore_java_defaults"],
358 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100359 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700360 srcs: [
361 "dalvik/src/test/java/**/*.java",
362 "dalvik/test-rules/src/test/java/**/*.java",
363 "dom/src/test/java/**/*.java",
364 "harmony-tests/src/test/java/**/*.java",
365 "json/src/test/java/**/*.java",
366 "luni/src/test/java/**/*.java",
367 "xml/src/test/java/**/*.java",
368 ],
369 exclude_srcs: [
370 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
371 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
372 ],
373
374 java_resource_dirs: [
375 "*/src/test/java",
376 "*/src/test/resources",
377 ],
378 exclude_java_resource_dirs: [
379 "ojluni/src/test/java",
380 "ojluni/src/test/resources",
381 ],
382
383 java_resources: [
384 ":filesystemstest",
385 ":parameter-metadata-test",
386 ],
387
388 libs: [
389 "okhttp",
390 "bouncycastle",
391 ],
392 static_libs: [
393 "archive-patcher",
394 "core-test-rules",
395 "core-tests-support",
396 "junit-params",
397 "mockftpserver",
398 "mockito-target",
399 "mockwebserver",
400 "nist-pkix-tests",
401 "slf4j-jdk14",
402 "sqlite-jdbc",
403 "tzdata-testing",
404 ],
405
406 errorprone: {
407 javacflags: [
408 "-Xep:TryFailThrowable:ERROR",
409 "-Xep:ComparisonOutOfRange:ERROR",
410 ],
411 },
412}
413
414// Make the core-ojtests library.
415java_test {
416 name: "core-ojtests",
417 defaults: ["libcore_java_defaults"],
418 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100419 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700420
421 srcs: [
422 "ojluni/src/test/java/**/*.java",
423 ],
424 java_resource_dirs: [
425 "ojluni/src/test/java",
426 "ojluni/src/test/resources",
427 ],
428 libs: [
429 "okhttp",
430 "bouncycastle",
431 ],
432 static_libs: ["testng"],
433
434 // ojluni/src/test/java/util/stream/{bootlib,boottest}
435 // contains tests that are in packages from java.base;
436 // By default, OpenJDK 9's javac will only compile such
437 // code if it's declared to also be in java.base at
438 // compile time.
439 //
440 // For now, we use --patch-module to put all sources
441 // and dependencies from this make target into java.base;
442 // other source directories in this make target are in
443 // packages not from java.base; if this becomes a problem
444 // in future, this could be addressed eg. by splitting
445 // boot{lib,test} out into a separate make target,
446 // deleting those tests or moving them to a different
447 // package.
448 patch_module: "java.base",
449}
450
451// Make the core-ojtests-public library. Excludes any private API tests.
452java_test {
453 name: "core-ojtests-public",
454 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100455 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700456 srcs: [
457 "ojluni/src/test/java/**/*.java",
458 ],
459 // Filter out the following:
460 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
461 // and won't actually run, and
462 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
463 // excluding them means we don't need patch_module: "java.base"
464 exclude_srcs: [
465 "**/DeserializeMethodTest.java",
466 "**/SerializedLambdaTest.java",
467 "ojluni/src/test/java/util/stream/boot*/**/*",
468 ],
469 java_resource_dirs: [
470 "ojluni/src/test/java",
471 "ojluni/src/test/resources",
472 // Include source code as part of JAR
473 "ojluni/src/test/dist",
474 ],
475 libs: [
476 "bouncycastle",
477 "okhttp",
478 "testng",
479 ],
480}
481
Pete Gillin7db7faa2018-07-31 13:29:35 +0100482// Make the annotated stubs in ojluni/annotations available to metalava:
483droiddoc_exported_dir {
484 name: "ojluni-annotated-stubs",
485 path: "ojluni/annotations",
486}
487
Neil Fuller6f16b462018-09-04 15:40:39 +0100488// A file containing the list of tags that are "known" to us from the OpenJdk
489// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800490filegroup {
491 name: "known-oj-tags",
492 srcs: [
493 "known_oj_tags.txt",
494 ],
495}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700496
Neil Fuller2f49d692018-09-04 15:47:11 +0100497droiddoc {
498 name: "core-current-stubs-gen-docs",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100499 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700500 installable: false,
501 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000502 metalava_enabled: true,
503 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700504}
505
506java_library_static {
507 name: "core.current.stubs",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100508 srcs: [":core-current-stubs-gen-docs"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700509 errorprone: {
510 javacflags: [
511 "-Xep:MissingOverride:OFF",
512 ],
513 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100514 openjdk9: {
515 javacflags: ["--patch-module=java.base=."],
516 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700517 no_standard_libs: true,
518 system_modules: "none",
519}
Neil Fullercf756882018-08-28 18:42:22 +0100520