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