1// 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 Android core library and associated tests. 17// 18 19// The Android core library provides low-level APIs for use by the rest of the 20// Android software stack. It is made up of various parts, some of which can be 21// found in libcore/ and other parts that can be found in various external/ 22// directories. 23// 24// libcore has some sub-directories that follow a common structure: 25// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni, 26// support, xml, xmlpull. 27// 28// The structure of these is generally: 29// 30// src/ 31// main/ # To be shipped on every device. 32// java/ # Java source for library code. 33// native/ # C/C++ source for library code. 34// resources/ # Support files. 35// test/ # Built only on demand, for testing. 36// java/ # Java source for tests. 37// native/ # C/C++ source for tests (rare). 38// resources/ # Support files. 39// 40// All subdirectories are optional. 41 42build = [ 43 "openjdk_java_files.bp", 44 "non_openjdk_java_files.bp", 45] 46 47// The Java files and their associated resources. 48filegroup { 49 name: "core-luni-resources", 50 visibility: [ 51 "//libcore:__subpackages__", 52 ], 53 path: "luni/src/main/java/", 54 srcs: [ 55 "luni/src/main/java/java/util/logging/logging.properties", 56 "luni/src/main/java/java/security/security.properties", 57 ], 58} 59 60filegroup { 61 name: "core-ojluni-resources", 62 visibility: [ 63 "//libcore:__subpackages__", 64 ], 65 path: "ojluni/src/main/resources/", 66 srcs: [ 67 "ojluni/src/main/resources/**/*", 68 ], 69} 70 71core_resources = [ 72 ":core-luni-resources", 73 ":core-ojluni-resources", 74] 75 76// The source files that go into core-oj. 77filegroup { 78 name: "core_oj_java_files", 79 visibility: [ 80 "//libcore:__subpackages__", 81 ], 82 srcs: [":openjdk_java_files"], 83} 84 85// http://b/129765390, http://b/188966706 86// Rewrite links to "platform" or "technotes" folders which are siblings 87// (and thus outside of) {@docRoot}. 88// 89// We have to escape \ as \\ and $ as $$ here because they get resolved by 90// different layers of the build tooling. The arguments are wrapped in '' so 91// that the shell doesn't add yet another level of escaping. 92rewrite_openjdk_doc_links = "sed -E 's" + 93 "!(\\{@docRoot\\}/\\.\\./|[./]+)((platform|technotes).+)\">" + 94 "!https://docs.oracle.com/javase/8/docs/\\2\">!' " + 95 "$(in) " + 96 "| sed -E 's" + // Android doesn't have java.base in the API docs 97 "!(\\{@docRoot\\}/)(java\\.base/)(.+)\">" + 98 "!\\1reference/\\3\">!' " + 99 "| sed -E 's" + 100 "!(\\{@docRoot\\}/\\.\\./)(specs/.+)\">" + 101 "!https://docs.oracle.com/en/java/javase/17/docs/\\2\">!' " + 102 " > $(out) " + 103 "&& ! grep '{@docRoot}/../' $(out)" // exit with 1 if "{@docRoot}/../" still exists. 104 105// OpenJDK source is not annotated with @hide so we need this separate 106// filegroup for just the parts that contribute to the API. 107gensrcs { 108 name: "core_oj_api_files", 109 cmd: rewrite_openjdk_doc_links, 110 srcs: [":openjdk_javadoc_files"], 111 output_extension: "java", 112} 113 114// The source files that go into core-libart.l 115filegroup { 116 name: "core_libart_java_files", 117 visibility: [ 118 "//libcore:__subpackages__", 119 ], 120 srcs: [ 121 ":non_openjdk_java_files", 122 ], 123} 124 125// Some parts of libart are not annotated with @hide so we need this separate 126// filegroup for just the parts that contribute to the API. 127filegroup { 128 name: "core_libart_api_files", 129 srcs: [ 130 ":non_openjdk_javadoc_files", 131 ], 132} 133 134// The set of files for the ART module that contribute to one or more API 135// surfaces. This includes files that are in the public API as well as those 136// that are not but which have been marked up with @hide plus one or more of 137// the API defining annotations. 138// 139// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are 140// annotated by applying annotations to the .annotated.java stubs files in 141// ojluni/annotated/mmodules and rather than in the original source. See the comments 142// in openjdk_java_files.bp for more details. 143filegroup { 144 name: "art_module_api_files", 145 visibility: [ 146 "//libcore:__subpackages__", 147 ], 148 srcs: [ 149 ":apache-xml_api_files", 150 ":bouncycastle_java_files", 151 ":core_oj_api_files", 152 ":core_libart_api_files", 153 ":okhttp_api_files", 154 ":openjdk_mmodule_extra_files", 155 ], 156} 157 158java_defaults { 159 name: "libcore_java_defaults", 160 visibility: [ 161 "//libcore:__subpackages__", 162 ], 163 javacflags: [ 164 //"-Xlint:all", 165 //"-Xlint:-serial,-deprecation,-unchecked", 166 ], 167 dxflags: [ 168 "--android-platform-build", 169 "--core-library", 170 ], 171 errorprone: { 172 javacflags: [ 173 "-Xep:MissingOverride:OFF", // Ignore missing @Override. 174 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom 175 "-Xep:UnicodeInCode:WARN", // XML parser uses line feeds in whitespace 176 "-Xep:ReturnValueIgnored:WARN", 177 "-Xep:HashtableContains:WARN", 178 "-Xep:ComparableType:WARN", 179 "-Xep:IdentityBinaryExpression:WARN", 180 "-Xep:BoxedPrimitiveEquality:WARN", 181 "-Xep:EmptyTopLevelDeclaration:WARN", 182 "-Xep:GetClassOnClass:WARN", 183 "-Xep:NullableOnContainingClass:WARN", 184 "-Xep:GetClassOnAnnotation:WARN", 185 ], 186 }, 187 lint: { 188 warning_checks: [ 189 "SuspiciousIndentation", 190 "NewApi", 191 ], 192 }, 193 min_sdk_version: "31", 194} 195 196// 197// Build for the target (device). 198// 199 200// A target used to bootstrap compilation for the core library. 201// 202// See core-all-system-modules for more details. 203java_library { 204 name: "core-all", 205 defaults: ["libcore_java_defaults"], 206 207 srcs: [ 208 // Use the source code for the I18N module intra core API as using the 209 // compiled version does not work due to limitations in either soong or the javac 210 // toolchain. See http://b/142056316 for more details. 211 ":i18n.module.intra.core.api{.public.stubs.source}", 212 ":core_oj_java_files", 213 ":core_libart_java_files", 214 // framework-api-annotations contain API annotations, e.g. @SystemApi. 215 ":framework-api-annotations", 216 ":openjdk_lambda_stub_files", 217 ":app-compat-annotations-source", 218 219 // Use the okhttp source too to allow libcore code to reference it 220 // directly. 221 ":okhttp_impl_files", 222 ], 223 224 sdk_version: "none", 225 system_modules: "none", 226 patch_module: "java.base", 227 openjdk9: { 228 srcs: ["luni/src/module/java/module-info.java"], 229 }, 230 231 java_resources: core_resources, 232 233 installable: false, 234 235 plugins: [ 236 "compat-changeid-annotation-processor", 237 "unsupportedappusage-annotation-processor", 238 ], 239 libs: [ 240 "conscrypt.module.intra.core.api", 241 ], 242} 243 244platform_compat_config { 245 name: "libcore-platform-compat-config", 246 src: ":core-all", 247 visibility: [ 248 "//art/build/apex", 249 "//art/build/sdk", 250 ], 251} 252 253// A system modules definition for use by core library targets only. It only 254// contains the core-all jar, which contains the classes that end up in core-oj, 255// core-libart as well as the lambda stubs needed to compile Java lambda code. 256// It does not contain other parts of core library like conscrypt, bouncycastle, 257// etc. This system_modules definition is used to bootstrap compilation for 258// other parts of the core library like core-oj, core-libart, conscrypt, 259// bouncycastle, etc. It is also used to compile Libcore tests, as well as ART 260// Java tests (run-tests). 261java_system_modules { 262 name: "core-all-system-modules", 263 264 // Visibility is deliberately restricted to a small set of build modules that 265 // the core library team control. 266 visibility: [ 267 "//art/test:__subpackages__", 268 "//build/make/tools/aconfig/fake_device_config", 269 "//external/apache-harmony:__subpackages__", 270 "//external/apache-xml", 271 "//external/icu", 272 "//external/okhttp", 273 "//frameworks/libs/modules-utils/java", 274 "//libcore:__subpackages__", 275 "//tools/platform-compat/java/android/compat/annotation", 276 ], 277 278 libs: ["core-all"], 279} 280 281// Contains the parts of core library associated with OpenJDK. 282java_library { 283 name: "core-oj", 284 visibility: [ 285 "//art/build/apex", 286 "//art/build/sdk", 287 "//external/wycheproof", 288 "//libcore/benchmarks", 289 "//packages/modules/ArtPrebuilt", 290 ], 291 apex_available: [ 292 "com.android.art", 293 "com.android.art.debug", 294 ], 295 defaults: ["libcore_java_defaults"], 296 installable: true, 297 hostdex: true, 298 299 srcs: [":core_oj_java_files"], 300 java_resources: core_resources, 301 302 sdk_version: "none", 303 system_modules: "core-all-system-modules", 304 patch_module: "java.base", 305 306 jacoco: { 307 exclude_filter: [ 308 "java.lang.Class", 309 "java.lang.Long", 310 "java.lang.Number", 311 "java.lang.Object", 312 "java.lang.String", 313 "java.lang.invoke.MethodHandle", 314 "java.lang.invoke.VarHandle", 315 "java.lang.ref.Reference", 316 "java.lang.reflect.Proxy", 317 "java.util.AbstractMap", 318 "java.util.HashMap", 319 "java.util.HashMap$Node", 320 "java.util.Map", 321 ], 322 }, 323 324 hiddenapi_additional_annotations: [ 325 "core-oj-hiddenapi-annotations", 326 ], 327 328 errorprone: { 329 javacflags: [ 330 "-Xep:ReturnValueIgnored:WARN", 331 "-Xep:HashtableContains:WARN", 332 "-Xep:ComparableType:WARN", 333 "-Xep:IdentityBinaryExpression:WARN", 334 "-Xep:BoxedPrimitiveEquality:WARN", 335 "-Xep:EmptyTopLevelDeclaration:WARN", 336 "-Xep:GetClassOnClass:WARN", 337 ], 338 }, 339} 340 341// Contains parts of core library not associated with OpenJDK. Contains not 342// just java.*, javax.* code but also android.system.* and various internal 343// libcore.* packages. 344java_library { 345 name: "core-libart", 346 visibility: [ 347 "//art/build/apex", 348 "//art/build/sdk", 349 "//external/wycheproof", 350 "//libcore/benchmarks", 351 "//packages/modules/ArtPrebuilt", 352 ], 353 apex_available: [ 354 "com.android.art", 355 "com.android.art.debug", 356 ], 357 defaults: ["libcore_java_defaults"], 358 installable: true, 359 hostdex: true, 360 361 srcs: [":core_libart_java_files"], 362 363 sdk_version: "none", 364 system_modules: "core-all-system-modules", 365 patch_module: "java.base", 366 367 jacoco: { 368 exclude_filter: [ 369 "java.lang.DexCache", 370 "dalvik.system.ClassExt", 371 ], 372 }, 373 374 target: { 375 hostdex: { 376 required: [ 377 // Files used to simulate the /system, runtime APEX and tzdata 378 // APEX dir structure on host. 379 "icu_tzdata.dat_host_tzdata_apex", 380 "tzdata_host", 381 "tzdata_host_tzdata_apex", 382 "tzlookup.xml_host_tzdata_apex", 383 "tz_version_host", 384 "tz_version_host_tzdata_apex", 385 ], 386 }, 387 darwin: { 388 enabled: false, 389 }, 390 }, 391 392 errorprone: { 393 javacflags: [ 394 "-Xep:EmptyTopLevelDeclaration:WARN", 395 "-Xep:GetClassOnAnnotation:WARN", 396 "-Xep:NullableOnContainingClass:WARN", 397 ], 398 }, 399} 400 401// Java library for use on host, e.g. by robolectric or layoutlib. 402java_library { 403 name: "core-libart-for-host", 404 visibility: [ 405 "//art/build/sdk", 406 "//external/robolectric", 407 "//external/robolectric-shadows", 408 "//frameworks/base", 409 "//frameworks/layoutlib", 410 ], 411 static_libs: [ 412 "core-libart", 413 ], 414 sdk_version: "none", 415 system_modules: "none", 416} 417 418// Provided solely to contribute information about which hidden parts of the 419// core-oj API are used by apps. 420// 421// Usually, e.g. for core-libart, the UnsupportedAppUsage annotations are 422// added to the source that is compiled directly into the bootjar and the build 423// system extracts the information about UnsupportedAppUsage directly from 424// there. 425// 426// This approach of having separate annotated source and a separate build 427// target was taken for ojluni to avoid having to maintain local patches in the 428// ojluni source for UnsupportedAppUsage annotations as that would make it more 429// difficult to pull down changes from upstream. 430// 431java_library { 432 name: "core-oj-hiddenapi-annotations", 433 // Do not allow this to be accessed from outside this directory. 434 visibility: ["//libcore:__subpackages__"], 435 defaults: ["libcore_java_defaults"], 436 compile_dex: true, 437 438 srcs: [":openjdk_hiddenapi_javadoc_files"], 439 440 sdk_version: "none", 441 system_modules: "core-all-system-modules", 442 patch_module: "java.base", 443 plugins: ["unsupportedappusage-annotation-processor"], 444 445 errorprone: { 446 javacflags: [ 447 "-Xep:ComparableType:WARN", 448 ], 449 }, 450} 451 452java_defaults { 453 name: "core_lambda_stubs_defaults", 454 defaults: ["libcore_java_defaults"], 455 hostdex: true, 456 457 sdk_version: "none", 458 system_modules: "core-all-system-modules", 459 patch_module: "java.base", 460 461 installable: false, 462 include_srcs: true, 463} 464 465// Creates a jar that exists to satisfy javac when compiling source code that 466// contains lambdas. This contains all classes / methods required by javac 467// when generating invoke-dynamic lambda implementation code, even those that 468// are also in the public SDK API from API level 26 onwards. 469java_library { 470 name: "core-lambda-stubs", 471 visibility: [ 472 "//visibility:public", 473 ], 474 defaults: ["core_lambda_stubs_defaults"], 475 srcs: [ 476 ":openjdk_lambda_stub_files", 477 ":openjdk_lambda_duplicate_stub_files", 478 ], 479 // This jar is packaged as part of the SDK, use -target 8 so that it works 480 // with old JDKs. 481 java_version: "1.8", 482} 483 484// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files 485// because those classes are also part of the core library public SDK API 486// (since API level 26). 487java_library { 488 name: "core-lambda-stubs-for-system-modules", 489 visibility: [ 490 "//art/build/sdk", 491 "//build/soong/java/core-libraries", 492 "//frameworks/base", 493 "//frameworks/base/api", 494 ], 495 defaults: ["core_lambda_stubs_defaults"], 496 srcs: [ 497 ":openjdk_lambda_stub_files", 498 ], 499 include_srcs: true, 500 // This jar is packaged as part of the SDK, use -target 8 so that it works 501 // with old JDKs. 502 java_version: "1.8", 503} 504 505// This is an empty jar that exists for backwards compatibility with T (and below). 506// Historically, it existed to satisfy javac when compiling source code that 507// contains @Generated annotations. 508// This is no longer necessary since @Generated was added to ART's Public API 509// surface in U. 510java_library { 511 name: "core-generated-annotation-stubs", 512 visibility: [ 513 "//art/build/sdk", 514 "//build/soong/java/core-libraries", 515 "//frameworks/base", 516 "//frameworks/base/api", 517 ], 518 defaults: ["libcore_java_defaults"], 519 srcs: [ 520 ], 521 hostdex: true, 522 sdk_version: "none", 523 system_modules: "core-all-system-modules", 524 patch_module: "java.base", 525 installable: false, 526 include_srcs: true, 527 // This jar is packaged as part of the SDK, use -target 8 so that it works 528 // with old JDKs. 529 java_version: "1.8", 530} 531 532// Builds libcore test rules 533java_library_static { 534 name: "core-test-rules", 535 visibility: [ 536 "//art/build/sdk", 537 "//cts/tests/core/runner-axt", 538 "//cts/tests/tests/util", 539 "//external/conscrypt", 540 "//external/conscrypt/apex/tests", 541 "//frameworks/base/location/tests/locationtests", 542 "//frameworks/base/core/tests/coretests", 543 "//frameworks/base/wifi/tests", 544 "//libcore/ojluni/src/test", 545 "//libcore/luni/src/test/java9compatibility", 546 "//packages/modules/Wifi/framework/tests", 547 ], 548 hostdex: true, 549 srcs: [ 550 "dalvik/test-rules/src/main/**/*.java", 551 "test-rules/src/main/**/*.java", 552 ], 553 static_libs: [ 554 "junit", 555 "platform-test-annotations", 556 ], 557 558 sdk_version: "none", 559 system_modules: "core-all-system-modules", 560} 561 562// Builds platform_compat test rules 563java_library_static { 564 name: "core-compat-test-rules", 565 visibility: [ 566 "//art/build/sdk", 567 "//frameworks/base/tests/PlatformCompatGating/test-rules", 568 "//libcore:__subpackages__", 569 ], 570 srcs: [ 571 "luni/src/main/java/android/compat/**/*.java", 572 "test-rules/src/platform_compat/**/*.java", 573 "luni/src/main/java/libcore/api/CorePlatformApi.java", 574 "luni/src/main/java/libcore/api/IntraCoreApi.java", 575 ], 576 static_libs: [ 577 "junit", 578 "guava", 579 ], 580 sdk_version: "none", 581 system_modules: "core-all-system-modules", 582 // This builds classes that are in the java.base Java module: 583 patch_module: "java.base", 584 hostdex: true, 585 586 errorprone: { 587 javacflags: [ 588 "-Xep:EmptyTopLevelDeclaration:WARN", 589 "-Xep:GetClassOnAnnotation:WARN", 590 ], 591 }, 592} 593 594// Builds the core-tests-support library used by various tests. 595java_library_static { 596 name: "core-tests-support", 597 visibility: [ 598 "//art/build/sdk", 599 "//cts/apps/CtsVerifier", 600 "//cts/tests/tests/keystore", 601 "//cts/tests/tests/net", 602 "//cts/hostsidetests/statsdatom/apps/statsdapp", 603 "//cts/tests/tests/net/api23Test", 604 "//external/apache-harmony", 605 "//frameworks/base/core/tests/coretests", 606 "//frameworks/base/apct-tests/perftests/core", 607 "//libcore/benchmarks", 608 "//packages/apps/KeyChain/tests", 609 "//system/timezone/distro/core", 610 "//packages/modules/Connectivity/tests:__subpackages__", 611 ], 612 hostdex: true, 613 srcs: ["support/src/test/java/**/*.java"], 614 615 sdk_version: "core_platform", 616 // Make sure that this will be added to the sdk snapshot for S. 617 min_sdk_version: "S", 618 libs: ["junit"], 619 static_libs: [ 620 "bouncycastle-unbundled", 621 "bouncycastle-bcpkix-unbundled", 622 "bouncycastle-ocsp-unbundled", 623 ], 624 errorprone: { 625 javacflags: [ 626 "-Xep:BoxedPrimitiveEquality:WARN", 627 ], 628 }, 629} 630 631// Used to generate the prebuilt file luni/src/test/resources/prebuilt-dex-from-java.dex. 632// The reason why we pre-build this dex file is to stabilize the test result from the 633// dexer / javac / other toolchains change. 634// Regenerate the prebuilt file with the following command: 635// m core-tests-prebuilt-dex-from-java && 636// unzip out/soong/.intermediates/libcore/core-tests-prebuilt-dex-from-java/android_common/dex/core-tests-prebuilt-dex-from-java.jar classes.dex \ 637// -d libcore/luni/src/test/resources/ && mv libcore/luni/src/test/resources/classes.dex libcore/luni/src/test/resources/prebuilt-dex-from-java.dex 638java_test { 639 name: "core-tests-prebuilt-dex-from-java", 640 srcs: ["luni/src/test/dex_src/**/*.java"], 641 compile_dex: true, 642 defaults: ["libcore_java_defaults"], 643 sdk_version: "none", 644 system_modules: "core-all-system-modules", 645 646 visibility: [ 647 "//libcore:__subpackages__", 648 ], 649} 650 651// Builds the jsr166-tests library. 652java_test { 653 name: "jsr166-tests", 654 visibility: [ 655 "//art/build/sdk", 656 "//cts/tests/libcore/jsr166", 657 ], 658 srcs: ["jsr166-tests/src/test/java/**/*.java"], 659 sdk_version: "none", 660 system_modules: "core-all-system-modules", 661 libs: [ 662 "junit", 663 ], 664 errorprone: { 665 javacflags: [ 666 "-Xep:DoNotCall:OFF", 667 "-Xep:ModifyingCollectionWithItself:WARN", 668 "-Xep:ReturnValueIgnored:WARN", 669 "-Xep:HashtableContains:WARN", 670 ], 671 }, 672} 673 674// A filegroup that provides access to a source file for a toolchain test that 675// checks Java 9 language features are handled properly by JarJar. 676filegroup { 677 name: "core-java-9-language-features-source", 678 srcs: ["luni/src/main/java/libcore/internal/Java9LanguageFeatures.java"], 679 visibility: ["//libcore/luni/src/test/java9language"], 680} 681 682// A filegroup that provides access to a source file for a toolchain test that 683// checks Java 11 language features are handled properly by JarJar. 684filegroup { 685 name: "core-java-11-language-features-source", 686 srcs: ["luni/src/main/java/libcore/internal/Java11LanguageFeatures.java"], 687 visibility: ["//libcore/luni/src/test/java11language"], 688} 689 690// A filegroup that provides access to a source file for a toolchain test that 691// checks Java 17 language features are handled properly by JarJar. 692filegroup { 693 name: "core-java-17-language-features-source", 694 srcs: ["luni/src/main/java/libcore/internal/Java17LanguageFeatures.java"], 695 visibility: ["//libcore/luni/src/test/java17language"], 696} 697 698genrule { 699 name: "core-tests-smali-dex", 700 srcs: ["luni/src/test/java/**/*.smali"], 701 cmd: "$(location android-smali) ass --api 28 -o $(out) $(in)", 702 out: ["core-tests-smali.dex"], 703 tools: ["android-smali"], 704} 705 706filegroup { 707 name: "core-ojtests-javax-resources", 708 // Set path to keep the resources and .class files in the same directory in the jar file. 709 path: "ojluni/src", 710 srcs: ["ojluni/src/test/javax/**/*"], 711 exclude_srcs: ["ojluni/src/test/javax/**/*.java"], 712} 713 714filegroup { 715 name: "core-ojtests-java-resources", 716 // Set path to keep the resources and .class files in the same directory in the jar file. 717 path: "ojluni/src", 718 srcs: [ 719 "ojluni/src/test/java/util/regex/**/*", 720 "ojluni/src/test/java/util/Base64/**/*", 721 "ojluni/src/test/java/util/Scanner/**/*", 722 "ojluni/src/test/java/util/Properties/**/*", 723 ], 724 exclude_srcs: ["ojluni/src/test/java/**/*.java"], 725} 726 727// Builds the core-tests library. 728java_test { 729 name: "core-tests", 730 visibility: [ 731 "//art/build/sdk", 732 "//cts/tests/libcore/luni", 733 ], 734 defaults: ["libcore_java_defaults"], 735 hostdex: true, 736 srcs: [ 737 "dalvik/src/test/java/**/*.java", 738 "dalvik/test-rules/src/test/java/**/*.java", 739 "dom/src/test/java/**/*.java", 740 "harmony-tests/src/test/java/**/*.java", 741 "json/src/test/java/**/*.java", 742 "luni/src/test/java/**/*.java", 743 "test-rules/src/test/java/**/*.java", 744 "xml/src/test/java/**/*.java", 745 ], 746 exclude_srcs: [ 747 "harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/*.java", 748 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java", 749 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java", 750 "luni/src/test/java/libcore/javax/crypto/**/*.java", 751 "luni/src/test/java/libcore/javax/net/ssl/**/*.java", 752 "luni/src/test/java/org/apache/harmony/crypto/**/*.java", 753 ], 754 755 java_resource_dirs: [ 756 "*/src/test/java", 757 "*/src/test/resources", 758 ], 759 exclude_java_resource_dirs: [ 760 "ojluni/src/test/java", 761 "ojluni/src/test/javax", 762 "ojluni/src/test/resources", 763 ], 764 765 java_resources: [ 766 ":annotations-test", 767 ":filesystemstest", 768 ":parameter-metadata-test", 769 ":core-tests-smali-dex", 770 ], 771 772 sdk_version: "none", 773 system_modules: "core-all-system-modules", 774 libs: [ 775 "okhttp", 776 "bouncycastle", 777 ], 778 779 static_libs: [ 780 "apache-xml-tests", 781 "core-compat-test-rules", 782 "core-java-9-compatibility-tests", 783 "core-java-9-language-tests", 784 "core-java-11-language-tests", 785 "core-java-17-language-tests", 786 "core-test-rules", 787 "core-tests-support", 788 "junit-params", 789 "libcore-crypto-tests", 790 "mockftpserver", 791 "mockito-target", 792 "mockwebserver", 793 "nist-pkix-tests", 794 "slf4j-jdk14", 795 "sqlite-jdbc", 796 ], 797 798 errorprone: { 799 javacflags: [ 800 "-Xep:TryFailThrowable:ERROR", 801 "-Xep:ComparisonOutOfRange:ERROR", 802 "-Xep:DoNotCall:OFF", 803 "-Xep:ArrayToString:WARN", 804 "-Xep:SelfEquals:WARN", 805 "-Xep:SelfComparison:WARN", 806 "-Xep:ReturnValueIgnored:WARN", 807 "-Xep:BoxedPrimitiveEquality:WARN", 808 "-Xep:SizeGreaterThanOrEqualsZero:WARN", 809 "-Xep:MisusedDayOfYear:WARN", 810 "-Xep:InvalidTimeZoneID:WARN", 811 "-Xep:CollectionToArraySafeParameter:WARN", 812 "-Xep:ModifyingCollectionWithItself:WARN", 813 "-Xep:ComparableType:WARN", 814 "-Xep:UnusedCollectionModifiedInPlace:WARN", 815 "-Xep:HashtableContains:WARN", 816 "-Xep:DoubleBraceInitialization:WARN", 817 "-Xep:RandomModInteger:WARN", 818 "-Xep:IdentityBinaryExpression:WARN", 819 "-Xep:UnnecessaryStringBuilder:OFF", // https://github.com/google/error-prone/issues/4195 820 "-Xep:InvalidPatternSyntax:WARN", 821 ], 822 }, 823 824 test_config: "AndroidTest-core-tests.xml", 825} 826 827java_test { 828 name: "libcore-crypto-tests", 829 830 visibility: [ 831 "//art/build/sdk", 832 "//external/conscrypt/apex/tests", 833 ], 834 exclude_srcs: [ 835 "luni/src/test/java/libcore/javax/crypto/CipherTest.java", 836 ], 837 srcs: [ 838 "harmony-tests/src/test/java/org/apache/harmony/tests/javax/net/ssl/*.java", 839 "luni/src/test/java/libcore/javax/crypto/**/*.java", 840 "luni/src/test/java/libcore/javax/net/ssl/**/*.java", 841 "luni/src/test/java/libcore/libcore/util/SerializationTester.java", 842 "luni/src/test/java/libcore/sun/security/**/*.java", 843 "luni/src/test/java/org/apache/harmony/crypto/**/*.java", 844 ], 845 846 java_resource_dirs: [ 847 "luni/src/test/java", 848 "luni/src/test/resources", 849 "support/src/test/java", 850 ], 851 852 sdk_version: "none", 853 system_modules: "core-all-system-modules", 854 855 static_libs: [ 856 "core-test-rules", 857 "core-tests-support", 858 "junit-params", 859 "mockito-target", 860 ], 861 862 errorprone: { 863 javacflags: [ 864 "-Xep:ArrayToString:WARN", 865 "-Xep:ReturnValueIgnored:WARN", 866 ], 867 }, 868} 869 870java_genrule { 871 name: "libcore-non-cts-tests-txt", 872 host_supported: true, 873 srcs: [ 874 ":apache-harmony-tests{.jar}", 875 ":conscrypt-tests{.jar}", 876 ":core-tests{.jar}", 877 ":core-ojtests{.jar}", 878 ], 879 tools: ["non-cts-json-generator"], 880 out: ["libcore-non-cts-tests.txt"], 881 cmd: "$(location non-cts-json-generator) $(in) > $(out)", 882} 883 884// Exports annotated stubs source files in ojluni/annotations/sdk to make them 885// available to metalava. Used for nullability annotations in OpenJDK source. 886droiddoc_exported_dir { 887 name: "ojluni-annotated-sdk-stubs", 888 visibility: [ 889 "//libcore:__subpackages__", 890 ], 891 path: "ojluni/annotations/sdk", 892} 893 894droiddoc_exported_dir { 895 name: "ojluni-annotated-nullability-stubs", 896 path: "ojluni/annotations/sdk/nullability", 897} 898 899// Exports annotated stubs source files in ojluni/annotations/mmodules to make 900// them available to metalava. Used for core platform API and intra-core API 901// annotations in OpenJDK source. 902droiddoc_exported_dir { 903 name: "ojluni-annotated-mmodule-stubs", 904 visibility: [ 905 "//libcore/mmodules/intracoreapi", 906 ], 907 path: "ojluni/annotations/mmodule", 908} 909 910droiddoc_exported_dir { 911 name: "ojluni-annotated-flagged-stubs", 912 path: "ojluni/annotations/flagged_api", 913 visibility: ["//visibility:private"], 914} 915 916// A file containing the list of tags that are "known" to us from the OpenJdk 917// source code and so should not cause an error or warning. 918filegroup { 919 name: "known-oj-tags", 920 visibility: [ 921 "//frameworks/base", 922 "//frameworks/base/api", 923 ], 924 srcs: [ 925 "known_oj_tags.txt", 926 ], 927} 928 929// A special set of stubs containing the minimal set of self consistent 930// classes for which a system module can be created. Every system module must 931// contain the java.lang classes so the set was constructed by starting with 932// the java.lang classes and then adding their transitive dependencies without 933// splitting packages. So, if one class from a package is used then all classes 934// in that package were added to the set. 935// 936// Needed for java-current-stubs-system-modules. 937droidstubs { 938 name: "java-current-stubs-source", 939 srcs: [ 940 ":core_oj_api_files", 941 ":core_libart_api_files", 942 ], 943 installable: false, 944 sdk_version: "none", 945 system_modules: "none", 946 947 args: "--stub-packages java.*:javax.*:org.w3c.dom.*:org.xml.sax.*", 948} 949 950// Generates stub files for the classes exposed in the public API, without 951// javadoc. This can be used as a starting point for adding a new file to 952// libcore/luni/annotations/flagged_api. 953droidstubs { 954 name: "libart-sdk-stubs-no-javadoc", 955 srcs: [ 956 ":core_libart_api_files", 957 // The definition of @SystemApi is needed to generate module-lib stubs. 958 ":framework-api-annotations", 959 ], 960 installable: false, 961 sdk_version: "none", 962 system_modules: "none", 963 api_levels_sdk_type: "module-lib", 964 flags: [ 965 "--exclude-documentation-from-stubs", 966 "--show-for-stub-purposes-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.MODULE_LIBRARIES\\)", 967 ], 968} 969 970// Separate @FlaggedApi annotations for luni/ to avoid a circular dependency between 971// libcore_aconfig_flags_lib and core-all 972droiddoc_exported_dir { 973 name: "luni-annotated-flagged-stubs", 974 path: "luni/annotations/flagged_api", 975 visibility: ["//visibility:private"], 976} 977 978java_library { 979 name: "java.current.stubs", 980 srcs: [":java-current-stubs-source"], 981 errorprone: { 982 javacflags: [ 983 "-Xep:MissingOverride:OFF", 984 ], 985 }, 986 patch_module: "java.base", 987 sdk_version: "none", 988 system_modules: "none", 989} 990 991// A special set of system modules needed to build art.module.public.api 992java_system_modules { 993 name: "java-current-stubs-system-modules", 994 libs: [ 995 // Minimal set of classes required for a system module. 996 "java.current.stubs", 997 ], 998} 999 1000java_library { 1001 name: "framework-api-annotations-lib", 1002 srcs: [":framework-api-annotations"], 1003 sdk_version: "none", 1004 patch_module: "java.base", 1005 system_modules: "core-all-system-modules", 1006 installable: false, 1007 visibility: [ 1008 "//visibility:private", 1009 ], 1010} 1011 1012aconfig_declarations { 1013 name: "libcore_aconfig_flags", 1014 package: "com.android.libcore", 1015 container: "com.android.art", 1016 exportable: true, 1017 srcs: ["libcore.aconfig"], 1018 visibility: [ 1019 "//frameworks/base", 1020 ], 1021} 1022 1023java_aconfig_library { 1024 name: "libcore_aconfig_flags_lib", 1025 aconfig_declarations: "libcore_aconfig_flags", 1026 sdk_version: "none", 1027 patch_module: "java.base", 1028 system_modules: "core-all-system-modules", 1029 apex_available: [ 1030 "com.android.art", 1031 // Remove :platform until we allow platform codes to use libcore's @FlaggedApi APIs 1032 // "//apex_available:platform", 1033 ], 1034 visibility: [ 1035 "//visibility:private", 1036 ], 1037} 1038 1039// Define the public SDK API provided by the ART module. 1040java_sdk_library { 1041 name: "art.module.public.api", 1042 visibility: [ 1043 "//art/build/sdk", 1044 "//build/soong/java/core-libraries", 1045 "//frameworks/base", 1046 "//frameworks/base/api", 1047 1048 // DO NOT REMOVE: Legacy visibility, needed for snapshots that are 1049 // generated for the S build. 1050 "//libcore/mmodules/core_platform_api", 1051 ], 1052 srcs: [ 1053 ":core_oj_api_files", 1054 ":core_libart_api_files", 1055 1056 // Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are 1057 // annotated by applying annotations to the .annotated.java stubs files in 1058 // ojluni/annotated/mmodules and rather than in the original source. See the comments 1059 // in openjdk_java_files.bp for more details. 1060 ":openjdk_mmodule_extra_files", 1061 ":okhttp_api_files", 1062 ], 1063 api_srcs: [ 1064 ":openjdk_javadoc_only_files", 1065 ], 1066 libs: [ 1067 // Put framework-api-annotations into libs to avoid exposing the definition of framework's 1068 // annotations from libcore (wrong place) instead of framework (correct place). 1069 "framework-api-annotations-lib", 1070 // Provide access to I18N constants that are used to initialize 1071 // constants in the public API. i.e. to allow the value of the 1072 // java.text.CollectionElementIterator.NULLORDER to be initialized from 1073 // android.icu.text.CollationElementIterator.NULLORDER. 1074 "i18n.module.intra.core.api.stubs", 1075 "libcore_aconfig_flags_lib", 1076 ], 1077 stub_only_static_libs: ["notices-for-stubs-jar"], 1078 1079 // Make dex jars for the stubs available for use by hiddenapi processing. 1080 compile_dex: true, 1081 1082 public: { 1083 enabled: true, 1084 }, 1085 system: { 1086 enabled: true, 1087 }, 1088 module_lib: { 1089 enabled: true, 1090 }, 1091 1092 api_only: true, 1093 droiddoc_options: [ 1094 "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.* ", 1095 "--hide-annotation libcore.api.Hide", 1096 ], 1097 1098 merge_inclusion_annotations_dirs: [ 1099 "luni-annotated-flagged-stubs", 1100 "ojluni-annotated-flagged-stubs", 1101 "ojluni-annotated-mmodule-stubs", 1102 ], 1103 // Emit nullability annotations from the source to the stub files. 1104 annotations_enabled: true, 1105 1106 merge_annotations_dirs: [ 1107 "metalava-manual", 1108 "ojluni-annotated-sdk-stubs", 1109 ], 1110 1111 doctag_files: [ 1112 ":known-oj-tags", 1113 ], 1114 1115 errorprone: { 1116 javacflags: [ 1117 "-Xep:MissingOverride:OFF", 1118 ], 1119 }, 1120 patch_module: "java.base", 1121 sdk_version: "none", 1122 system_modules: "java-current-stubs-system-modules", 1123 // The base name for the artifacts that are automatically published to the 1124 // dist and which end up in one of the sub-directories of prebuilts/sdk. 1125 // As long as this matches the name of the artifacts in prebuilts/sdk then 1126 // the API will be checked for compatibility against the latest released 1127 // version of the API. 1128 dist_stem: "art", 1129 dist_group: "android", 1130 aconfig_declarations: [ 1131 "libcore_aconfig_flags", 1132 ], 1133} 1134 1135// Target for validating nullability annotations for correctness and 1136// completeness. To check that there are no nullability errors: 1137// m art-module-public-api-stubs-nullability-validation 1138// To check that there are only the expected nullability warnings: 1139// m art-module-public-api-stubs-nullability-validation-check-nullability-warnings 1140// (If that check fails, it will provide instructions on how to proceed, 1141// including the command to run to update the expected warnings file.) 1142droidstubs { 1143 name: "art-module-public-api-stubs-nullability-validation", 1144 srcs: [":art_module_api_files"], 1145 installable: false, 1146 sdk_version: "none", 1147 system_modules: "none", 1148 annotations_enabled: true, 1149 args: "--hide-annotation libcore.api.Hide " + 1150 "--validate-nullability-from-merged-stubs ", 1151 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"], 1152 merge_annotations_dirs: [ 1153 // N.B. Stubs in this filegroup will be validated: 1154 "ojluni-annotated-nullability-stubs", 1155 ], 1156 // The list of classes which have nullability annotations included in the source. 1157 // (This is in addition to those which have annotations in the merged stubs.) 1158 validate_nullability_from_list: "nullability_annotated_classes.txt", 1159 // The expected set of warnings about missing annotations: 1160 check_nullability_warnings: "nullability_warnings.txt", 1161} 1162 1163// A special set of system modules for building the following library for use 1164// in the art-module-public-api-system-modules. 1165java_system_modules { 1166 name: "api-annotations-system-modules", 1167 libs: [ 1168 "art.module.public.api.stubs", 1169 ], 1170} 1171 1172// A library that contains annotations that define API surfaces (core 1173// platform, intra core and the hidden API) along with some supporting 1174// constants. The annotations are source only and do not introduce any runtime 1175// dependencies. Specially built for use in system modules definitions to 1176// avoid introducing compile time cycles. 1177java_library { 1178 name: "art.module.api.annotations.for.system.modules", 1179 visibility: [ 1180 "//build/soong/java/core-libraries", 1181 ], 1182 srcs: [ 1183 ":api_surface_annotation_files", 1184 ], 1185 1186 installable: false, 1187 sdk_version: "none", 1188 system_modules: "api-annotations-system-modules", 1189 patch_module: "java.base", 1190 // This jar is packaged as part of the SDK, use -target 8 so that it works 1191 // with old JDKs. 1192 java_version: "1.8", 1193} 1194 1195// Create a library containing the api surface annotations, built against 1196// core_current for use by the annotation processor in frameworks/base. 1197java_library { 1198 name: "art.module.api.annotations", 1199 visibility: [ 1200 "//art/build/sdk", 1201 "//external/icu/android_icu4j", 1202 "//frameworks/base", 1203 "//frameworks/base/api", 1204 ], 1205 host_supported: true, 1206 srcs: [ 1207 ":api_surface_annotation_files", 1208 ], 1209 sdk_version: "core_current", 1210 // Make sure that this will be added to the sdk snapshot for S. 1211 min_sdk_version: "S", 1212 // This jar is packaged as part of the ART module host exports, use -target 8 so that it works 1213 // with old JDKs. 1214 java_version: "1.8", 1215} 1216