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