blob: efbef4d9338a85e0bf1a7fde56f65758db1d3b6b [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
48java_defaults {
49 name: "libcore_java_defaults",
50 javacflags: [
51 //"-Xlint:all",
52 //"-Xlint:-serial,-deprecation,-unchecked",
53 ],
54 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -080055 errorprone: {
56 javacflags: [
57 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -070058 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -080059 ],
60 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070061}
62
63//
64// Build for the target (device).
65//
66
67java_library {
68 name: "core-all",
69 defaults: ["libcore_java_defaults"],
70
71 srcs: [
72 ":openjdk_java_files",
73 ":non_openjdk_java_files",
74 ":android_icu4j_src_files",
Neil Fullercf756882018-08-28 18:42:22 +010075 ":core_simple_mmodule_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -070076 ":openjdk_lambda_stub_files",
77 ],
Colin Crossec80f4f2018-08-15 21:17:11 -070078
79 no_standard_libs: true,
80 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -070081 openjdk9: {
82 srcs: ["luni/src/module/java/module-info.java"],
83 javacflags: ["--patch-module=java.base=."],
84 },
Colin Crossec80f4f2018-08-15 21:17:11 -070085
Colin Crossaf0b54c2017-09-27 17:22:32 -070086 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -070087 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -070088
89 required: [
90 "tzdata",
91 "tzlookup.xml",
92 ],
93
94 installable: false,
95}
96
Colin Crossa4d9fc42017-09-29 18:04:37 -070097java_system_modules {
98 name: "core-all-system-modules",
99 libs: ["core-all"],
100}
101
Colin Crossaf0b54c2017-09-27 17:22:32 -0700102java_library {
103 name: "core-oj",
104 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700105 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700106 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700107
108 srcs: [":openjdk_java_files"],
109 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700110
111 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700112 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700113 system_modules: "core-all-system-modules",
114 openjdk9: {
115 javacflags: ["--patch-module=java.base=."],
116 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700117
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000118 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000119 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000120 "java.lang.Class",
121 "java.lang.Long",
122 "java.lang.Number",
123 "java.lang.Object",
124 "java.lang.String",
125 "java.lang.invoke.MethodHandle",
126 "java.lang.ref.Reference",
127 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000128 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000129 "java.util.HashMap",
130 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000131 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000132 ],
133 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700134
135 notice: "ojluni/NOTICE",
136
137 required: [
138 "tzdata",
139 "tzlookup.xml",
140 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700141
Colin Crossaf0b54c2017-09-27 17:22:32 -0700142}
143
144// Definitions to make the core library.
145java_library {
146 name: "core-libart",
147 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700148 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700149 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700150
151 srcs: [
152 ":non_openjdk_java_files",
153 ":android_icu4j_src_files",
154 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700155 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700156
Colin Crossec80f4f2018-08-15 21:17:11 -0700157 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700158 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700159 system_modules: "core-all-system-modules",
160 openjdk9: {
161 javacflags: ["--patch-module=java.base=."],
162 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700163
Pete Gillin80ebe872018-02-13 15:21:20 +0000164 jacoco: {
165 exclude_filter: [
166 "java.lang.DexCache",
167 "dalvik.system.ClassExt",
168 ],
169 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700170
171 required: [
172 "tzdata",
173 "tzlookup.xml",
174 ],
175}
176
Colin Cross3c6c2e22017-10-18 13:24:52 -0700177// A guaranteed unstripped version of core-oj and core-libart.
178// The build system may or may not strip the core-oj and core-libart jars,
179// but these will not be stripped. See b/24535627.
180java_library {
181 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700182 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700183 static_libs: ["core-oj"],
184 no_standard_libs: true,
185 libs: ["core-all"],
186 system_modules: "core-all-system-modules",
187 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800188 dex_preopt: {
189 enabled: false,
190 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700191 notice: "ojluni/NOTICE",
192 required: [
193 "tzdata",
194 "tzlookup.xml",
195 ],
196}
197
198java_library {
199 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700200 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700201 static_libs: ["core-libart"],
202 no_standard_libs: true,
203 libs: ["core-all"],
204 system_modules: "core-all-system-modules",
205 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800206 dex_preopt: {
207 enabled: false,
208 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700209 notice: "ojluni/NOTICE",
210 required: [
211 "tzdata",
212 "tzlookup.xml",
213 ],
214}
215
Colin Crossaf0b54c2017-09-27 17:22:32 -0700216// A library that exists to satisfy javac when
217// compiling source code that contains lambdas.
218java_library {
219 name: "core-lambda-stubs",
220 defaults: ["libcore_java_defaults"],
221
222 srcs: [
223 ":openjdk_lambda_stub_files",
224 ":openjdk_lambda_duplicate_stub_files",
225 ],
226
Colin Crossec80f4f2018-08-15 21:17:11 -0700227 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700228 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700229 system_modules: "core-all-system-modules",
230 openjdk9: {
231 javacflags: ["--patch-module=java.base=."],
232 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700233
234 notice: "ojluni/NOTICE",
235
236 installable: false,
237 include_srcs: true,
238}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700239
240java_system_modules {
241 name: "core-system-modules",
242 libs: [
243 "core-oj",
244 "core-libart",
245 "core-lambda-stubs",
246 ],
247}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700248
249// Build libcore test rules
250java_library_static {
251 name: "core-test-rules",
252 hostdex: true,
253 no_framework_libs: true,
254 srcs: [
255 "dalvik/test-rules/src/main/**/*.java",
256 "test-rules/src/main/**/*.java",
257 ],
258 static_libs: ["junit"],
259}
260
261// Make the core-tests-support library.
262java_library_static {
263 name: "core-tests-support",
264 hostdex: true,
265 no_framework_libs: true,
266 srcs: ["support/src/test/java/**/*.java"],
267 libs: [
268 "junit",
269 "bouncycastle",
270 ],
271 static_libs: [
272 "bouncycastle-bcpkix",
273 "bouncycastle-ocsp",
274 ],
275}
276
277// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700278java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700279 name: "jsr166-tests",
280 srcs: ["jsr166-tests/src/test/java/**/*.java"],
281 no_framework_libs: true,
282 libs: [
283 "junit",
284 ],
285}
Nan Zhang65f27a32018-01-05 10:41:46 -0800286
Colin Crossec80f4f2018-08-15 21:17:11 -0700287// Build a library just containing files from luni/src/test/filesystems for use in tests.
288java_library {
289 name: "filesystemstest",
290 compile_dex: true,
291 srcs: ["luni/src/test/filesystems/src/**/*.java"],
292 java_resource_dirs: ["luni/src/test/filesystems/resources"],
293 no_framework_libs: true,
294 errorprone: {
295 javacflags: ["-Xep:MissingOverride:OFF"],
296 },
297}
298
299// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
300java_library {
301 name: "parameter-metadata-test",
302 compile_dex: true,
303 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
304 no_framework_libs: true,
305 javacflags: ["-parameters"],
306 errorprone: {
307 javacflags: ["-Xep:MissingOverride:OFF"],
308 },
309}
310
311// Make the core-tests library.
312java_test {
313 name: "core-tests",
314 defaults: ["libcore_java_defaults"],
315 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100316 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700317 srcs: [
318 "dalvik/src/test/java/**/*.java",
319 "dalvik/test-rules/src/test/java/**/*.java",
320 "dom/src/test/java/**/*.java",
321 "harmony-tests/src/test/java/**/*.java",
322 "json/src/test/java/**/*.java",
323 "luni/src/test/java/**/*.java",
324 "xml/src/test/java/**/*.java",
325 ],
326 exclude_srcs: [
327 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
328 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
329 ],
330
331 java_resource_dirs: [
332 "*/src/test/java",
333 "*/src/test/resources",
334 ],
335 exclude_java_resource_dirs: [
336 "ojluni/src/test/java",
337 "ojluni/src/test/resources",
338 ],
339
340 java_resources: [
341 ":filesystemstest",
342 ":parameter-metadata-test",
343 ],
344
345 libs: [
346 "okhttp",
347 "bouncycastle",
348 ],
349 static_libs: [
350 "archive-patcher",
351 "core-test-rules",
352 "core-tests-support",
353 "junit-params",
354 "mockftpserver",
355 "mockito-target",
356 "mockwebserver",
357 "nist-pkix-tests",
358 "slf4j-jdk14",
359 "sqlite-jdbc",
360 "tzdata-testing",
361 ],
362
363 errorprone: {
364 javacflags: [
365 "-Xep:TryFailThrowable:ERROR",
366 "-Xep:ComparisonOutOfRange:ERROR",
367 ],
368 },
369}
370
371// Make the core-ojtests library.
372java_test {
373 name: "core-ojtests",
374 defaults: ["libcore_java_defaults"],
375 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100376 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700377
378 srcs: [
379 "ojluni/src/test/java/**/*.java",
380 ],
381 java_resource_dirs: [
382 "ojluni/src/test/java",
383 "ojluni/src/test/resources",
384 ],
385 libs: [
386 "okhttp",
387 "bouncycastle",
388 ],
389 static_libs: ["testng"],
390
391 // ojluni/src/test/java/util/stream/{bootlib,boottest}
392 // contains tests that are in packages from java.base;
393 // By default, OpenJDK 9's javac will only compile such
394 // code if it's declared to also be in java.base at
395 // compile time.
396 //
397 // For now, we use --patch-module to put all sources
398 // and dependencies from this make target into java.base;
399 // other source directories in this make target are in
400 // packages not from java.base; if this becomes a problem
401 // in future, this could be addressed eg. by splitting
402 // boot{lib,test} out into a separate make target,
403 // deleting those tests or moving them to a different
404 // package.
405 patch_module: "java.base",
406}
407
408// Make the core-ojtests-public library. Excludes any private API tests.
409java_test {
410 name: "core-ojtests-public",
411 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100412 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700413 srcs: [
414 "ojluni/src/test/java/**/*.java",
415 ],
416 // Filter out the following:
417 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
418 // and won't actually run, and
419 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
420 // excluding them means we don't need patch_module: "java.base"
421 exclude_srcs: [
422 "**/DeserializeMethodTest.java",
423 "**/SerializedLambdaTest.java",
424 "ojluni/src/test/java/util/stream/boot*/**/*",
425 ],
426 java_resource_dirs: [
427 "ojluni/src/test/java",
428 "ojluni/src/test/resources",
429 // Include source code as part of JAR
430 "ojluni/src/test/dist",
431 ],
432 libs: [
433 "bouncycastle",
434 "okhttp",
435 "testng",
436 ],
437}
438
Pete Gillin7db7faa2018-07-31 13:29:35 +0100439// Make the annotated stubs in ojluni/annotations available to metalava:
440droiddoc_exported_dir {
441 name: "ojluni-annotated-stubs",
442 path: "ojluni/annotations",
443}
444
Neil Fuller6f16b462018-09-04 15:40:39 +0100445// A file containing the list of tags that are "known" to us from the OpenJdk
446// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800447filegroup {
448 name: "known-oj-tags",
449 srcs: [
450 "known_oj_tags.txt",
451 ],
452}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700453
454droiddoc {
455 name: "core-current-stubs-gen-docs",
456 srcs: [
457 ":openjdk_javadoc_files",
458 ":non_openjdk_javadoc_files",
459 ":android_icu4j_src_files_for_docs",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700460 ],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700461 installable: false,
462 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000463 metalava_enabled: true,
464 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700465}
466
467java_library_static {
468 name: "core.current.stubs",
469 srcs: [
470 ":core-current-stubs-gen-docs",
471 ],
472 errorprone: {
473 javacflags: [
474 "-Xep:MissingOverride:OFF",
475 ],
476 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100477 openjdk9: {
478 javacflags: ["--patch-module=java.base=."],
479 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700480 no_standard_libs: true,
481 system_modules: "none",
482}
Neil Fullercf756882018-08-28 18:42:22 +0100483
484//
485// Targets related to core mmodule APIs / dependencies.
486//
487
488// Generates stub source files for the {public SDK API + intra-core mmodule API}
489// of core-all.
490droiddoc {
491 name: "core-all-mmodule-stubs-docs",
492 srcs: [
493 ":openjdk_javadoc_files",
494 ":non_openjdk_javadoc_files",
495 ":android_icu4j_src_files_for_docs",
496 ":core_simple_mmodule_java_files",
497 ],
498
499 installable: false,
500 no_framework_libs: true,
501 metalava_enabled: true,
502 args: "-nodocs -stubsourceonly -showAnnotation libcore.mmodule.IntraCoreMModuleApi",
503}
504
505// A library containing the {public SDK API + intra-core mmodule API} stubs for
506// core-all.
507java_library {
508 name: "core-all.mmodule.stubs",
509 srcs: [
510 ":core-all-mmodule-stubs-docs",
511 ],
512 no_framework_libs: true,
513
514 no_standard_libs: true,
515 libs: ["core-all"],
516 system_modules: "core-all-system-modules",
517 openjdk9: {
518 javacflags: ["--patch-module=java.base=."],
519 },
520}