blob: 21645d36bec56a50ab5c13fca72dfb75096ca780 [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"],
Tobias Thierer8e1ef512018-03-07 15:10:46 +0000130 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700131
132 required: [
133 "tzdata",
134 "tzlookup.xml",
135 ],
136
137 installable: false,
138}
139
Colin Crossa4d9fc42017-09-29 18:04:37 -0700140java_system_modules {
141 name: "core-all-system-modules",
142 libs: ["core-all"],
143}
144
Colin Crossaf0b54c2017-09-27 17:22:32 -0700145java_library {
146 name: "core-oj",
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
Neil Fuller866ed4a2018-09-06 12:05:46 +0100151 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700152 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700153
154 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 Gillin7a7a6d22017-12-19 14:56:03 +0000161 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000162 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000163 "java.lang.Class",
164 "java.lang.Long",
165 "java.lang.Number",
166 "java.lang.Object",
167 "java.lang.String",
168 "java.lang.invoke.MethodHandle",
169 "java.lang.ref.Reference",
170 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000171 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000172 "java.util.HashMap",
173 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000174 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000175 ],
176 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700177
178 notice: "ojluni/NOTICE",
179
180 required: [
181 "tzdata",
182 "tzlookup.xml",
183 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700184
Colin Crossaf0b54c2017-09-27 17:22:32 -0700185}
186
187// Definitions to make the core library.
188java_library {
189 name: "core-libart",
190 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700191 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700192 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700193
Neil Fuller866ed4a2018-09-06 12:05:46 +0100194 srcs: [":core_libart_java_files"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700195 java_resources: [":android_icu4j_resources"],
Tobias Thierer8e1ef512018-03-07 15:10:46 +0000196 java_version: "1.9",
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 },
Tobias Thierer8e1ef512018-03-07 15:10:46 +0000250 java_version: "1.9",
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 },
415}
416
417// Make the core-ojtests library.
418java_test {
419 name: "core-ojtests",
420 defaults: ["libcore_java_defaults"],
421 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100422 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700423
424 srcs: [
425 "ojluni/src/test/java/**/*.java",
426 ],
427 java_resource_dirs: [
428 "ojluni/src/test/java",
429 "ojluni/src/test/resources",
430 ],
431 libs: [
432 "okhttp",
433 "bouncycastle",
434 ],
435 static_libs: ["testng"],
436
437 // ojluni/src/test/java/util/stream/{bootlib,boottest}
438 // contains tests that are in packages from java.base;
439 // By default, OpenJDK 9's javac will only compile such
440 // code if it's declared to also be in java.base at
441 // compile time.
442 //
443 // For now, we use --patch-module to put all sources
444 // and dependencies from this make target into java.base;
445 // other source directories in this make target are in
446 // packages not from java.base; if this becomes a problem
447 // in future, this could be addressed eg. by splitting
448 // boot{lib,test} out into a separate make target,
449 // deleting those tests or moving them to a different
450 // package.
451 patch_module: "java.base",
452}
453
454// Make the core-ojtests-public library. Excludes any private API tests.
455java_test {
456 name: "core-ojtests-public",
457 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100458 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700459 srcs: [
460 "ojluni/src/test/java/**/*.java",
461 ],
462 // Filter out the following:
463 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
464 // and won't actually run, and
465 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
466 // excluding them means we don't need patch_module: "java.base"
467 exclude_srcs: [
468 "**/DeserializeMethodTest.java",
469 "**/SerializedLambdaTest.java",
470 "ojluni/src/test/java/util/stream/boot*/**/*",
471 ],
472 java_resource_dirs: [
473 "ojluni/src/test/java",
474 "ojluni/src/test/resources",
475 // Include source code as part of JAR
476 "ojluni/src/test/dist",
477 ],
478 libs: [
479 "bouncycastle",
480 "okhttp",
481 "testng",
482 ],
483}
484
Pete Gillin7db7faa2018-07-31 13:29:35 +0100485// Make the annotated stubs in ojluni/annotations available to metalava:
486droiddoc_exported_dir {
487 name: "ojluni-annotated-stubs",
488 path: "ojluni/annotations",
489}
490
Neil Fuller6f16b462018-09-04 15:40:39 +0100491// A file containing the list of tags that are "known" to us from the OpenJdk
492// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800493filegroup {
494 name: "known-oj-tags",
495 srcs: [
496 "known_oj_tags.txt",
497 ],
498}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700499
Nan Zhangf0207602018-09-10 18:57:38 -0700500droidstubs {
501 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100502 srcs: [":core_api_files"],
Tobias Thierer8e1ef512018-03-07 15:10:46 +0000503 java_version: "1.9",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700504 installable: false,
505 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000506 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700507}
508
509java_library_static {
510 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700511 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700512 errorprone: {
513 javacflags: [
514 "-Xep:MissingOverride:OFF",
515 ],
516 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100517 openjdk9: {
518 javacflags: ["--patch-module=java.base=."],
519 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700520 no_standard_libs: true,
521 system_modules: "none",
522}
Neil Fullercf756882018-08-28 18:42:22 +0100523