# Copyright 2019 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/rules.gni")
if (enable_java_templates) {
android_system_java_prebuilt("public_framework_system_java") {
jar_path = "//third_party/android_system_sdk/cipd/android_system.jar"
}
android_system_java_prebuilt("android_sdk_java") {
jar_path = android_sdk_jar
}
template("android_sdk_optional_library") {
forward_variables_from(invoker, [ "testonly" ])
_manifest_path = "$target_gen_dir/$target_name/AndroidManifest.xml"
# String replace to prevent dep from being treated as a java library.
_manifest_target = string_replace(target_name, "_java", "_J") + "__manifest"
jinja_template(_manifest_target) {
input = "//third_party/android_sdk/AndroidManifest.xml.jinja2"
output = _manifest_path
_library_name = invoker.library_name
if (defined(invoker.runtime_library_name)) {
_library_name = invoker.runtime_library_name
}
variables = [
"library_name=$_library_name",
"required=${invoker.required}",
]
}
java_group(target_name) {
forward_variables_from(invoker, [ "jar_deps" ])
deps = [ ":$_manifest_target" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
# Makes the .jar appear in the classpath for compile steps.
if (defined(invoker.input_jars_paths)) {
input_jars_paths = invoker.input_jars_paths
} else {
input_jars_paths =
[ "${android_sdk}/optional/${invoker.library_name}.jar" ]
}
# Adds the <uses-library> tag to the manifest.
mergeable_android_manifests = [ _manifest_path ]
}
}
android_sdk_optional_library("android_test_mock_java") {
testonly = true
required = true
library_name = "android.test.mock"
runtime_library_name = "android.test.runner"
}
android_sdk_optional_library("android_car_java") {
library_name = "android.car"
required = false
}
if (!limit_android_deps) {
android_sdk_optional_library("android_window_extensions_java") {
library_name = "androidx.window.extensions"
required = false
jar_deps = [ "//third_party/android_sdk/window_extensions:androidx_window_extensions" ]
deps =
[ "//third_party/androidx:androidx_annotation_annotation_jvm_java" ]
input_jars_paths = [ "$root_build_dir/obj/third_party/android_sdk/window_extensions/androidx_window_extensions_java.javac.jar" ]
}
}
}