xref: /aosp_15_r20/external/icu/android_icu4j/Android.bp (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8//      http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
17package {
18    default_team: "trendy_team_java_core_libraries",
19    default_visibility: ["//visibility:private"],
20    // See: http://go/android-license-faq
21    // A large-scale-change added 'default_applicable_licenses' to import
22    // all of the 'license_kinds' from "external_icu_license"
23    // to get the below license kinds:
24    //   SPDX-license-identifier-Apache-2.0
25    //   SPDX-license-identifier-BSD
26    //   SPDX-license-identifier-ICU
27    //   SPDX-license-identifier-MIT
28    //   SPDX-license-identifier-Unicode-DFS
29    //   legacy_unencumbered
30    default_applicable_licenses: ["external_icu_license"],
31}
32
33//==========================================================
34// build repackaged ICU for target
35//
36// This is done in the libcore/JavaLibraries.mk file as there are circular
37// dependencies between ICU and libcore
38//==========================================================
39filegroup {
40    name: "android_icu4j_public_api_files",
41    srcs: [
42        ":android_icu4j_repackaged_src_files",
43    ],
44    path: "src/main/java",
45}
46
47filegroup {
48    name: "android_icu4j_repackaged_src_files",
49    srcs: ["src/main/java/android/icu/**/*.java"],
50    path: "src/main/java",
51}
52
53// The files contains Android-specific codes to expose intra-core APIs
54// from ICU4J/ICU4C to libcore or core platform APIs to the framework.
55// The package is com.android.icu.* and should not expose any public APIs.
56filegroup {
57    name: "libcore_icu_bridge_src_files",
58    srcs: ["libcore_bridge/src/java/**/*.java"],
59    path: "libcore_bridge/src/java",
60}
61
62java_defaults {
63    name: "libcore_icu_bridge_defaults",
64    srcs: [
65        "libcore_bridge/src/java/**/*.java",
66        ":app-compat-annotations-source",
67    ],
68    jarjar_rules: "jarjar-rules.txt",
69    plugins: [
70        "compat-changeid-annotation-processor",
71    ],
72}
73
74// A host library containing time zone related classes. Used for
75// host-side tools and tests that have to deal with Android
76// time zone data.
77java_library_host {
78    name: "timezone-host",
79    visibility: [
80        "//packages/modules/RuntimeI18n/apex",
81        "//system/timezone/input_tools/version",
82    ],
83    srcs: [
84        "libcore_bridge/src/java/com/android/i18n/timezone/TzDataSetVersion.java",
85    ],
86    libs: [
87        "art.module.api.annotations",
88    ],
89}
90
91// core-repackaged-icu4j contains only the repackaged ICU4J that does not
92// use any internal or android specific code. If it ever did then it could depend on
93// art-module-intra-core-api-stubs-system-modules (a superset) instead.
94// It is important that core-icu4j is restricted to only use stable APIs from the ART module
95// since it is in a different APEX module that can be updated independently.
96java_library_static {
97    name: "core-repackaged-icu4j",
98    installable: false,
99    srcs: [":android_icu4j_repackaged_src_files"],
100    libs: [
101        "unsupportedappusage",
102        // Need framework-api-annotations-lib for @FlaggedApi.
103        // Put framework-api-annotations into libs to avoid exposing the definition of framework's
104        // annotations from ICU (wrong place) instead of framework (correct place).
105        "framework-annotations-lib",
106        // We only need the aconfig library for @FlaggedApi. We can move it to static_libs
107        // if we need it for flagging features in the future.
108        "icu_aconfig_flags_lib",
109    ],
110    // The resource files are generated in the downstream branch master-icu-dev.
111    java_resource_dirs: ["resources"],
112
113    sdk_version: "none",
114    system_modules: "art-module-public-api-stubs-system-modules",
115
116    dxflags: ["--core-library"],
117    apex_available: [
118        "com.android.i18n",
119    ],
120    errorprone: {
121        javacflags: [
122            "-Xep:MissingOverride:OFF", // Ignore missing @Override.
123            "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
124            "-Xep:BoxedPrimitiveEquality:WARN",
125            "-Xep:ComparableType:WARN",
126            "-Xep:EmptyTopLevelDeclaration:WARN",
127        ],
128    },
129    lint: {
130        warning_checks: ["SuspiciousIndentation"],
131        baseline_filename: "lint-baseline.xml",
132    },
133}
134
135// A separated core library that contains ICU4J because ICU4J will be in a different APEX module,
136// not in ART module.
137java_library {
138    name: "core-icu4j",
139    defaults: ["libcore_icu_bridge_defaults"],
140    visibility: [
141        "//art/tools/fuzzer",
142        "//packages/modules/RuntimeI18n/apex",
143    ],
144    apex_available: [
145        "com.android.i18n",
146    ],
147    permitted_packages: [
148        "android.icu",
149        "com.android.icu",
150        "com.android.i18n.system",
151        "com.android.i18n.timezone",
152        "com.android.i18n.util",
153    ],
154    installable: true,
155    hostdex: false,
156
157    static_libs: ["core-repackaged-icu4j"],
158
159    // It is important that core-icu4j is restricted to only use stable APIs from the ART module
160    // since it is in a different APEX module that can be updated independently.
161    sdk_version: "none",
162    system_modules: "art-module-intra-core-api-stubs-system-modules",
163
164    dxflags: ["--core-library"],
165}
166
167// Java library for use on host, e.g. by ravenwood, robolectric.
168java_library {
169    name: "core-icu4j-for-host",
170    visibility: [
171        "//art/build",
172        "//external/robolectric",
173        "//external/robolectric-shadows",
174        "//frameworks/layoutlib",
175        "//frameworks/base/ravenwood:__subpackages__",
176        "//packages/modules/RuntimeI18n/apex",
177    ],
178    static_libs: [
179        "core-icu4j",
180    ],
181    sdk_version: "none",
182    system_modules: "none",
183}
184
185platform_compat_config {
186    name: "icu4j-platform-compat-config",
187    src: ":core-icu4j",
188    visibility: [
189        "//frameworks/base",
190    ],
191}
192
193java_sdk_library {
194    name: "i18n.module.public.api",
195    visibility: [
196        "//build/soong/java/core-libraries",
197        "//frameworks/base",
198        "//frameworks/base/api",
199        "//packages/modules/RuntimeI18n/apex",
200        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
201        // this module.
202        // TODO(b/155921753): Restrict this when prebuilts are in their proper
203        // locations.
204        "//prebuilts:__subpackages__",
205    ],
206    // Added to make sure that no private classes leak out in stubs.
207    defaults: ["libcore_icu_bridge_defaults"],
208    srcs: [
209        // Added to make sure that no private classes leak out in stubs.
210        ":android_icu4j_repackaged_src_files",
211        ":android_icu4j_public_api_files",
212    ],
213    libs: [
214        "icu_aconfig_flags_lib",
215    ],
216    droiddoc_options: [
217        "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.* ",
218    ],
219    errorprone: {
220        javacflags: [
221            "-Xep:MissingOverride:OFF",
222        ],
223    },
224    lint: {
225        warning_checks: ["SuspiciousIndentation"],
226    },
227
228    public: {
229        enabled: true,
230    },
231    system: {
232        enabled: true,
233    },
234    module_lib: {
235        enabled: true,
236    },
237
238    api_dir: "api/public",
239    api_only: true,
240
241    // Emit nullability annotations from the source to the stub files.
242    annotations_enabled: true,
243
244    sdk_version: "none",
245    system_modules: "art-module-public-api-stubs-system-modules",
246
247    // The base name for the artifacts that are automatically published to the
248    // dist and which end up in one of the sub-directories of prebuilts/sdk.
249    // As long as this matches the name of the artifacts in prebuilts/sdk then
250    // the API will be checked for compatibility against the latest released
251    // version of the API.
252    dist_stem: "runtime-i18n",
253    dist_group: "android",
254    aconfig_declarations: [
255        "icu_aconfig_flags",
256    ],
257}
258
259// Generates stub source files for the intra-core API of the I18N module.
260// i.e. every class/member that is either in the public API or annotated with
261// @IntraCoreApi.
262//
263// The API specification .txt files managed by this only contain the additional
264// classes/members that are in the intra-core API but which are not the public
265// API.
266java_sdk_library {
267    name: "i18n.module.intra.core.api",
268    defaults: ["libcore_icu_bridge_defaults"],
269    srcs: [
270        ":android_icu4j_repackaged_src_files",
271    ],
272    visibility: [
273        "//libcore:__subpackages__",
274        "//packages/modules/RuntimeI18n/apex",
275        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
276        // this module.
277        // TODO(b/155921753): Restrict this when prebuilts are in their proper
278        // locations.
279        "//prebuilts:__subpackages__",
280    ],
281    api_dir: "api/intra",
282    api_only: true,
283    sdk_version: "none",
284    system_modules: "art-module-intra-core-api-stubs-system-modules",
285
286    droiddoc_options: [
287        "--hide-annotation libcore.api.Hide ",
288        "--show-single-annotation libcore.api.IntraCoreApi ",
289    ],
290
291    // Don't copy any output files to the dist.
292    no_dist: true,
293
294    lint: {
295        warning_checks: ["SuspiciousIndentation"],
296    },
297
298    // This module's output stubs contain apis defined in "i18n.module.public.api.stubs",
299    // but adding "i18n.module.public.api" as a dependency of this module leads to circular
300    // dependency and requires further bootstrapping. Thus, disable stubs generation from the
301    // api signature files and generate stubs from the source Java files instead.
302    build_from_text_stub: false,
303}
304
305// Referenced implicitly from i18n.module.intra.core.api.
306filegroup {
307    name: "i18n.module.intra.core.api.api.combined.public.latest",
308    srcs: [
309        "api/intra/last-api.txt",
310    ],
311}
312
313// Referenced implicitly from i18n.module.intra.core.api.
314filegroup {
315    name: "i18n.module.intra.core.api-removed.api.combined.public.latest",
316    srcs: [
317        "api/intra/last-removed.txt",
318    ],
319}
320
321// Referenced implicitly from i18n.module.intra.core.api.
322filegroup {
323    name: "i18n.module.intra.core.api-incompatibilities.api.public.latest",
324    srcs: [
325        "api/intra/last-incompatibilities.txt",
326    ],
327}
328
329// Referenced implicitly from legacy.i18n.module.platform.api.
330filegroup {
331    name: "legacy.i18n.module.platform.api.api.combined.public.latest",
332    srcs: [
333        "api/legacy_platform/last-api.txt",
334    ],
335}
336
337// Referenced implicitly from legacy.i18n.module.platform.api.
338filegroup {
339    name: "legacy.i18n.module.platform.api-removed.api.combined.public.latest",
340    srcs: [
341        "api/legacy_platform/last-removed.txt",
342    ],
343}
344
345// Referenced implicitly from legacy.i18n.module.platform.api.
346filegroup {
347    name: "legacy.i18n.module.platform.api-incompatibilities.api.public.latest",
348    srcs: [
349        "api/legacy_platform/last-incompatibilities.txt",
350    ],
351}
352
353// Referenced implicitly from stable.i18n.module.platform.api.
354filegroup {
355    name: "stable.i18n.module.platform.api.api.combined.public.latest",
356    srcs: [
357        "api/stable_platform/last-api.txt",
358    ],
359}
360
361// Referenced implicitly from stable.i18n.module.platform.api.
362filegroup {
363    name: "stable.i18n.module.platform.api-removed.api.combined.public.latest",
364    srcs: [
365        "api/stable_platform/last-removed.txt",
366    ],
367}
368
369// Referenced implicitly from stable.i18n.module.platform.api.
370filegroup {
371    name: "stable.i18n.module.platform.api-incompatibilities.api.public.latest",
372    srcs: [
373        "api/stable_platform/last-incompatibilities.txt",
374    ],
375}
376
377// Used by ravenwood for processing
378filegroup {
379    name: "icu-ravenwood-policies",
380    visibility: ["//frameworks/base/ravenwood"],
381    srcs: [
382        "icu-ravenwood-policies.txt",
383    ],
384}
385
386// Generates stub source files for the core platform API of the I18N module.
387// i.e. every class/member that is either in the public API or annotated with
388// @CorePlatformApi.
389//
390// The API specification .txt files managed by this only contain the additional
391// classes/members that are in the intra-core API but which are not in the public
392// API.
393//
394// For notes on the legacy and stable versions see mmodules/core_platform_api/Android.bp.
395
396java_sdk_library {
397    name: "legacy.i18n.module.platform.api",
398    defaults: ["libcore_icu_bridge_defaults"],
399    srcs: [
400        ":android_icu4j_repackaged_src_files",
401    ],
402    visibility: [
403        "//build/soong/java/core-libraries",
404        "//packages/modules/RuntimeI18n/apex",
405        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
406        // this module.
407        // TODO(b/155921753): Restrict this when prebuilts are in their proper
408        // locations.
409        "//prebuilts:__subpackages__",
410    ],
411    hostdex: true,
412    api_dir: "api/legacy_platform",
413    api_only: true,
414    sdk_version: "none",
415    system_modules: "art-module-lib-api-stubs-system-modules",
416
417    droiddoc_options: [
418        "--hide-annotation libcore.api.Hide ",
419        "--show-single-annotation libcore.api.CorePlatformApi ",
420    ],
421
422    // Don't copy any output files to the dist.
423    no_dist: true,
424
425    lint: {
426        warning_checks: ["SuspiciousIndentation"],
427    },
428}
429
430java_sdk_library {
431    name: "stable.i18n.module.platform.api",
432    defaults: ["libcore_icu_bridge_defaults"],
433    srcs: [
434        ":android_icu4j_repackaged_src_files",
435    ],
436    visibility: [
437        "//build/soong/java/core-libraries",
438        "//packages/modules/RuntimeI18n/apex",
439        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
440        // this module.
441        // TODO(b/155921753): Restrict this when prebuilts are in their proper
442        // locations.
443        "//prebuilts:__subpackages__",
444    ],
445    hostdex: true,
446    api_dir: "api/stable_platform",
447    api_only: true,
448    sdk_version: "none",
449    system_modules: "art-module-lib-api-stubs-system-modules",
450
451    droiddoc_options: [
452        "--hide-annotation libcore.api.Hide ",
453        "--show-single-annotation libcore.api.CorePlatformApi\\(status=libcore.api.CorePlatformApi.Status.STABLE\\)",
454    ],
455
456    // Don't copy any output files to the dist.
457    no_dist: true,
458
459    lint: {
460        warning_checks: ["SuspiciousIndentation"],
461    },
462}
463
464//==========================================================
465// build repackaged ICU tests
466//
467// Target builds against core-libart and core-oj so that it can access all the
468// repackaged android.icu classes and methods and not just the ones available
469// through the Android API.
470//==========================================================
471java_defaults {
472    name: "android-icu4j-tests-default",
473    visibility: [
474        "//cts/tests/tests/icu",
475    ],
476    java_resource_dirs: [
477        "src/main/tests",
478        "testing/src",
479    ],
480    libs: [
481        "core-icu4j",
482    ],
483    static_libs: [
484        "gson",
485        "junit",
486        "junit-params",
487        "tzdata-testing",
488    ],
489
490    patch_module: "java.base",
491    sdk_version: "none",
492    system_modules: "art-module-intra-core-api-stubs-system-modules",
493
494    errorprone: {
495        javacflags: [
496            "-Xep:EqualsNull:WARN",
497            "-Xep:ArrayToString:WARN",
498            "-Xep:SelfEquals:WARN",
499            "-Xep:SelfComparison:WARN",
500            "-Xep:ReturnValueIgnored:WARN",
501            "-Xep:IdentityBinaryExpression:WARN",
502            "-Xep:BoxedPrimitiveEquality:WARN",
503            "-Xep:ComparableType:WARN",
504        ],
505    },
506}
507
508java_test {
509    name: "android-icu4j-tests",
510    defaults: ["android-icu4j-tests-default"],
511    visibility: [
512        "//cts/tests/tests/icu",
513    ],
514    srcs: [
515        "src/main/tests/**/*.java",
516        "testing/src/**/*.java",
517    ],
518}
519
520// Equivalent to android-icu4j-tests, excluding the tests under testing/.
521// We run this as ICU CTS on Ravenwood, where the testing/ tests won't pass due to lack of
522// libcore.
523java_test {
524    name: "android-icu4j-tests-core-only",
525    defaults: ["android-icu4j-tests-default"],
526    visibility: [
527        "//cts/tests/tests/icu",
528    ],
529    srcs: [
530        "src/main/tests/**/*.java",
531        "testing/src/android/icu/testsharding/**/*.java",
532    ],
533    // TODO(b/340889954) Un-excluide the excluded tests.
534    exclude_srcs: [
535        // This class has a "known-failure", which we can't exclude on Ravenwood without
536        // modifying this file, so let's just exclude the whole class for now.
537        "src/main/tests/android/icu/dev/test/format/NumberFormatRegressionTest.java",
538
539        // This test takes too much time and hits the timeout.
540        "src/main/tests/android/icu/dev/test/rbbi/RBBIMonkeyTest.java",
541    ],
542}
543