blob: 4f7a7a4270d4384cedd5a4919bae3bb50e675917 [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
Pete Gillinc9935b62018-09-25 14:42:40 +010081// annotations. Note that this includes the intra-core and core-platform APIs as
82// well as the public APIs. Some source files in :openjdk_mmodule_extra_files
83// are annotated by applying annotation to the .annotated.java stubs files in
84// ojluni/annotated/mmodules and rather than in the original source. See the
85// comments in openjdk_java_files.bp for more details.
Neil Fuller866ed4a2018-09-06 12:05:46 +010086filegroup {
87 name: "core_api_files",
88 srcs: [
Neil Fullerd129bc92018-09-26 11:12:58 +010089 ":apache-xml_api_files",
Neil Fullera77f7102018-09-21 19:04:41 +010090 ":bouncycastle_java_files",
Neil Fuller603e1a72018-09-25 11:55:41 +010091 ":conscrypt_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010092 ":core_oj_api_files",
93 ":core_libart_api_files",
94 ":core_simple_java_files",
Neil Fuller641d5f92018-09-24 15:40:39 +010095 ":okhttp_api_files",
Pete Gillinc9935b62018-09-25 14:42:40 +010096 ":openjdk_mmodule_extra_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +010097 ],
98}
99
Colin Crossaf0b54c2017-09-27 17:22:32 -0700100java_defaults {
101 name: "libcore_java_defaults",
102 javacflags: [
103 //"-Xlint:all",
104 //"-Xlint:-serial,-deprecation,-unchecked",
105 ],
106 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800107 errorprone: {
108 javacflags: [
109 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
Andreas Gampe24a20172018-06-13 11:28:45 -0700110 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800111 ],
112 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700113}
114
115//
116// Build for the target (device).
117//
118
Victor Chang7fef4052018-09-25 14:12:03 +0100119// Rule generating resource lib for android_icu4j.
120// In the downstream branch master-icu-dev, the resource files are generated.
121// This rule can't be moved external/icu because soong enforces that no_standard_libs:true can only
122// be used in libcore/ or development/
123java_library {
124 name: "android_icu4j_resources_lib",
125 java_resources: [":android_icu4j_resources"],
126 no_standard_libs: true,
127 system_modules: "none",
128}
129
Colin Crossaf0b54c2017-09-27 17:22:32 -0700130java_library {
131 name: "core-all",
132 defaults: ["libcore_java_defaults"],
133
134 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100135 ":core_oj_java_files",
136 ":core_libart_java_files",
137 ":core_simple_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700138 ":openjdk_lambda_stub_files",
139 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700140
141 no_standard_libs: true,
142 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700143 openjdk9: {
144 srcs: ["luni/src/module/java/module-info.java"],
145 javacflags: ["--patch-module=java.base=."],
146 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700147
Colin Crossaf0b54c2017-09-27 17:22:32 -0700148 java_resource_dirs: core_resource_dirs,
Victor Chang7fef4052018-09-25 14:12:03 +0100149 static_libs: ["android_icu4j_resources_lib"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700150
151 required: [
152 "tzdata",
153 "tzlookup.xml",
154 ],
155
156 installable: false,
157}
158
Colin Crossa4d9fc42017-09-29 18:04:37 -0700159java_system_modules {
160 name: "core-all-system-modules",
161 libs: ["core-all"],
162}
163
Colin Crossaf0b54c2017-09-27 17:22:32 -0700164java_library {
165 name: "core-oj",
166 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700167 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700168 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700169
Neil Fuller866ed4a2018-09-06 12:05:46 +0100170 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700171 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700172
173 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700174 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700175 system_modules: "core-all-system-modules",
176 openjdk9: {
177 javacflags: ["--patch-module=java.base=."],
178 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700179
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000180 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000181 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000182 "java.lang.Class",
183 "java.lang.Long",
184 "java.lang.Number",
185 "java.lang.Object",
186 "java.lang.String",
187 "java.lang.invoke.MethodHandle",
188 "java.lang.ref.Reference",
189 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000190 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000191 "java.util.HashMap",
192 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000193 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000194 ],
195 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700196
197 notice: "ojluni/NOTICE",
198
199 required: [
200 "tzdata",
201 "tzlookup.xml",
202 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700203
Colin Crossaf0b54c2017-09-27 17:22:32 -0700204}
205
206// Definitions to make the core library.
207java_library {
208 name: "core-libart",
209 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700210 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700211 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700212
Neil Fuller866ed4a2018-09-06 12:05:46 +0100213 srcs: [":core_libart_java_files"],
Victor Chang7fef4052018-09-25 14:12:03 +0100214 static_libs: ["android_icu4j_resources_lib"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700215
Colin Crossec80f4f2018-08-15 21:17:11 -0700216 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700217 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700218 system_modules: "core-all-system-modules",
219 openjdk9: {
220 javacflags: ["--patch-module=java.base=."],
221 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700222
Pete Gillin80ebe872018-02-13 15:21:20 +0000223 jacoco: {
224 exclude_filter: [
225 "java.lang.DexCache",
226 "dalvik.system.ClassExt",
227 ],
228 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700229
230 required: [
231 "tzdata",
232 "tzlookup.xml",
233 ],
234}
235
Colin Cross3c6c2e22017-10-18 13:24:52 -0700236// A guaranteed unstripped version of core-oj and core-libart.
237// The build system may or may not strip the core-oj and core-libart jars,
238// but these will not be stripped. See b/24535627.
239java_library {
240 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700241 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700242 static_libs: ["core-oj"],
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
257java_library {
258 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700259 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700260 static_libs: ["core-libart"],
261 no_standard_libs: true,
262 libs: ["core-all"],
263 system_modules: "core-all-system-modules",
264 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800265 dex_preopt: {
266 enabled: false,
267 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700268 notice: "ojluni/NOTICE",
269 required: [
270 "tzdata",
271 "tzlookup.xml",
272 ],
273}
274
Colin Crossaf0b54c2017-09-27 17:22:32 -0700275// A library that exists to satisfy javac when
276// compiling source code that contains lambdas.
277java_library {
278 name: "core-lambda-stubs",
279 defaults: ["libcore_java_defaults"],
280
281 srcs: [
282 ":openjdk_lambda_stub_files",
283 ":openjdk_lambda_duplicate_stub_files",
284 ],
285
Colin Crossec80f4f2018-08-15 21:17:11 -0700286 no_standard_libs: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700287 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700288 system_modules: "core-all-system-modules",
289 openjdk9: {
290 javacflags: ["--patch-module=java.base=."],
291 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700292
293 notice: "ojluni/NOTICE",
294
295 installable: false,
296 include_srcs: true,
297}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700298
Neil Fuller866ed4a2018-09-06 12:05:46 +0100299// The libraries that make up core.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700300java_system_modules {
301 name: "core-system-modules",
302 libs: [
303 "core-oj",
304 "core-libart",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100305 "core-simple",
306 // This one is not on device but it's needed when javac compiles code
307 // containing lambdas.
Neil Fullerb669ccb2018-10-04 23:10:27 +0100308 "core-lambda-stubs",
309 "bouncycastle",
310 "conscrypt",
311 "okhttp",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700312 ],
313}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700314
315// Build libcore test rules
316java_library_static {
317 name: "core-test-rules",
318 hostdex: true,
319 no_framework_libs: true,
320 srcs: [
321 "dalvik/test-rules/src/main/**/*.java",
322 "test-rules/src/main/**/*.java",
323 ],
324 static_libs: ["junit"],
325}
326
327// Make the core-tests-support library.
328java_library_static {
329 name: "core-tests-support",
330 hostdex: true,
331 no_framework_libs: true,
332 srcs: ["support/src/test/java/**/*.java"],
333 libs: [
334 "junit",
335 "bouncycastle",
336 ],
337 static_libs: [
338 "bouncycastle-bcpkix",
339 "bouncycastle-ocsp",
340 ],
341}
342
343// Make the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700344java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700345 name: "jsr166-tests",
346 srcs: ["jsr166-tests/src/test/java/**/*.java"],
347 no_framework_libs: true,
348 libs: [
349 "junit",
350 ],
351}
Nan Zhang65f27a32018-01-05 10:41:46 -0800352
Colin Crossec80f4f2018-08-15 21:17:11 -0700353// Build a library just containing files from luni/src/test/filesystems for use in tests.
354java_library {
355 name: "filesystemstest",
356 compile_dex: true,
357 srcs: ["luni/src/test/filesystems/src/**/*.java"],
358 java_resource_dirs: ["luni/src/test/filesystems/resources"],
359 no_framework_libs: true,
360 errorprone: {
361 javacflags: ["-Xep:MissingOverride:OFF"],
362 },
363}
364
365// Build a library just containing files from luni/src/test/parameter_metadata for use in tests.
366java_library {
367 name: "parameter-metadata-test",
368 compile_dex: true,
369 srcs: ["luni/src/test/parameter_metadata/src/**/*.java"],
370 no_framework_libs: true,
371 javacflags: ["-parameters"],
372 errorprone: {
373 javacflags: ["-Xep:MissingOverride:OFF"],
374 },
375}
376
377// Make the core-tests library.
378java_test {
379 name: "core-tests",
380 defaults: ["libcore_java_defaults"],
381 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100382 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700383 srcs: [
384 "dalvik/src/test/java/**/*.java",
385 "dalvik/test-rules/src/test/java/**/*.java",
386 "dom/src/test/java/**/*.java",
387 "harmony-tests/src/test/java/**/*.java",
388 "json/src/test/java/**/*.java",
389 "luni/src/test/java/**/*.java",
390 "xml/src/test/java/**/*.java",
391 ],
392 exclude_srcs: [
393 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
394 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
395 ],
396
397 java_resource_dirs: [
398 "*/src/test/java",
399 "*/src/test/resources",
400 ],
401 exclude_java_resource_dirs: [
402 "ojluni/src/test/java",
403 "ojluni/src/test/resources",
404 ],
405
406 java_resources: [
407 ":filesystemstest",
408 ":parameter-metadata-test",
409 ],
410
Colin Crossec80f4f2018-08-15 21:17:11 -0700411 static_libs: [
412 "archive-patcher",
413 "core-test-rules",
414 "core-tests-support",
415 "junit-params",
416 "mockftpserver",
417 "mockito-target",
418 "mockwebserver",
419 "nist-pkix-tests",
420 "slf4j-jdk14",
421 "sqlite-jdbc",
422 "tzdata-testing",
423 ],
424
425 errorprone: {
426 javacflags: [
427 "-Xep:TryFailThrowable:ERROR",
428 "-Xep:ComparisonOutOfRange:ERROR",
429 ],
430 },
Simran Basi3be01e02018-08-21 17:53:49 -0700431
432 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700433}
434
435// Make the core-ojtests library.
436java_test {
437 name: "core-ojtests",
438 defaults: ["libcore_java_defaults"],
439 hostdex: true,
Roland Levillain5e028a22018-08-17 17:33:59 +0100440 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700441
442 srcs: [
443 "ojluni/src/test/java/**/*.java",
444 ],
445 java_resource_dirs: [
446 "ojluni/src/test/java",
447 "ojluni/src/test/resources",
448 ],
Neil Fullerb669ccb2018-10-04 23:10:27 +0100449
Colin Crossec80f4f2018-08-15 21:17:11 -0700450 static_libs: ["testng"],
451
452 // ojluni/src/test/java/util/stream/{bootlib,boottest}
453 // contains tests that are in packages from java.base;
454 // By default, OpenJDK 9's javac will only compile such
455 // code if it's declared to also be in java.base at
456 // compile time.
457 //
458 // For now, we use --patch-module to put all sources
459 // and dependencies from this make target into java.base;
460 // other source directories in this make target are in
461 // packages not from java.base; if this becomes a problem
462 // in future, this could be addressed eg. by splitting
463 // boot{lib,test} out into a separate make target,
464 // deleting those tests or moving them to a different
465 // package.
466 patch_module: "java.base",
467}
468
469// Make the core-ojtests-public library. Excludes any private API tests.
470java_test {
471 name: "core-ojtests-public",
472 defaults: ["libcore_java_defaults"],
Roland Levillain5e028a22018-08-17 17:33:59 +0100473 no_framework_libs: true,
Colin Crossec80f4f2018-08-15 21:17:11 -0700474 srcs: [
475 "ojluni/src/test/java/**/*.java",
476 ],
477 // Filter out the following:
478 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
479 // and won't actually run, and
480 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
481 // excluding them means we don't need patch_module: "java.base"
482 exclude_srcs: [
483 "**/DeserializeMethodTest.java",
484 "**/SerializedLambdaTest.java",
485 "ojluni/src/test/java/util/stream/boot*/**/*",
486 ],
487 java_resource_dirs: [
488 "ojluni/src/test/java",
489 "ojluni/src/test/resources",
490 // Include source code as part of JAR
491 "ojluni/src/test/dist",
492 ],
Neil Fullerb669ccb2018-10-04 23:10:27 +0100493 libs: ["testng"],
Colin Crossec80f4f2018-08-15 21:17:11 -0700494}
495
Pete Gillin7db7faa2018-07-31 13:29:35 +0100496// Make the annotated stubs in ojluni/annotations available to metalava:
497droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100498 name: "ojluni-annotated-sdk-stubs",
499 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100500}
Pete Gillinc9935b62018-09-25 14:42:40 +0100501droiddoc_exported_dir {
502 name: "ojluni-annotated-mmodule-stubs",
503 path: "ojluni/annotations/mmodule",
504}
Pete Gillin7db7faa2018-07-31 13:29:35 +0100505
Neil Fuller6f16b462018-09-04 15:40:39 +0100506// A file containing the list of tags that are "known" to us from the OpenJdk
507// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800508filegroup {
509 name: "known-oj-tags",
510 srcs: [
511 "known_oj_tags.txt",
512 ],
513}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700514
Neil Fullera6ba3592018-09-21 13:19:37 +0100515// Stubs for the parts of the public SDK API provided by the core libraries.
Nan Zhangf0207602018-09-10 18:57:38 -0700516droidstubs {
517 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100518 srcs: [":core_api_files"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700519 installable: false,
520 no_framework_libs: true,
Neil Fullerbe9258e2018-09-24 17:11:27 +0100521 args: " --exclude-annotations "
522 + "--hide-annotation libcore.api.Hide",
523 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700524}
525
Neil Fullera6ba3592018-09-21 13:19:37 +0100526// A library containing the parts of the public SDK API provided by the core libraries.
527// Don't use this directly, use "sdk_version: core_current".
528java_library {
Nan Zhang602fc0e2018-03-22 16:14:22 -0700529 name: "core.current.stubs",
Nan Zhangf0207602018-09-10 18:57:38 -0700530 srcs: [":core-current-stubs-gen"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700531 errorprone: {
532 javacflags: [
533 "-Xep:MissingOverride:OFF",
534 ],
535 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100536 openjdk9: {
537 javacflags: ["--patch-module=java.base=."],
538 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700539 no_standard_libs: true,
540 system_modules: "none",
541}