summaryrefslogtreecommitdiff
path: root/icu4j/Android.bp
blob: 8e04598d75d13c9935784eb1b8572b95c7a6394b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
//
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package {
    default_visibility: ["//visibility:private"],
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "external_icu_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    //   SPDX-license-identifier-BSD
    //   SPDX-license-identifier-ICU
    //   SPDX-license-identifier-MIT
    //   SPDX-license-identifier-Unicode-DFS
    //   legacy_unencumbered
    default_applicable_licenses: ["external_icu_license"],
}

java_defaults {
    name: "icu4j-defaults",
    host_supported: true,
    hostdex: true,

    // Use the same Java language version in the Android build configuration as used
    // in main/shared/build/common.properties for the ICU4J build configuration.
    java_version: "1.8",
    lint: {
        warning_checks: ["SuspiciousIndentation"],
    },
    errorprone: {
        javacflags: [
            "-Xep:EmptyTopLevelDeclaration:WARN",
            "-Xep:BoxedPrimitiveEquality:WARN",
            "-Xep:EqualsHashCode:WARN",
            "-Xep:ComparableType:WARN",
            "-Xep:SelfAssignment:WARN",
            "-Xep:ReturnValueIgnored:WARN",
            "-Xep:SelfComparison:WARN",
            "-Xep:SelfEquals:WARN",
            "-Xep:MisusedDayOfYear:WARN",
            "-Xep:MisusedWeekYear:WARN",
            "-Xep:IdentityBinaryExpression:WARN",
        ],
    },
    sdk_version: "core_current",
}

java_library {
    name: "icu4j",
    visibility: [
        "//bootable/recovery/tools/image_generator",
        "//external/icu/tools/srcgen",
        "//external/jimfs/jimfs",
        "//external/robolectric-shadows/robolectric",
        "//external/robolectric-shadows/shadows/framework",
        "//external/robolectric/robolectric",
        "//external/robolectric/shadows/framework",
        "//system/timezone/input_tools/android/telephonylookup_generator",
        "//system/timezone/input_tools/android/tzlookup_generator",
    ],
    defaults: ["icu4j-defaults"],
    libs: [
        // Need the following shared libraries for @FlaggedApi. These libraries are only needed
        // compile-time, not runtime, and it shouldn't need to be statically linked.
        // framework-api-annotations are not static libs to avoid exposing the definition of
        // framework's annotations from ICU (wrong place) instead of framework (correct place).
        "framework-annotations-lib",
        "icu_aconfig_flags_lib",
    ],

    srcs: ["main/classes/**/*.java"],
    java_resource_dirs: ["main/classes/*/src"],

    // User-supplied locale service providers (using the java.text.spi or
    // java.util.spi mechanisms) are not supported in Android:
    //
    // http://developer.android.com/reference/java/util/Locale.html
    exclude_srcs: ["main/classes/localespi/**/*.java"],
    exclude_java_resource_dirs: ["main/classes/localespi/src"],

    static_libs: [
        "icu4j-icudata",
        "icu4j-icutzdata",
    ],
}

// Small static library used by TwilightService in the system server and WallpaperPicker2 app. To
// avoid @CorePlaformApi, the system server doesn't use CalendarAstronomer in android.icu.
// Don't link this in boot classpath or Zygote to avoid class collision with the
// com.ibm.icu.impl.CalendarAstronomer in the app classloader.
java_library_static {
    name: "icu4j_calendar_astronomer",
    host_supported: false,
    sdk_version: "core_current",
    srcs: ["main/classes/core/src/com/ibm/icu/impl/CalendarAstronomer.java"],
    visibility: [
        "//frameworks/base/services/core",
        "//packages/apps/WallpaperPicker2",
    ],
}

java_test {
    name: "icu4j-tests",
    defaults: ["icu4j-defaults"],

    srcs: [
        "main/tests/**/*.java",
        "tools/misc/src/com/ibm/icu/dev/tool/locale/*.java",
    ],
    java_resource_dirs: ["main/tests/*/src"],

    exclude_srcs: ["main/tests/localespi/**/*.java"],
    exclude_java_resource_dirs: ["main/tests/localespi/src"],

    static_libs: [
        "icu4j",
        "icu4j-testdata",
        "junit-params",
    ],

    errorprone: {
        javacflags: [
            "-Xep:EqualsNull:WARN",
            "-Xep:ArrayToString:WARN",
        ],
    },

    test_options: {
        unit_test: false,
    },
}

