blob: 9fdbf7fcf0a9dbe4849d9260e3cae2d01bcbbd7e [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: [
Neil Fullera77f7102018-09-21 19:04:41 +010085 ":bouncycastle_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010086 ":core_oj_api_files",
87 ":core_libart_api_files",
88 ":core_simple_java_files",
Neil Fuller641d5f92018-09-24 15:40:39 +010089 ":okhttp_api_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010090 ],
91}
92
Colin Crossaf0b54c2017-09-27 17:22:32 -070093java_defaults {
94 name: "libcore_java_defaults",
95 javacflags: [
96 //"-Xlint:all",
97 //"-Xlint:-serial,-deprecation,-unchecked",
98 ],
99 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800100 errorprone: {
101 javacflags: [
102 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -0700103 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800104 ],
105 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700106}
107
108//
109// Build for the target (device).
110//
111
112java_library {
113 name: "core-all",
114 defaults: ["libcore_java_defaults"],
115
116 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100117 ":core_oj_java_files",
118 ":core_libart_java_files",
119 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700120 ":openjdk_lambda_stub_files",
121 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700122
123 no_standard_libs: true,
124 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700125 openjdk9: {
126 srcs: ["luni/src/module/java/module-info.java"],
127 javacflags: ["--patch-module=java.base=."],
128 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700129
Colin Crossaf0b54c2017-09-27 17:22:32 -0700130 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -0700131 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700132
133 required: [
134 "tzdata",
135 "tzlookup.xml",
136 ],
137
138 installable: false,
139}
140
Colin Crossa4d9fc42017-09-29 18:04:37 -0700141java_system_modules {
142 name: "core-all-system-modules",
143 libs: ["core-all"],
144}
145
Colin Crossaf0b54c2017-09-27 17:22:32 -0700146java_library {
147 name: "core-oj",
148 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700149 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700150 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700151
Neil Fuller866ed4a2018-09-06 12:05:46 +0100152 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700153 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700154
155 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 Gillin7a7a6d22017-12-19 14:56:03 +0000162 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000163 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000164 "java.lang.Class",
165 "java.lang.Long",
166 "java.lang.Number",
167 "java.lang.Object",
168 "java.lang.String",
169 "java.lang.invoke.MethodHandle",
170 "java.lang.ref.Reference",
171 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000172 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000173 "java.util.HashMap",
174 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000175 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000176 ],
177 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700178
179 notice: "ojluni/NOTICE",
180
181 required: [
182 "tzdata",
183 "tzlookup.xml",
184 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700185
Colin Crossaf0b54c2017-09-27 17:22:32 -0700186}
187
188// Definitions to make the core library.
189java_library {
190 name: "core-libart",
191 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700192 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700193 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700194
Neil Fuller866ed4a2018-09-06 12:05:46 +0100195 srcs: [":core_libart_java_files"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700196 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700197
Colin Crossec80f4f2018-08-15 21:17:11 -0700198 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700199 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700200 system_modules: "core-all-system-modules",
201 openjdk9: {
202 javacflags: ["--patch-module=java.base=."],
203 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700204
Pete Gillin80ebe872018-02-13 15:21:20 +0000205 jacoco: {
206 exclude_filter: [
207 "java.lang.DexCache",
208 "dalvik.system.ClassExt",
209 ],
210 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700211
212 required: [
213 "tzdata",
214 "tzlookup.xml",
215 ],
216}
217
Colin Cross3c6c2e22017-10-18 13:24:52 -0700218// A guaranteed unstripped version of core-oj and core-libart.
219// The build system may or may not strip the core-oj and core-libart jars,
220// but these will not be stripped. See b/24535627.
221java_library {
222 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700223 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700224 static_libs: ["core-oj"],
225 no_standard_libs: true,
226 libs: ["core-all"],
227 system_modules: "core-all-system-modules",
228 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800229 dex_preopt: {
230 enabled: false,
231 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700232 notice: "ojluni/NOTICE",
233 required: [
234 "tzdata",
235 "tzlookup.xml",
236 ],
237}
238
239java_library {
240 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700241 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700242 static_libs: ["core-libart"],
243 no_standard_libs: true,
244 libs: ["core-all"],
245 system_modules: "core-all-system-modules",
246 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800247 dex_preopt: {
248 enabled: false,
249 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700250 notice: "ojluni/NOTICE",
251 required: [
252 "tzdata",
253 "tzlookup.xml",
254 ],
255}
256
Colin Crossaf0b54c2017-09-27 17:22:32 -0700257// A library that exists to satisfy javac when
258// compiling source code that contains lambdas.
259java_library {
260 name: "core-lambda-stubs",
261 defaults: ["libcore_java_defaults"],
262
263 srcs: [
264 ":openjdk_lambda_stub_files",
265 ":openjdk_lambda_duplicate_stub_files",
266 ],
267
Colin Crossec80f4f2018-08-15 21:17:11 -0700268 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700269 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700270 system_modules: "core-all-system-modules",
271 openjdk9: {
272 javacflags: ["--patch-module=java.base=."],
273 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700274
275 notice: "ojluni/NOTICE",
276
277 installable: false,
278 include_srcs: true,
279}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700280
Neil Fuller866ed4a2018-09-06 12:05:46 +0100281// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700282java_system_modules {
283 name: "core-system-modules",
284 libs: [
285 "core-oj",
286 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100287 "core-simple",
288 // This one is not on device but it's needed when javac compiles code
289 // containing lambdas.
290 "core-lambda-stubs"
Colin Crossa4d9fc42017-09-29 18:04:37 -0700291 ],
292}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700293
294// Build libcore test rules
295java_library_static {
296 name: "core-test-rules",
297 hostdex: true,
298 no_framework_libs: true,
299 srcs: [
300 "dalvik/test-rules/src/main/**/*.java",
301 "test-rules/src/main/**/*.java",
302 ],
303 static_libs: ["junit"],
304}
305
306// Make the core-tests-support library.
307java_library_static {
308 name: "core-tests-support",
309 hostdex: true,
310 no_framework_libs: true,
311 srcs: ["support/src/test/java/**/*.java"],
312 libs: [
313 "junit",
314 "bouncycastle",
315 ],
316 static_libs: [
317 "bouncycastle-bcpkix",
318 "bouncycastle-ocsp",
319 ],
320}
321
322// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700323java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700324 name: "jsr166-tests",
325 srcs: ["jsr166-tests/src/test/java/**/*.java"],
326 no_framework_libs: true,
327 libs: [
328 "junit",
329 ],
330}
Nan Zhang65f27a32018-01-05 10:41:46 -0800331
Colin Crossec80f4f2018-08-15 21:17:11 -0700332// Build a library just containing files from luni/src/test/filesystems for use in tests.
333java_library {
334 name: "filesystemstest",
335 compile_dex: true,
336 srcs: ["luni/src/test/filesystems/src/**/*.java"],
337 java_resource_dirs: ["luni/src/test/filesystems/resources"],
338 no_framework_libs: true,
339 errorprone: {
340 javacflags: ["-Xep:MissingOverride:OFF"],
341 },
342}
343
344// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
345java_library {
346 name: "parameter-metadata-test",
347 compile_dex: true,
348 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
349 no_framework_libs: true,
350 javacflags: ["-parameters"],
351 errorprone: {
352 javacflags: ["-Xep:MissingOverride:OFF"],
353 },
354}
355
356// Make the core-tests library.
357java_test {
358 name: "core-tests",
359 defaults: ["libcore_java_defaults"],
360 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100361 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700362 srcs: [
363 "dalvik/src/test/java/**/*.java",
364 "dalvik/test-rules/src/test/java/**/*.java",
365 "dom/src/test/java/**/*.java",
366 "harmony-tests/src/test/java/**/*.java",
367 "json/src/test/java/**/*.java",
368 "luni/src/test/java/**/*.java",
369 "xml/src/test/java/**/*.java",
370 ],
371 exclude_srcs: [
372 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
373 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
374 ],
375
376 java_resource_dirs: [
377 "*/src/test/java",
378 "*/src/test/resources",
379 ],
380 exclude_java_resource_dirs: [
381 "ojluni/src/test/java",
382 "ojluni/src/test/resources",
383 ],
384
385 java_resources: [
386 ":filesystemstest",
387 ":parameter-metadata-test",
388 ],
389
390 libs: [
391 "okhttp",
392 "bouncycastle",
393 ],
394 static_libs: [
395 "archive-patcher",
396 "core-test-rules",
397 "core-tests-support",
398 "junit-params",
399 "mockftpserver",
400 "mockito-target",
401 "mockwebserver",
402 "nist-pkix-tests",
403 "slf4j-jdk14",
404 "sqlite-jdbc",
405 "tzdata-testing",
406 ],
407
408 errorprone: {
409 javacflags: [
410 "-Xep:TryFailThrowable:ERROR",
411 "-Xep:ComparisonOutOfRange:ERROR",
412 ],
413 },
Simran Basi3be01e02018-08-21 17:53:49 -0700414
415 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700416}
417
418// Make the core-ojtests library.
419java_test {
420 name: "core-ojtests",
421 defaults: ["libcore_java_defaults"],
422 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100423 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700424
425 srcs: [
426 "ojluni/src/test/java/**/*.java",
427 ],
428 java_resource_dirs: [
429 "ojluni/src/test/java",
430 "ojluni/src/test/resources",
431 ],
432 libs: [
433 "okhttp",
434 "bouncycastle",
435 ],
436 static_libs: ["testng"],
437
438 // ojluni/src/test/java/util/stream/{bootlib,boottest}
439 // contains tests that are in packages from java.base;
440 // By default, OpenJDK 9's javac will only compile such
441 // code if it's declared to also be in java.base at
442 // compile time.
443 //
444 // For now, we use --patch-module to put all sources
445 // and dependencies from this make target into java.base;
446 // other source directories in this make target are in
447 // packages not from java.base; if this becomes a problem
448 // in future, this could be addressed eg. by splitting
449 // boot{lib,test} out into a separate make target,
450 // deleting those tests or moving them to a different
451 // package.
452 patch_module: "java.base",
453}
454
455// Make the core-ojtests-public library. Excludes any private API tests.
456java_test {
457 name: "core-ojtests-public",
458 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100459 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700460 srcs: [
461 "ojluni/src/test/java/**/*.java",
462 ],
463 // Filter out the following:
464 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
465 // and won't actually run, and
466 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
467 // excluding them means we don't need patch_module: "java.base"
468 exclude_srcs: [
469 "**/DeserializeMethodTest.java",
470 "**/SerializedLambdaTest.java",
471 "ojluni/src/test/java/util/stream/boot*/**/*",
472 ],
473 java_resource_dirs: [
474 "ojluni/src/test/java",
475 "ojluni/src/test/resources",
476 // Include source code as part of JAR
477 "ojluni/src/test/dist",
478 ],
479 libs: [
480 "bouncycastle",
481 "okhttp",
482 "testng",
483 ],
484}
485
Pete Gillin7db7faa2018-07-31 13:29:35 +0100486// Make the annotated stubs in ojluni/annotations available to metalava:
487droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100488 name: "ojluni-annotated-sdk-stubs",
489 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100490}
491
Neil Fuller6f16b462018-09-04 15:40:39 +0100492// A file containing the list of tags that are "known" to us from the OpenJdk
493// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800494filegroup {
495 name: "known-oj-tags",
496 srcs: [
497 "known_oj_tags.txt",
498 ],
499}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700500
Neil Fullera6ba3592018-09-21 13:19:37 +0100501// Stubs for the parts of the public SDK API provided by the core libraries.
Nan Zhangf0207602018-09-10 18:57:38 -0700502droidstubs {
503 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100504 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700505 installable: false,
506 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000507 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700508}
509
Neil Fullera6ba3592018-09-21 13:19:37 +0100510// A library containing the parts of the public SDK API provided by the core libraries.
511// Don't use this directly, use "sdk_version: core_current".
512java_library {
Nan Zhang602fc0e2018-03-22 16:14:22 -0700513 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700514 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700515 errorprone: {
516 javacflags: [
517 "-Xep:MissingOverride:OFF",
518 ],
519 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100520 openjdk9: {
521 javacflags: ["--patch-module=java.base=."],
522 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700523 no_standard_libs: true,
524 system_modules: "none",
525}