• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2020 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#   Dagger Lint Rules
17
18load("//:build_defs.bzl", "POM_VERSION")
19load("//tools:maven.bzl", "gen_maven_artifact")
20load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
21
22package(default_visibility = ["//:src"])
23
24kt_jvm_library(
25    name = "lint-artifact-lib",
26    srcs = glob(["*.kt"]),
27    tags = ["maven_coordinates=com.google.dagger:dagger-lint:" + POM_VERSION],
28    deps = [
29        "@google_bazel_common//third_party/java/auto:service",
30        "@maven//:com_android_tools_external_com_intellij_intellij_core",
31        "@maven//:com_android_tools_external_com_intellij_kotlin_compiler",
32        "@maven//:com_android_tools_external_org_jetbrains_uast",
33        "@maven//:com_android_tools_lint_lint",
34        "@maven//:com_android_tools_lint_lint_api",
35    ],
36)
37
38# Current `kt_jvm_library` does not output source jars and gen_maven_artifact expects one.
39# See: https://github.com/bazelbuild/rules_kotlin/issues/324
40genrule(
41    name = "dagger-lint-sources",
42    srcs = glob(["*.kt"]),
43    outs = ["liblint-artifact-lib-src.jar"],
44    cmd = """
45        TEMP="$$(mktemp -d)"
46        for file in $(SRCS); do
47            filename="$$TEMP/$${file#java/}"
48            mkdir -p `dirname $$filename` && cp $$file $$filename
49        done
50        jar cf $@ -C $$TEMP .
51    """,
52)
53
54gen_maven_artifact(
55    name = "lint-artifact",
56    artifact_coordinates = "com.google.dagger:dagger-lint:" + POM_VERSION,
57    artifact_name = "Dagger Lint Rules",
58    artifact_target = ":lint-artifact-lib",
59    artifact_target_maven_deps = [
60        "com.android.tools.external.com-intellij:intellij-core",
61        "com.android.tools.external.com-intellij:kotlin-compiler",
62        "com.android.tools.external.org-jetbrains:uast",
63        "com.android.tools.lint:lint",
64        "com.android.tools.lint:lint-api",
65    ],
66    pom_name = "lint-pom",
67)
68
69# An empty android artifact to distribute and share the Dagger lint rules for
70# the Android sub-projects.
71android_library(
72    name = "lint-android-artifact-lib",
73    tags = ["maven_coordinates=com.google.dagger:dagger-lint-aar:" + POM_VERSION],
74)
75
76gen_maven_artifact(
77    name = "lint-android-artifact",
78    artifact_coordinates = "com.google.dagger:dagger-lint-aar:" + POM_VERSION,
79    artifact_name = "Dagger Lint Rules AAR Distribution",
80    artifact_target = ":lint-android-artifact-lib",
81    lint_deps = [":lint-artifact-lib"],
82    manifest = "AndroidManifest.xml",
83    packaging = "aar",
84    pom_name = "lint-android-pom",
85)
86