java_import {
    name: "icu4j-icudata",
    host_supported: true,
    jars: ["main/shared/data/icudata.jar"],
}

java_import {
    name: "icu4j-icutzdata",
    host_supported: true,
    jars: ["main/shared/data/icutzdata.jar"],
}

java_import {
    name: "icu4j-testdata",
    host_supported: true,
    jars: ["main/shared/data/testdata.jar"],
}

// LayoutLib (frameworks/layoutlib) and robolectric need JarJar'd versions of
// the icudata and icutzdata, so add rules for it.
java_library {
    name: "icu4j-icudata-jarjar",
    visibility: [
        "//external/robolectric-shadows",
        "//external/robolectric",
        "//frameworks/layoutlib",
    ],
    defaults: ["icu4j-defaults"],
    static_libs: ["icu4j-icudata"],
    jarjar_rules: "liblayout-jarjar-rules.txt",
}

java_library {
    name: "icu4j-icutzdata-jarjar",
    visibility: [
        "//external/robolectric-shadows",
        "//external/robolectric",
        "//frameworks/layoutlib",
    ],
    defaults: ["icu4j-defaults"],
    static_libs: ["icu4j-icutzdata"],
    jarjar_rules: "liblayout-jarjar-rules.txt",
}

// Compatibility alias until references to icu4j-host are removed
//
// When converting .mk files to .bp files do not change the visibility of this
// module, instead replace usages of this with icu4j
java_library_host {
    name: "icu4j-host",
    static_libs: ["icu4j"],
}

// Rules to generate android_icu4j files during build time
// The following rules are used in the downstream branches master-icu-dev only,
// but NOT used in AOSP.
generate_script_srcs = [
    "main/**/*",
    "samples/**/*",
]
generate_script_tools = [
    "android_icu4j_srcgen_binary",
    "soong_zip",
]
generate_script_tool_files = [
    ":generate_android_icu4j_script",
]
// ANDROID_BUILD_TOP is needed to be set for generate_android_icu4j.sh
generate_script_common_cmd = "export ANDROID_BUILD_TOP=$$(pwd) && " +
    "$(location :generate_android_icu4j_script) " +
    "--no-doc-patch " +
    "--gen $(genDir) " +
    "--srcgen-tool $(location android_icu4j_srcgen_binary)"

genrule {
    name: "generated_android_icu4j_src_files",
    enabled: false, // http://b/117312606
    srcs: generate_script_srcs,
    tools: generate_script_tools,
    tool_files: generate_script_tool_files,
    out: ["generated_android_icu4j.srcjar"],
    cmd: generate_script_common_cmd +
        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/java " +
        "-D $(genDir)/android_icu4j/src/main/java",
}

java_genrule {
    name: "generated_android_icu4j_resources",
    enabled: false, // http://b/117312606
    host_supported: true,
    srcs: generate_script_srcs,
    tools: generate_script_tools,
    tool_files: generate_script_tool_files,
    out: ["generated_android_icu4j_resources.jar"],
    cmd: generate_script_common_cmd +
        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/resources " +
        "-D $(genDir)/android_icu4j/resources",
}

genrule {
    name: "generated_android_icu4j_test_files",
    enabled: false, // http://b/117312606
    srcs: generate_script_srcs,
    tools: generate_script_tools,
    tool_files: generate_script_tool_files,
    out: ["generated_android_icu4j_test.srcjar"],
    cmd: generate_script_common_cmd +
        "&& find $(genDir)/android_icu4j/src/main/tests -type f -not -name \"*.java\" -exec rm {} \\; " +
        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
        "-D $(genDir)/android_icu4j/src/main/tests",
}

java_genrule {
    name: "generated_android_icu4j_test_resources",
    enabled: false, // http://b/117312606
    host_supported: true,
    srcs: generate_script_srcs,
    tools: generate_script_tools,
    tool_files: generate_script_tool_files,
    out: ["generated_android_icu4j_test_resources.jar"],
    cmd: generate_script_common_cmd +
        "&& find $(genDir)/android_icu4j/src/main/tests -type f -name \"*.java\" -exec rm {} \\; " +
        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
        "-D $(genDir)/android_icu4j/src/main/tests",
}