• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_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
32java_defaults {
33    name: "icu4j-defaults",
34    host_supported: true,
35    hostdex: true,
36
37    // Use the same Java language version in the Android build configuration as used
38    // in main/shared/build/common.properties for the ICU4J build configuration.
39    java_version: "1.7",
40}
41
42java_library {
43    name: "icu4j",
44    visibility: [
45        "//bootable/recovery/tools/image_generator",
46        "//external/icu/tools/srcgen",
47        "//external/jimfs/jimfs",
48        "//external/robolectric-shadows/robolectric",
49        "//external/robolectric-shadows/shadows/framework",
50        "//external/robolectric/robolectric",
51        "//external/robolectric/shadows/framework",
52        "//system/timezone/input_tools/android/telephonylookup_generator",
53        "//system/timezone/input_tools/android/tzlookup_generator",
54    ],
55    defaults: ["icu4j-defaults"],
56
57    srcs: ["main/classes/**/*.java"],
58    java_resource_dirs: ["main/classes/*/src"],
59
60    // User-supplied locale service providers (using the java.text.spi or
61    // java.util.spi mechanisms) are not supported in Android:
62    //
63    // http://developer.android.com/reference/java/util/Locale.html
64    exclude_srcs: ["main/classes/localespi/**/*.java"],
65    exclude_java_resource_dirs: ["main/classes/localespi/src"],
66
67    static_libs: [
68        "icu4j-icudata",
69        "icu4j-icutzdata",
70    ],
71}
72
73// Small static library used by TwilightService in the system server. To avoid @CorePlaformApi,
74// the system server doesn't use CalendarAstronomer in android.icu.
75// Don't link this in boot classpath or Zygote to avoid class collision with the
76// com.ibm.icu.impl.CalendarAstronomer in the app classloader.
77java_library_static {
78    name: "icu4j_calendar_astronomer",
79    host_supported: false,
80    srcs: ["main/classes/core/src/com/ibm/icu/impl/CalendarAstronomer.java"],
81    visibility: ["//frameworks/base/services/core"],
82}
83
84java_test {
85    name: "icu4j-tests",
86    defaults: ["icu4j-defaults"],
87
88    srcs: [
89        "main/tests/**/*.java",
90        "tools/misc/src/com/ibm/icu/dev/tool/locale/*.java",
91    ],
92    java_resource_dirs: ["main/tests/*/src"],
93
94    exclude_srcs: ["main/tests/localespi/**/*.java"],
95    exclude_java_resource_dirs: ["main/tests/localespi/src"],
96
97    static_libs: [
98        "icu4j",
99        "icu4j-testdata",
100        "junit-params",
101    ],
102
103    errorprone: {
104        javacflags: ["-Xep:EqualsNull:WARN"],
105    },
106}
107
108java_import {
109    name: "icu4j-icudata",
110    host_supported: true,
111    jars: ["main/shared/data/icudata.jar"],
112}
113
114java_import {
115    name: "icu4j-icutzdata",
116    host_supported: true,
117    jars: ["main/shared/data/icutzdata.jar"],
118}
119
120java_import {
121    name: "icu4j-testdata",
122    host_supported: true,
123    jars: ["main/shared/data/testdata.jar"],
124}
125
126// LayoutLib (frameworks/layoutlib) and robolectric need JarJar'd versions of
127// the icudata and icutzdata, so add rules for it.
128java_library {
129    name: "icu4j-icudata-jarjar",
130    visibility: [
131        "//external/robolectric-shadows",
132        "//external/robolectric",
133        "//frameworks/layoutlib",
134    ],
135    defaults: ["icu4j-defaults"],
136    static_libs: ["icu4j-icudata"],
137    jarjar_rules: "liblayout-jarjar-rules.txt",
138}
139
140java_library {
141    name: "icu4j-icutzdata-jarjar",
142    visibility: [
143        "//external/robolectric-shadows",
144        "//external/robolectric",
145        "//frameworks/layoutlib",
146    ],
147    defaults: ["icu4j-defaults"],
148    static_libs: ["icu4j-icutzdata"],
149    jarjar_rules: "liblayout-jarjar-rules.txt",
150}
151
152// Compatibility alias until references to icu4j-host are removed
153//
154// When converting .mk files to .bp files do not change the visibility of this
155// module, instead replace usages of this with icu4j
156java_library_host {
157    name: "icu4j-host",
158    static_libs: ["icu4j"],
159}
160
161// Rules to generate android_icu4j files during build time
162// The following rules are used in the downstream branches master-icu-dev only,
163// but NOT used in AOSP.
164generate_script_srcs = [
165    "main/**/*",
166    "samples/**/*",
167]
168generate_script_tools = [
169    "android_icu4j_srcgen_binary",
170    "soong_zip",
171]
172generate_script_tool_files = [
173    ":generate_android_icu4j_script",
174]
175// ANDROID_BUILD_TOP is needed to be set for generate_android_icu4j.sh
176generate_script_common_cmd = "export ANDROID_BUILD_TOP=$$(pwd) && " +
177    "$(location :generate_android_icu4j_script) " +
178    "--no-doc-patch " +
179    "--gen $(genDir) " +
180    "--srcgen-tool $(location android_icu4j_srcgen_binary)"
181
182genrule {
183    name: "generated_android_icu4j_src_files",
184    enabled: false, // http://b/117312606
185    srcs: generate_script_srcs,
186    tools: generate_script_tools,
187    tool_files: generate_script_tool_files,
188    out: ["generated_android_icu4j.srcjar"],
189    cmd: generate_script_common_cmd +
190        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/java " +
191        "-D $(genDir)/android_icu4j/src/main/java",
192}
193
194java_genrule {
195    name: "generated_android_icu4j_resources",
196    enabled: false, // http://b/117312606
197    host_supported: true,
198    srcs: generate_script_srcs,
199    tools: generate_script_tools,
200    tool_files: generate_script_tool_files,
201    out: ["generated_android_icu4j_resources.jar"],
202    cmd: generate_script_common_cmd +
203        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/resources " +
204        "-D $(genDir)/android_icu4j/resources",
205}
206
207genrule {
208    name: "generated_android_icu4j_test_files",
209    enabled: false, // http://b/117312606
210    srcs: generate_script_srcs,
211    tools: generate_script_tools,
212    tool_files: generate_script_tool_files,
213    out: ["generated_android_icu4j_test.srcjar"],
214    cmd: generate_script_common_cmd +
215        "&& find $(genDir)/android_icu4j/src/main/tests -type f -not -name \"*.java\" -exec rm {} \\; " +
216        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
217        "-D $(genDir)/android_icu4j/src/main/tests",
218}
219
220java_genrule {
221    name: "generated_android_icu4j_test_resources",
222    enabled: false, // http://b/117312606
223    host_supported: true,
224    srcs: generate_script_srcs,
225    tools: generate_script_tools,
226    tool_files: generate_script_tool_files,
227    out: ["generated_android_icu4j_test_resources.jar"],
228    cmd: generate_script_common_cmd +
229        "&& find $(genDir)/android_icu4j/src/main/tests -type f -name \"*.java\" -exec rm {} \\; " +
230        "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
231        "-D $(genDir)/android_icu4j/src/main/tests",
232}
233