blob: cd42259e44a1f7710c2b68b4df78fb4ecedb5111 [file] [log] [blame]
Colin Cross6e18e292018-09-11 16:41:13 -07001//
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
17java_defaults {
18 name: "icu4j-defaults",
19 host_supported: true,
20 hostdex: true,
21
22 // Use the same Java language version in the Android build configuration as used
23 // in main/shared/build/common.properties for the ICU4J build configuration.
24 java_version: "1.6",
25
26 // Suppress warnings about Java 1.6 being obsolete.
27 javacflags: ["-Xlint:-options"],
28}
29
30java_library {
31 name: "icu4j",
32 defaults: ["icu4j-defaults"],
33
34 srcs: ["main/classes/**/*.java"],
35 java_resource_dirs: ["main/classes/*/src"],
36
37 // User-supplied locale service providers (using the java.text.spi or
38 // java.util.spi mechanisms) are not supported in Android:
39 //
40 // http://developer.android.com/reference/java/util/Locale.html
41 exclude_srcs: ["main/classes/localespi/**/*.java"],
42 exclude_java_resource_dirs: ["main/classes/localespi/src"],
43
44 target: {
45 android: {
46 exclude_java_resources: ["main/classes/core/src/com/ibm/icu/ICUConfig.properties"],
47 java_resources: [":icu4j-config"],
48 },
49 host: {
50 static_libs: [
51 "icu4j-icudata",
52 "icu4j-icutzdata",
53 ],
54 },
55 },
56}
57
58// Insert path to the ICU4C data files in the Android device file system:
59genrule {
60 name: "icu4j-config",
61 srcs: ["main/classes/core/src/com/ibm/icu/ICUConfig.properties"],
62 out: ["com/ibm/icu/ICUConfig.properties"],
63 cmd: "sed -e'/\\.dataPath =/s|$$| /system/usr/icu|' $(in) > $(out)",
64}
65
66java_test {
67 name: "icu4j-tests",
68 defaults: ["icu4j-defaults"],
69
70 srcs: ["main/tests/**/*.java"],
71 java_resource_dirs: ["main/tests/*/src"],
72
73 exclude_srcs: ["main/tests/localespi/**/*.java"],
74 exclude_java_resource_dirs: ["main/tests/localespi/src"],
75
76 static_libs: [
77 "icu4j",
78 "icu4j-testdata",
79 "junit-params",
80 ],
81}
82
83java_import {
84 name: "icu4j-icudata",
85 host_supported: true,
86 jars: ["main/shared/data/icudata.jar"],
87}
88
89java_import {
90 name: "icu4j-icutzdata",
91 host_supported: true,
92 jars: ["main/shared/data/icutzdata.jar"],
93}
94
95java_import {
96 name: "icu4j-testdata",
97 host_supported: true,
98 jars: ["main/shared/data/testdata.jar"],
99}
100
101// LayoutLib (frameworks/layoutlib) needs JarJar'd versions of the
102// icudata and icutzdata, so add rules for it.
103java_library_static {
104 name: "icu4j-icudata-jarjar",
105 defaults: ["icu4j-defaults"],
106 static_libs: ["icu4j-icudata"],
107 jarjar_rules: "liblayout-jarjar-rules.txt",
108}
109
110java_library_static {
111 name: "icu4j-icutzdata-jarjar",
112 defaults: ["icu4j-defaults"],
113 static_libs: ["icu4j-icutzdata"],
114 jarjar_rules: "liblayout-jarjar-rules.txt",
115}
116
117// Compatibility alias until references to icu4j-host are removed
118java_library_host {
119 name: "icu4j-host",
120 static_libs: ["icu4j"],
121}
Victor Change9935982018-09-21 14:55:40 +0100122
123// Rules to generate android_icu4j files during build time
124// The following rules are used in the downstream branches master-icu-dev only,
125// but NOT used in AOSP.
126generate_script_srcs = [
127 "main/**/*",
128 "samples/**/*",
129]
130generate_script_tools = [
131 "android_icu4j_srcgen_binary",
132 "soong_zip",
133]
134generate_script_tool_files = [
135 ":generate_android_icu4j_script",
136]
137// ANDROID_BUILD_TOP is needed to be set for generate_android_icu4j.sh
138generate_script_common_cmd = "export ANDROID_BUILD_TOP=$$(pwd) && " +
Colin Crossd4025ce2018-10-05 12:35:15 -0700139 "$(location :generate_android_icu4j_script) " +
Victor Change9935982018-09-21 14:55:40 +0100140 "--no-doc-patch " +
141 "--gen $(genDir) " +
142 "--srcgen-tool $(location android_icu4j_srcgen_binary)"
143
144genrule {
145 name: "generated_android_icu4j_src_files",
146 srcs: generate_script_srcs,
147 tools: generate_script_tools,
148 tool_files: generate_script_tool_files,
149 out: ["generated_android_icu4j.srcjar"],
150 cmd: generate_script_common_cmd +
151 "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/java " +
152 "-D $(genDir)/android_icu4j/src/main/java",
153}
154
155java_genrule {
156 name: "generated_android_icu4j_resources",
157 host_supported: true,
158 srcs: generate_script_srcs,
159 tools: generate_script_tools,
160 tool_files: generate_script_tool_files,
161 out: ["generated_android_icu4j_resources.jar"],
162 cmd: generate_script_common_cmd +
163 "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/resources " +
164 "-D $(genDir)/android_icu4j/resources",
165}
166
167genrule {
168 name: "generated_android_icu4j_test_files",
169 srcs: generate_script_srcs,
170 tools: generate_script_tools,
171 tool_files: generate_script_tool_files,
172 out: ["generated_android_icu4j_test.srcjar"],
173 cmd: generate_script_common_cmd +
174 "&& find $(genDir)/android_icu4j/src/main/tests -type f -not -name \"*.java\" -exec rm {} \\; " +
175 "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
176 "-D $(genDir)/android_icu4j/src/main/tests",
177}
178
179java_genrule {
180 name: "generated_android_icu4j_test_resources",
181 host_supported: true,
182 srcs: generate_script_srcs,
183 tools: generate_script_tools,
184 tool_files: generate_script_tool_files,
185 out: ["generated_android_icu4j_test_resources.jar"],
186 cmd: generate_script_common_cmd +
187 "&& find $(genDir)/android_icu4j/src/main/tests -type f -name \"*.java\" -exec rm {} \\; " +
188 "&& $(location soong_zip) -o $(out) -C $(genDir)/android_icu4j/src/main/tests " +
189 "-D $(genDir)/android_icu4j/src/main/tests",
190}