blob: 72d9d756d0175adffc7cba3cd274ced12a2c4a92 [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
Victor Chang7fef4052018-09-25 14:12:03 +0100113// Rule generating resource lib for android_icu4j.
114// In the downstream branch master-icu-dev, the resource files are generated.
115// This rule can't be moved external/icu because soong enforces that no_standard_libs:true can only
116// be used in libcore/ or development/
117java_library {
118 name: "android_icu4j_resources_lib",
119 java_resources: [":android_icu4j_resources"],
120 no_standard_libs: true,
121 system_modules: "none",
122}
123
Colin Crossaf0b54c2017-09-27 17:22:32 -0700124java_library {
125 name: "core-all",
126 defaults: ["libcore_java_defaults"],
127
128 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100129 ":core_oj_java_files",
130 ":core_libart_java_files",
131 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700132 ":openjdk_lambda_stub_files",
133 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700134
135 no_standard_libs: true,
136 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700137 openjdk9: {
138 srcs: ["luni/src/module/java/module-info.java"],
139 javacflags: ["--patch-module=java.base=."],
140 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700141
Colin Crossaf0b54c2017-09-27 17:22:32 -0700142 java_resource_dirs: core_resource_dirs,
Victor Chang7fef4052018-09-25 14:12:03 +0100143 static_libs: ["android_icu4j_resources_lib"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700144
145 required: [
146 "tzdata",
147 "tzlookup.xml",
148 ],
149
150 installable: false,
151}
152
Colin Crossa4d9fc42017-09-29 18:04:37 -0700153java_system_modules {
154 name: "core-all-system-modules",
155 libs: ["core-all"],
156}
157
Colin Crossaf0b54c2017-09-27 17:22:32 -0700158java_library {
159 name: "core-oj",
160 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700161 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700162 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700163
Neil Fuller866ed4a2018-09-06 12:05:46 +0100164 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700165 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700166
167 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700168 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700169 system_modules: "core-all-system-modules",
170 openjdk9: {
171 javacflags: ["--patch-module=java.base=."],
172 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700173
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000174 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000175 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000176 "java.lang.Class",
177 "java.lang.Long",
178 "java.lang.Number",
179 "java.lang.Object",
180 "java.lang.String",
181 "java.lang.invoke.MethodHandle",
182 "java.lang.ref.Reference",
183 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000184 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000185 "java.util.HashMap",
186 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000187 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000188 ],
189 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700190
191 notice: "ojluni/NOTICE",
192
193 required: [
194 "tzdata",
195 "tzlookup.xml",
196 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700197
Colin Crossaf0b54c2017-09-27 17:22:32 -0700198}
199
200// Definitions to make the core library.
201java_library {
202 name: "core-libart",
203 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700204 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700205 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700206
Neil Fuller866ed4a2018-09-06 12:05:46 +0100207 srcs: [":core_libart_java_files"],
Victor Chang7fef4052018-09-25 14:12:03 +0100208 static_libs: ["android_icu4j_resources_lib"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700209
Colin Crossec80f4f2018-08-15 21:17:11 -0700210 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700211 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700212 system_modules: "core-all-system-modules",
213 openjdk9: {
214 javacflags: ["--patch-module=java.base=."],
215 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700216
Pete Gillin80ebe872018-02-13 15:21:20 +0000217 jacoco: {
218 exclude_filter: [
219 "java.lang.DexCache",
220 "dalvik.system.ClassExt",
221 ],
222 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700223
224 required: [
225 "tzdata",
226 "tzlookup.xml",
227 ],
228}
229
Colin Cross3c6c2e22017-10-18 13:24:52 -0700230// A guaranteed unstripped version of core-oj and core-libart.
231// The build system may or may not strip the core-oj and core-libart jars,
232// but these will not be stripped. See b/24535627.
233java_library {
234 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700235 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700236 static_libs: ["core-oj"],
237 no_standard_libs: true,
238 libs: ["core-all"],
239 system_modules: "core-all-system-modules",
240 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800241 dex_preopt: {
242 enabled: false,
243 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700244 notice: "ojluni/NOTICE",
245 required: [
246 "tzdata",
247 "tzlookup.xml",
248 ],
249}
250
251java_library {
252 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700253 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700254 static_libs: ["core-libart"],
255 no_standard_libs: true,
256 libs: ["core-all"],
257 system_modules: "core-all-system-modules",
258 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800259 dex_preopt: {
260 enabled: false,
261 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700262 notice: "ojluni/NOTICE",
263 required: [
264 "tzdata",
265 "tzlookup.xml",
266 ],
267}
268
Colin Crossaf0b54c2017-09-27 17:22:32 -0700269// A library that exists to satisfy javac when
270// compiling source code that contains lambdas.
271java_library {
272 name: "core-lambda-stubs",
273 defaults: ["libcore_java_defaults"],
274
275 srcs: [
276 ":openjdk_lambda_stub_files",
277 ":openjdk_lambda_duplicate_stub_files",
278 ],
279
Colin Crossec80f4f2018-08-15 21:17:11 -0700280 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700281 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700282 system_modules: "core-all-system-modules",
283 openjdk9: {
284 javacflags: ["--patch-module=java.base=."],
285 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700286
287 notice: "ojluni/NOTICE",
288
289 installable: false,
290 include_srcs: true,
291}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700292
Neil Fuller866ed4a2018-09-06 12:05:46 +0100293// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700294java_system_modules {
295 name: "core-system-modules",
296 libs: [
297 "core-oj",
298 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100299 "core-simple",
300 // This one is not on device but it's needed when javac compiles code
301 // containing lambdas.
302 "core-lambda-stubs"
Colin Crossa4d9fc42017-09-29 18:04:37 -0700303 ],
304}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700305
306// Build libcore test rules
307java_library_static {
308 name: "core-test-rules",
309 hostdex: true,
310 no_framework_libs: true,
311 srcs: [
312 "dalvik/test-rules/src/main/**/*.java",
313 "test-rules/src/main/**/*.java",
314 ],
315 static_libs: ["junit"],
316}
317
318// Make the core-tests-support library.
319java_library_static {
320 name: "core-tests-support",
321 hostdex: true,
322 no_framework_libs: true,
323 srcs: ["support/src/test/java/**/*.java"],
324 libs: [
325 "junit",
326 "bouncycastle",
327 ],
328 static_libs: [
329 "bouncycastle-bcpkix",
330 "bouncycastle-ocsp",
331 ],
332}
333
334// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700335java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700336 name: "jsr166-tests",
337 srcs: ["jsr166-tests/src/test/java/**/*.java"],
338 no_framework_libs: true,
339 libs: [
340 "junit",
341 ],
342}
Nan Zhang65f27a32018-01-05 10:41:46 -0800343
Colin Crossec80f4f2018-08-15 21:17:11 -0700344// Build a library just containing files from luni/src/test/filesystems for use in tests.
345java_library {
346 name: "filesystemstest",
347 compile_dex: true,
348 srcs: ["luni/src/test/filesystems/src/**/*.java"],
349 java_resource_dirs: ["luni/src/test/filesystems/resources"],
350 no_framework_libs: true,
351 errorprone: {
352 javacflags: ["-Xep:MissingOverride:OFF"],
353 },
354}
355
356// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
357java_library {
358 name: "parameter-metadata-test",
359 compile_dex: true,
360 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
361 no_framework_libs: true,
362 javacflags: ["-parameters"],
363 errorprone: {
364 javacflags: ["-Xep:MissingOverride:OFF"],
365 },
366}
367
368// Make the core-tests library.
369java_test {
370 name: "core-tests",
371 defaults: ["libcore_java_defaults"],
372 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100373 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700374 srcs: [
375 "dalvik/src/test/java/**/*.java",
376 "dalvik/test-rules/src/test/java/**/*.java",
377 "dom/src/test/java/**/*.java",
378 "harmony-tests/src/test/java/**/*.java",
379 "json/src/test/java/**/*.java",
380 "luni/src/test/java/**/*.java",
381 "xml/src/test/java/**/*.java",
382 ],
383 exclude_srcs: [
384 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
385 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
386 ],
387
388 java_resource_dirs: [
389 "*/src/test/java",
390 "*/src/test/resources",
391 ],
392 exclude_java_resource_dirs: [
393 "ojluni/src/test/java",
394 "ojluni/src/test/resources",
395 ],
396
397 java_resources: [
398 ":filesystemstest",
399 ":parameter-metadata-test",
400 ],
401
402 libs: [
403 "okhttp",
404 "bouncycastle",
405 ],
406 static_libs: [
407 "archive-patcher",
408 "core-test-rules",
409 "core-tests-support",
410 "junit-params",
411 "mockftpserver",
412 "mockito-target",
413 "mockwebserver",
414 "nist-pkix-tests",
415 "slf4j-jdk14",
416 "sqlite-jdbc",
417 "tzdata-testing",
418 ],
419
420 errorprone: {
421 javacflags: [
422 "-Xep:TryFailThrowable:ERROR",
423 "-Xep:ComparisonOutOfRange:ERROR",
424 ],
425 },
Simran Basi3be01e02018-08-21 17:53:49 -0700426
427 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700428}
429
430// Make the core-ojtests library.
431java_test {
432 name: "core-ojtests",
433 defaults: ["libcore_java_defaults"],
434 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100435 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700436
437 srcs: [
438 "ojluni/src/test/java/**/*.java",
439 ],
440 java_resource_dirs: [
441 "ojluni/src/test/java",
442 "ojluni/src/test/resources",
443 ],
444 libs: [
445 "okhttp",
446 "bouncycastle",
447 ],
448 static_libs: ["testng"],
449
450 // ojluni/src/test/java/util/stream/{bootlib,boottest}
451 // contains tests that are in packages from java.base;
452 // By default, OpenJDK 9's javac will only compile such
453 // code if it's declared to also be in java.base at
454 // compile time.
455 //
456 // For now, we use --patch-module to put all sources
457 // and dependencies from this make target into java.base;
458 // other source directories in this make target are in
459 // packages not from java.base; if this becomes a problem
460 // in future, this could be addressed eg. by splitting
461 // boot{lib,test} out into a separate make target,
462 // deleting those tests or moving them to a different
463 // package.
464 patch_module: "java.base",
465}
466
467// Make the core-ojtests-public library. Excludes any private API tests.
468java_test {
469 name: "core-ojtests-public",
470 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100471 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700472 srcs: [
473 "ojluni/src/test/java/**/*.java",
474 ],
475 // Filter out the following:
476 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
477 // and won't actually run, and
478 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
479 // excluding them means we don't need patch_module: "java.base"
480 exclude_srcs: [
481 "**/DeserializeMethodTest.java",
482 "**/SerializedLambdaTest.java",
483 "ojluni/src/test/java/util/stream/boot*/**/*",
484 ],
485 java_resource_dirs: [
486 "ojluni/src/test/java",
487 "ojluni/src/test/resources",
488 // Include source code as part of JAR
489 "ojluni/src/test/dist",
490 ],
491 libs: [
492 "bouncycastle",
493 "okhttp",
494 "testng",
495 ],
496}
497
Pete Gillin7db7faa2018-07-31 13:29:35 +0100498// Make the annotated stubs in ojluni/annotations available to metalava:
499droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100500 name: "ojluni-annotated-sdk-stubs",
501 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100502}
503
Neil Fuller6f16b462018-09-04 15:40:39 +0100504// A file containing the list of tags that are "known" to us from the OpenJdk
505// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800506filegroup {
507 name: "known-oj-tags",
508 srcs: [
509 "known_oj_tags.txt",
510 ],
511}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700512
Neil Fullera6ba3592018-09-21 13:19:37 +0100513// Stubs for the parts of the public SDK API provided by the core libraries.
Nan Zhangf0207602018-09-10 18:57:38 -0700514droidstubs {
515 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100516 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700517 installable: false,
518 no_framework_libs: true,
Nan Zhang68c55b42018-08-21 17:31:51 +0000519 args: " --exclude-annotations",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700520}
521
Neil Fullera6ba3592018-09-21 13:19:37 +0100522// A library containing the parts of the public SDK API provided by the core libraries.
523// Don't use this directly, use "sdk_version: core_current".
524java_library {
Nan Zhang602fc0e2018-03-22 16:14:22 -0700525 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700526 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700527 errorprone: {
528 javacflags: [
529 "-Xep:MissingOverride:OFF",
530 ],
531 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100532 openjdk9: {
533 javacflags: ["--patch-module=java.base=."],
534 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700535 no_standard_libs: true,
536 system_modules: "none",
537}