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_visibility: ["//visibility:private"],
19    // See: http://go/android-license-faq
20    // A large-scale-change added 'default_applicable_licenses' to import
21    // all of the 'license_kinds' from "external_icu_license"
22    // to get the below license kinds:
23    //   SPDX-license-identifier-Apache-2.0
24    //   SPDX-license-identifier-BSD
25    //   SPDX-license-identifier-ICU
26    //   SPDX-license-identifier-MIT
27    //   SPDX-license-identifier-Unicode-DFS
28    //   legacy_unencumbered
29    default_applicable_licenses: ["external_icu_license"],
30}
31
32//==========================================================
33// build repackaged ICU for target
34//
35// This is done in the libcore/JavaLibraries.mk file as there are circular
36// dependencies between ICU and libcore
37//==========================================================
38filegroup {
39    name: "android_icu4j_public_api_files",
40    srcs: [
41        ":android_icu4j_repackaged_src_files",
42    ],
43    path: "src/main/java",
44}
45
46filegroup {
47    name: "android_icu4j_repackaged_src_files",
48    srcs: ["src/main/java/android/icu/**/*.java"],
49    path: "src/main/java",
50}
51
52// The files contains Android-specific codes to expose intra-core APIs
53// from ICU4J/ICU4C to libcore or core platform APIs to the framework.
54// The package is com.android.icu.* and should not expose any public APIs.
55filegroup {
56    name: "libcore_icu_bridge_src_files",
57    srcs: ["libcore_bridge/src/java/**/*.java"],
58    path: "libcore_bridge/src/java",
59}
60
61java_defaults {
62    name: "libcore_icu_bridge_defaults",
63    srcs: [
64        "libcore_bridge/src/java/**/*.java",
65        ":app-compat-annotations-source",
66    ],
67    jarjar_rules: "jarjar-rules.txt",
68    plugins: [
69        "compat-changeid-annotation-processor",
70    ],
71}
72
73// A host library containing time zone related classes. Used for
74// host-side tools and tests that have to deal with Android
75// time zone data.
76java_library_host {
77    name: "timezone-host",
78    visibility: [
79        "//packages/modules/RuntimeI18n/apex",
80        "//system/timezone/distro/core",
81    ],
82    srcs: [
83        "libcore_bridge/src/java/com/android/i18n/timezone/TzDataSetVersion.java",
84    ],
85    libs: [
86        "art.module.api.annotations",
87    ],
88}
89
90// core-repackaged-icu4j contains only the repackaged ICU4J that does not
91// use any internal or android specific code. If it ever did then it could depend on
92// art-module-intra-core-api-stubs-system-modules (a superset) instead.
93// It is important that core-icu4j is restricted to only use stable APIs from the ART module
94// since it is in a different APEX module that can be updated independently.
95java_library_static {
96    name: "core-repackaged-icu4j",
97    installable: false,
98    srcs: [":android_icu4j_repackaged_src_files"],
99    libs: ["unsupportedappusage"],
100    // The resource files are generated in the downstream branch master-icu-dev.
101    java_resource_dirs: ["resources"],
102
103    sdk_version: "none",
104    system_modules: "art-module-public-api-stubs-system-modules",
105
106    dxflags: ["--core-library"],
107    apex_available: [
108        "com.android.i18n",
109    ],
110    errorprone: {
111        javacflags: [
112            "-Xep:MissingOverride:OFF", // Ignore missing @Override.
113            "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
114        ],
115    },
116}
117
118// A separated core library that contains ICU4J because ICU4J will be in a different APEX module,
119// not in ART module.
120java_library {
121    name: "core-icu4j",
122    defaults: ["libcore_icu_bridge_defaults"],
123    visibility: [
124        "//packages/modules/RuntimeI18n/apex",
125    ],
126    apex_available: [
127        "com.android.i18n",
128    ],
129    permitted_packages: [
130        "android.icu",
131        "com.android.icu",
132        "com.android.i18n.timezone",
133    ],
134    installable: true,
135    hostdex: false,
136
137    static_libs: ["core-repackaged-icu4j"],
138
139    // It is important that core-icu4j is restricted to only use stable APIs from the ART module
140    // since it is in a different APEX module that can be updated independently.
141    sdk_version: "none",
142    system_modules: "art-module-intra-core-api-stubs-system-modules",
143
144    dxflags: ["--core-library"],
145}
146
147// Java library for use on host, e.g. by robolectric.
148java_library {
149    name: "core-icu4j-for-host",
150    visibility: [
151        "//art/build",
152        "//external/robolectric-shadows",
153        "//frameworks/layoutlib",
154        "//packages/modules/RuntimeI18n/apex",
155    ],
156    static_libs: [
157        "core-icu4j",
158    ],
159    sdk_version: "none",
160    system_modules: "none",
161}
162
163platform_compat_config {
164    name: "icu4j-platform-compat-config",
165    src: ":core-icu4j",
166}
167
168java_sdk_library {
169    name: "i18n.module.public.api",
170    visibility: [
171        "//frameworks/base",
172        "//frameworks/base/api",
173        "//libcore",
174        "//packages/modules/RuntimeI18n/apex",
175        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
176        // this module.
177        // TODO(b/155921753): Restrict this when prebuilts are in their proper
178        // locations.
179        "//prebuilts:__subpackages__",
180    ],
181    srcs: [
182        ":android_icu4j_public_api_files",
183    ],
184    droiddoc_options: [
185        "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.* ",
186    ],
187    errorprone: {
188        javacflags: [
189            "-Xep:MissingOverride:OFF",
190        ],
191    },
192    api_dir: "api/public",
193    api_only: true,
194    sdk_version: "none",
195    system_modules: "art-module-public-api-stubs-system-modules",
196
197    // The base name for the artifacts that are automatically published to the
198    // dist and which end up in one of the sub-directories of prebuilts/sdk.
199    // As long as this matches the name of the artifacts in prebuilts/sdk then
200    // the API will be checked for compatibility against the latest released
201    // version of the API.
202    dist_stem: "runtime-i18n",
203    dist_group: "android",
204}
205
206// Generates stub source files for the intra-core API of the I18N module.
207// i.e. every class/member that is either in the public API or annotated with
208// @IntraCoreApi.
209//
210// The API specification .txt files managed by this only contain the additional
211// classes/members that are in the intra-core API but which are not the public
212// API.
213java_sdk_library {
214    name: "i18n.module.intra.core.api",
215    defaults: ["libcore_icu_bridge_defaults"],
216    srcs: [
217        ":android_icu4j_repackaged_src_files",
218    ],
219    visibility: [
220        "//libcore:__subpackages__",
221        "//packages/modules/RuntimeI18n/apex",
222        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
223        // this module.
224        // TODO(b/155921753): Restrict this when prebuilts are in their proper
225        // locations.
226        "//prebuilts:__subpackages__",
227    ],
228    api_dir: "api/intra",
229    api_only: true,
230    sdk_version: "none",
231    system_modules: "art-module-intra-core-api-stubs-system-modules",
232
233    droiddoc_options: [
234        "--hide-annotation libcore.api.Hide ",
235        "--show-single-annotation libcore.api.IntraCoreApi ",
236        "--skip-annotation-instance-methods=false ",
237    ],
238
239    // Don't copy any output files to the dist.
240    no_dist: true,
241}
242
243// Referenced implicitly from i18n.module.intra.core.api.
244filegroup {
245    name: "i18n.module.intra.core.api.api.public.latest",
246    srcs: [
247        "api/intra/last-api.txt",
248    ],
249}
250
251// Referenced implicitly from i18n.module.intra.core.api.
252filegroup {
253    name: "i18n.module.intra.core.api-removed.api.public.latest",
254    srcs: [
255        "api/intra/last-removed.txt",
256    ],
257}
258
259// Referenced implicitly from i18n.module.intra.core.api.
260filegroup {
261    name: "i18n.module.intra.core.api-incompatibilities.api.public.latest",
262    srcs: [
263        "api/intra/last-incompatibilities.txt",
264    ],
265}
266
267// Referenced implicitly from legacy.i18n.module.platform.api.
268filegroup {
269    name: "legacy.i18n.module.platform.api.api.public.latest",
270    srcs: [
271        "api/legacy_platform/last-api.txt",
272    ],
273}
274
275// Referenced implicitly from legacy.i18n.module.platform.api.
276filegroup {
277    name: "legacy.i18n.module.platform.api-removed.api.public.latest",
278    srcs: [
279        "api/legacy_platform/last-removed.txt",
280    ],
281}
282
283// Referenced implicitly from legacy.i18n.module.platform.api.
284filegroup {
285    name: "legacy.i18n.module.platform.api-incompatibilities.api.public.latest",
286    srcs: [
287        "api/legacy_platform/last-incompatibilities.txt",
288    ],
289}
290
291// Referenced implicitly from stable.i18n.module.platform.api.
292filegroup {
293    name: "stable.i18n.module.platform.api.api.public.latest",
294    srcs: [
295        "api/stable_platform/last-api.txt",
296    ],
297}
298
299// Referenced implicitly from stable.i18n.module.platform.api.
300filegroup {
301    name: "stable.i18n.module.platform.api-removed.api.public.latest",
302    srcs: [
303        "api/stable_platform/last-removed.txt",
304    ],
305}
306
307// Referenced implicitly from stable.i18n.module.platform.api.
308filegroup {
309    name: "stable.i18n.module.platform.api-incompatibilities.api.public.latest",
310    srcs: [
311        "api/stable_platform/last-incompatibilities.txt",
312    ],
313}
314
315// Generates stub source files for the core platform API of the I18N module.
316// i.e. every class/member that is either in the public API or annotated with
317// @CorePlatformApi.
318//
319// The API specification .txt files managed by this only contain the additional
320// classes/members that are in the intra-core API but which are not in the public
321// API.
322//
323// For notes on the legacy and stable versions see mmodules/core_platform_api/Android.bp.
324
325java_sdk_library {
326    name: "legacy.i18n.module.platform.api",
327    defaults: ["libcore_icu_bridge_defaults"],
328    srcs: [
329        ":android_icu4j_repackaged_src_files",
330    ],
331    visibility: [
332        "//libcore:__subpackages__",
333        "//packages/modules/RuntimeI18n/apex",
334        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
335        // this module.
336        // TODO(b/155921753): Restrict this when prebuilts are in their proper
337        // locations.
338        "//prebuilts:__subpackages__",
339    ],
340    hostdex: true,
341    api_dir: "api/legacy_platform",
342    api_only: true,
343    sdk_version: "none",
344    system_modules: "art-module-lib-api-stubs-system-modules",
345
346    droiddoc_options: [
347        "--hide-annotation libcore.api.Hide ",
348        "--show-single-annotation libcore.api.CorePlatformApi ",
349        "--skip-annotation-instance-methods=false ",
350    ],
351
352    // Don't copy any output files to the dist.
353    no_dist: true,
354}
355
356java_sdk_library {
357    name: "stable.i18n.module.platform.api",
358    defaults: ["libcore_icu_bridge_defaults"],
359    srcs: [
360        ":android_icu4j_repackaged_src_files",
361    ],
362    visibility: [
363        "//libcore:__subpackages__",
364        "//packages/modules/RuntimeI18n/apex",
365        // Visibility for prebuilt i18n-module-sdk from the prebuilt of
366        // this module.
367        // TODO(b/155921753): Restrict this when prebuilts are in their proper
368        // locations.
369        "//prebuilts:__subpackages__",
370    ],
371    hostdex: true,
372    api_dir: "api/stable_platform",
373    api_only: true,
374    sdk_version: "none",
375    system_modules: "art-module-lib-api-stubs-system-modules",
376
377    droiddoc_options: [
378        "--hide-annotation libcore.api.Hide ",
379        "--show-single-annotation libcore.api.CorePlatformApi\\(status=libcore.api.CorePlatformApi.Status.STABLE\\)",
380        "--skip-annotation-instance-methods=false ",
381    ],
382
383    // Don't copy any output files to the dist.
384    no_dist: true,
385}
386
387//==========================================================
388// build repackaged ICU tests
389//
390// Target builds against core-libart and core-oj so that it can access all the
391// repackaged android.icu classes and methods and not just the ones available
392// through the Android API.
393//==========================================================
394java_test {
395    name: "android-icu4j-tests",
396    visibility: [
397        "//cts/tests/tests/icu",
398    ],
399
400    srcs: [
401        "src/main/tests/**/*.java",
402        "testing/src/**/*.java",
403    ],
404    java_resource_dirs: [
405        "src/main/tests",
406        "testing/src",
407    ],
408    libs: [
409        "core-icu4j",
410    ],
411    static_libs: [
412        "junit",
413        "junit-params",
414        "tzdata-testing",
415    ],
416
417    patch_module: "java.base",
418    sdk_version: "none",
419    system_modules: "art-module-intra-core-api-stubs-system-modules",
420}
421