xref: /aosp_15_r20/external/icu/icu4j/Android.bp (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1//
2// Copyright (C) 2014 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
33java_defaults {
34    name: "icu4j-defaults",
35    host_supported: true,
36    hostdex: true,
37
38    // Use the same Java language version in the Android build configuration as used
39    // in main/shared/build/common.properties for the ICU4J build configuration.
40    java_version: "1.8",
41    lint: {
42        warning_checks: ["SuspiciousIndentation"],
43    },
44    errorprone: {
45        javacflags: [
46            "-Xep:EmptyTopLevelDeclaration:WARN",
47            "-Xep:BoxedPrimitiveEquality:WARN",
48            "-Xep:EqualsHashCode:WARN",
49            "-Xep:ComparableType:WARN",
50            "-Xep:SelfAssignment:WARN",
51            "-Xep:ReturnValueIgnored:WARN",
52            "-Xep:SelfComparison:WARN",
53            "-Xep:SelfEquals:WARN",
54            "-Xep:MisusedDayOfYear:WARN",
55            "-Xep:MisusedWeekYear:WARN",
56            "-Xep:IdentityBinaryExpression:WARN",
57        ],
58    },
59    sdk_version: "current",
60}
61
62java_library {
63    name: "icu4j",
64    visibility: [
65        "//bootable/recovery/tools/image_generator",
66        "//external/icu/tools/srcgen",
67        "//external/jimfs/jimfs",
68        "//external/robolectric-shadows/robolectric",
69        "//external/robolectric-shadows/shadows/framework",
70        "//external/robolectric/robolectric",
71        "//external/robolectric/shadows/framework",
72        "//frameworks/base/ravenwood:__subpackages__",
73        "//system/timezone/input_tools/android/telephonylookup_generator",
74        "//system/timezone/input_tools/android/tzlookup_generator",
75    ],
76    defaults: ["icu4j-defaults"],
77    libs: [
78        // Need the following shared libraries for @FlaggedApi. These libraries are only needed
79        // compile-time, not runtime, and it shouldn't need to be statically linked.
80        // framework-api-annotations are not static libs to avoid exposing the definition of
81        // framework's annotations from ICU (wrong place) instead of framework (correct place).
82        "framework-annotations-lib",
83        "icu_aconfig_flags_lib",
84    ],
85
86    srcs: ["main/*/src/main/java/**/*.java"],
87    java_resource_dirs: ["main/*/src/main/resources"],
88
89    // User-supplied locale service providers (using the java.text.spi or
90    // java.util.spi mechanisms) are not supported in Android:
91    //
92    // http://developer.android.com/reference/java/util/Locale.html
93    exclude_srcs: ["main/localespi/src/main/java/**/*.java"],
94    exclude_java_resource_dirs: [
95        "main/localespi/src/main/resources",
96        // The actual resource files are included by linking icu4j-icudata and icu4j-icutzdata
97        // statically.
98        "main/*/src/main/resources/com/ibm/icu/impl/data/icudt*",
99    ],
100
101    static_libs: [
102        "icu4j-icudata",
103        "icu4j-icutzdata",
104    ],
105}
106
107java_test {
108    name: "icu4j-tests",
109    defaults: ["icu4j-defaults"],
110
111    srcs: [
112        "main/*/src/test/**/*.java",
113    ],
114    java_resource_dirs: ["main/*/src/test/resources"],
115
116    exclude_srcs: ["main/localespi/src/test/**/*.java"],
117    exclude_java_resource_dirs: ["main/localespi/src/test"],
118
119    static_libs: [
120        "gson",
121        "icu4j",
122        "icu4j-testdata",
123        "junit-params",
124    ],
125
126    errorprone: {
127        javacflags: [
128            "-Xep:EqualsNull:WARN",
129            "-Xep:ArrayToString:WARN",
130        ],
131    },
132
133    test_options: {
134        unit_test: false,
135    },
136}
137
138java_import {
139    name: "icu4j-icudata",
140    host_supported: true,
141    jars: ["main/shared/data/icudata.jar"],
142}
143
144java_import {
145    name: "icu4j-icutzdata",
146    host_supported: true,
147    jars: ["main/shared/data/icutzdata.jar"],
148}
149
150java_import {
151    name: "icu4j-testdata",
152    host_supported: true,
153    jars: ["main/shared/data/testdata.jar"],
154}
155
156// LayoutLib (frameworks/layoutlib), ravewnwood and robolectric need
157// JarJar'd versions of the icudata and icutzdata, so add rules for it.
158java_library {
159    name: "icu4j-icudata-jarjar",
160    visibility: [
161        "//external/robolectric-shadows",
162        "//external/robolectric",
163        "//frameworks/base/ravenwood:__subpackages__",
164        "//frameworks/layoutlib",
165    ],
166    defaults: ["icu4j-defaults"],
167    static_libs: ["icu4j-icudata"],
168    jarjar_rules: "liblayout-jarjar-rules.txt",
169}
170
171java_library {
172    name: "icu4j-icutzdata-jarjar",
173    visibility: [
174        "//external/robolectric-shadows",
175        "//external/robolectric",
176        "//frameworks/base/ravenwood:__subpackages__",
177        "//frameworks/layoutlib",
178    ],
179    defaults: ["icu4j-defaults"],
180    static_libs: ["icu4j-icutzdata"],
181    jarjar_rules: "liblayout-jarjar-rules.txt",
182}
183
184java_library_host {
185    name: "icu4j-host",
186    static_libs: ["icu4j"],
187    visibility: [
188        "//vendor:__subpackages__",
189    ],
190}
191