1# Copyright (C) 2017 The Dagger Authors.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Description:
16#   Public Dagger API for Android
17
18load(
19    "//:build_defs.bzl",
20    "DOCLINT_HTML_AND_SYNTAX",
21    "DOCLINT_REFERENCES",
22    "POM_VERSION",
23    "SOURCE_7_TARGET_7",
24)
25load("//tools:dejetify.bzl", "dejetified_library")
26load("//tools:maven.bzl", "pom_file")
27load("@google_bazel_common//tools/javadoc:javadoc.bzl", "javadoc_library")
28
29package(default_visibility = ["//:src"])
30
31# Work around b/70476182 which prevents Kythe from connecting :producers to the .java files it
32# contains.
33SRCS = glob([
34    "*.java",
35    "internal/*.java",
36])
37
38filegroup(
39    name = "android-srcs",
40    srcs = SRCS,
41)
42
43android_library(
44    name = "android",
45    srcs = SRCS,
46    javacopts = SOURCE_7_TARGET_7 + DOCLINT_HTML_AND_SYNTAX + DOCLINT_REFERENCES,
47    manifest = "AndroidManifest.xml",
48    plugins = [
49        "//java/dagger/android/internal/proguard:plugin",
50    ],
51    tags = ["maven_coordinates=com.google.dagger:dagger-android:" + POM_VERSION],
52    exports = [
53        "//java/dagger/lint:lint-android-artifact-lib",
54    ],
55    deps = [
56        "//:dagger_with_compiler",
57        "@google_bazel_common//third_party/java/auto:value",
58        "@google_bazel_common//third_party/java/error_prone:annotations",
59        "@maven//:androidx_annotation_annotation",
60    ],
61)
62
63pom_file(
64    name = "pom",
65    artifact_id = "dagger-android",
66    artifact_name = "Dagger Android",
67    packaging = "aar",
68    targets = [":android"],
69)
70
71# b/37741866 and https://github.com/google/dagger/issues/715
72pom_file(
73    name = "jarimpl-pom",
74    artifact_id = "dagger-android-jarimpl",
75    artifact_name = "Dagger Android",
76    targets = [":android"],
77)
78
79dejetified_library(
80    name = "dejetified-android",
81    input = ":android.aar",
82    output = "android-legacy.aar",
83)
84
85android_library(
86    name = "legacy-deps",
87    tags = ["maven_coordinates=com.google.dagger:dagger-android-legacy:" + POM_VERSION],
88    exports = [
89        "//:dagger_with_compiler",
90        "@google_bazel_common//third_party/java/auto:value",
91        "@google_bazel_common//third_party/java/error_prone:annotations",
92        "@maven//:com_android_support_support_annotations",
93    ],
94)
95
96pom_file(
97    name = "legacy-pom",
98    artifact_id = "dagger-android-legacy",
99    artifact_name = "Dagger Android Legacy",
100    packaging = "aar",
101    targets = [":legacy-deps"],
102)
103
104javadoc_library(
105    name = "android-javadoc",
106    srcs = [":android-srcs"],
107    android_api_level = 30,
108    exclude_packages = ["dagger.android.internal"],
109    root_packages = ["dagger.android"],
110    deps = [":android"],
111)
112