blob: 4276511d68aff39b60c112768ff4777f1787ef83 [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 Fuller603e1a72018-09-25 11:55:41 +010086 ":conscrypt_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010087 ":core_oj_api_files",
88 ":core_libart_api_files",
89 ":core_simple_java_files",
Neil Fuller641d5f92018-09-24 15:40:39 +010090 ":okhttp_api_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010091 ],
92}
93
Colin Crossaf0b54c2017-09-27 17:22:32 -070094java_defaults {
95 name: "libcore_java_defaults",
96 javacflags: [
97 //"-Xlint:all",
98 //"-Xlint:-serial,-deprecation,-unchecked",
99 ],
100 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800101 errorprone: {
102 javacflags: [
103 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -0700104 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800105 ],
106 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700107}
108
109//
110// Build for the target (device).
111//
112
113java_library {
114 name: "core-all",
115 defaults: ["libcore_java_defaults"],
116
117 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100118 ":core_oj_java_files",
119 ":core_libart_java_files",
120 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700121 ":openjdk_lambda_stub_files",
122 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700123
124 no_standard_libs: true,
125 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700126 openjdk9: {
127 srcs: ["luni/src/module/java/module-info.java"],
128 javacflags: ["--patch-module=java.base=."],
129 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700130
Colin Crossaf0b54c2017-09-27 17:22:32 -0700131 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -0700132 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700133
134 required: [
135 "tzdata",
136 "tzlookup.xml",
137 ],
138
139 installable: false,
140}
141
Colin Crossa4d9fc42017-09-29 18:04:37 -0700142java_system_modules {
143 name: "core-all-system-modules",
144 libs: ["core-all"],
145}
146
Colin Crossaf0b54c2017-09-27 17:22:32 -0700147java_library {
148 name: "core-oj",
149 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700150 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700151 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700152
Neil Fuller866ed4a2018-09-06 12:05:46 +0100153 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700154 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700155
156 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700157 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700158 system_modules: "core-all-system-modules",
159 openjdk9: {
160 javacflags: ["--patch-module=java.base=."],
161 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700162
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000163 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000164 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000165 "java.lang.Class",
166 "java.lang.Long",
167 "java.lang.Number",
168 "java.lang.Object",
169 "java.lang.String",
170 "java.lang.invoke.MethodHandle",
171 "java.lang.ref.Reference",
172 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000173 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000174 "java.util.HashMap",
175 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000176 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000177 ],
178 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700179
180 notice: "ojluni/NOTICE",
181
182 required: [
183 "tzdata",
184 "tzlookup.xml",
185 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700186
Colin Crossaf0b54c2017-09-27 17:22:32 -0700187}
188
189// Definitions to make the core library.
190java_library {
191 name: "core-libart",
192 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700193 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700194 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700195
Neil Fuller866ed4a2018-09-06 12:05:46 +0100196 srcs: [":core_libart_java_files"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700197 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700198
Colin Crossec80f4f2018-08-15 21:17:11 -0700199 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700200 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700201 system_modules: "core-all-system-modules",
202 openjdk9: {
203 javacflags: ["--patch-module=java.base=."],
204 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700205
Pete Gillin80ebe872018-02-13 15:21:20 +0000206 jacoco: {
207 exclude_filter: [
208 "java.lang.DexCache",
209 "dalvik.system.ClassExt",
210 ],
211 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700212
213 required: [
214 "tzdata",
215 "tzlookup.xml",
216 ],
217}
218
Colin Cross3c6c2e22017-10-18 13:24:52 -0700219// A guaranteed unstripped version of core-oj and core-libart.
220// The build system may or may not strip the core-oj and core-libart jars,
221// but these will not be stripped. See b/24535627.
222java_library {
223 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700224 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700225 static_libs: ["core-oj"],
226 no_standard_libs: true,
227 libs: ["core-all"],
228 system_modules: "core-all-system-modules",
229 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800230 dex_preopt: {
231 enabled: false,
232 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700233 notice: "ojluni/NOTICE",
234 required: [
235 "tzdata",
236 "tzlookup.xml",
237 ],
238}
239
240java_library {
241 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700242 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700243 static_libs: ["core-libart"],
244 no_standard_libs: true,
245 libs: ["core-all"],
246 system_modules: "core-all-system-modules",
247 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800248 dex_preopt: {
249 enabled: false,
250 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700251 notice: "ojluni/NOTICE",
252 required: [
253 "tzdata",
254 "tzlookup.xml",
255 ],
256}
257
Colin Crossaf0b54c2017-09-27 17:22:32 -0700258// A library that exists to satisfy javac when
259// compiling source code that contains lambdas.
260java_library {
261 name: "core-lambda-stubs",
262 defaults: ["libcore_java_defaults"],
263
264 srcs: [
265 ":openjdk_lambda_stub_files",
266 ":openjdk_lambda_duplicate_stub_files",
267 ],
268
Colin Crossec80f4f2018-08-15 21:17:11 -0700269 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700270 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700271 system_modules: "core-all-system-modules",
272 openjdk9: {
273 javacflags: ["--patch-module=java.base=."],
274 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700275
276 notice: "ojluni/NOTICE",
277
278 installable: false,
279 include_srcs: true,
280}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700281
Neil Fuller866ed4a2018-09-06 12:05:46 +0100282// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700283java_system_modules {
284 name: "core-system-modules",
285 libs: [
286 "core-oj",
287 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100288 "core-simple",
289 // This one is not on device but it's needed when javac compiles code
290 // containing lambdas.
291 "core-lambda-stubs"
Colin Crossa4d9fc42017-09-29 18:04:37 -0700292 ],
293}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700294
295// Build libcore test rules
296java_library_static {
297 name: "core-test-rules",
298 hostdex: true,
299 no_framework_libs: true,
300 srcs: [
301 "dalvik/test-rules/src/main/**/*.java",
302 "test-rules/src/main/**/*.java",
303 ],
304 static_libs: ["junit"],
305}
306
307// Make the core-tests-support library.
308java_library_static {
309 name: "core-tests-support",
310 hostdex: true,
311 no_framework_libs: true,
312 srcs: ["support/src/test/java/**/*.java"],
313 libs: [
314 "junit",
315 "bouncycastle",
316 ],
317 static_libs: [
318 "bouncycastle-bcpkix",
319 "bouncycastle-ocsp",
320 ],
321}
322
323// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700324java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700325 name: "jsr166-tests",
326 srcs: ["jsr166-tests/src/test/java/**/*.java"],
327 no_framework_libs: true,
328 libs: [
329 "junit",
330 ],
331}
Nan Zhang65f27a32018-01-05 10:41:46 -0800332
Colin Crossec80f4f2018-08-15 21:17:11 -0700333// Build a library just containing files from luni/src/test/filesystems for use in tests.
334java_library {
335 name: "filesystemstest",
336 compile_dex: true,
337 srcs: ["luni/src/test/filesystems/src/**/*.java"],
338 java_resource_dirs: ["luni/src/test/filesystems/resources"],
339 no_framework_libs: true,
340 errorprone: {
341 javacflags: ["-Xep:MissingOverride:OFF"],
342 },
343}
344
345// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
346java_library {
347 name: "parameter-metadata-test",
348 compile_dex: true,
349 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
350 no_framework_libs: true,
351 javacflags: ["-parameters"],
352 errorprone: {
353 javacflags: ["-Xep:MissingOverride:OFF"],
354 },
355}
356
357// Make the core-tests library.
358java_test {
359 name: "core-tests",
360 defaults: ["libcore_java_defaults"],
361 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100362 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700363 srcs: [
364 "dalvik/src/test/java/**/*.java",
365 "dalvik/test-rules/src/test/java/**/*.java",
366 "dom/src/test/java/**/*.java",
367 "harmony-tests/src/test/java/**/*.java",
368 "json/src/test/java/**/*.java",
369 "luni/src/test/java/**/*.java",
370 "xml/src/test/java/**/*.java",
371 ],
372 exclude_srcs: [
373 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
374 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
375 ],
376
377 java_resource_dirs: [
378 "*/src/test/java",
379 "*/src/test/resources",
380 ],
381 exclude_java_resource_dirs: [
382 "ojluni/src/test/java",
383 "ojluni/src/test/resources",
384 ],
385
386 java_resources: [
387 ":filesystemstest",
388 ":parameter-metadata-test",
389 ],
390
391 libs: [
392 "okhttp",
393 "bouncycastle",
394 ],
395 static_libs: [
396 "archive-patcher",
397 "core-test-rules",
398 "core-tests-support",
399 "junit-params",
400 "mockftpserver",
401 "mockito-target",
402 "mockwebserver",
403 "nist-pkix-tests",
404 "slf4j-jdk14",
405 "sqlite-jdbc",
406 "tzdata-testing",
407 ],
408
409 errorprone: {
410 javacflags: [
411 "-Xep:TryFailThrowable:ERROR",
412 "-Xep:ComparisonOutOfRange:ERROR",
413 ],
414 },
Simran Basi3be01e02018-08-21 17:53:49 -0700415
416 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700417}
418
419// Make the core-ojtests library.
420java_test {
421 name: "core-ojtests",
422 defaults: ["libcore_java_defaults"],
423 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100424 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700425
426 srcs: [
427 "ojluni/src/test/java/**/*.java",
428 ],
429 java_resource_dirs: [
430 "ojluni/src/test/java",
431 "ojluni/src/test/resources",
432 ],
433 libs: [
434 "okhttp",
435 "bouncycastle",
436 ],
437 static_libs: ["testng"],
438
439 // ojluni/src/test/java/util/stream/{bootlib,boottest}
440 // contains tests that are in packages from java.base;
441 // By default, OpenJDK 9's javac will only compile such
442 // code if it's declared to also be in java.base at
443 // compile time.
444 //
445 // For now, we use --patch-module to put all sources
446 // and dependencies from this make target into java.base;
447 // other source directories in this make target are in
448 // packages not from java.base; if this becomes a problem
449 // in future, this could be addressed eg. by splitting
450 // boot{lib,test} out into a separate make target,
451 // deleting those tests or moving them to a different
452 // package.
453 patch_module: "java.base",
454}
455
456// Make the core-ojtests-public library. Excludes any private API tests.
457java_test {
458 name: "core-ojtests-public",
459 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100460 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700461 srcs: [
462 "ojluni/src/test/java/**/*.java",
463 ],
464 // Filter out the following:
465 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
466 // and won't actually run, and
467 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
468 // excluding them means we don't need patch_module: "java.base"
469 exclude_srcs: [
470 "**/DeserializeMethodTest.java",
471 "**/SerializedLambdaTest.java",
472 "ojluni/src/test/java/util/stream/boot*/**/*",
473 ],
474 java_resource_dirs: [
475 "ojluni/src/test/java",
476 "ojluni/src/test/resources",
477 // Include source code as part of JAR
478 "ojluni/src/test/dist",
479 ],
480 libs: [
481 "bouncycastle",
482 "okhttp",
483 "testng",
484 ],
485}
486
Pete Gillin7db7faa2018-07-31 13:29:35 +0100487// Make the annotated stubs in ojluni/annotations available to metalava:
488droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100489 name: "ojluni-annotated-sdk-stubs",
490 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100491}
492
Neil Fuller6f16b462018-09-04 15:40:39 +0100493// A file containing the list of tags that are "known" to us from the OpenJdk
494// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800495filegroup {
496 name: "known-oj-tags",
497 srcs: [
498 "known_oj_tags.txt",
499 ],
500}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700501
Neil Fullera6ba3592018-09-21 13:19:37 +0100502// Stubs for the parts of the public SDK API provided by the core libraries.
Nan Zhangf0207602018-09-10 18:57:38 -0700503droidstubs {
504 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100505 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700506 installable: false,
507 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000508 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700509}
510
Neil Fullera6ba3592018-09-21 13:19:37 +0100511// A library containing the parts of the public SDK API provided by the core libraries.
512// Don't use this directly, use "sdk_version: core_current".
513java_library {
Nan Zhang602fc0e2018-03-22 16:14:22 -0700514 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700515 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700516 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}