Skip to content

Commit

Permalink
Fix lint aspect not linting non databinding targets (#146)
Browse files Browse the repository at this point in the history
Fixes #146
  • Loading branch information
arunkumar9t2 committed Feb 29, 2024
1 parent df3f86b commit 4eabb7f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rules/android/android_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load("@grab_bazel_common//tools/res_value:res_value.bzl", "res_value")
load("@grab_bazel_common//tools/kotlin:android.bzl", "kt_android_library")
load("@grab_bazel_common//rules/android/databinding:databinding.bzl", "kt_db_android_library")
load(":resources.bzl", "build_resources")
load("@grab_bazel_common//rules/android/lint:defs.bzl", "lint", "lint_sources")
load("@grab_bazel_common//rules/android/lint:defs.bzl", "LINT_ENABLED", "lint", "lint_sources")

def android_library(
name,
Expand Down Expand Up @@ -92,7 +92,7 @@ def android_library(
assets = attrs.get("assets", default = None),
assets_dir = attrs.get("assets_dir", default = None),
visibility = attrs.get("visibility", default = None),
tags = attrs.get("tags", default = []) + ["lint_enabled"],
tags = attrs.get("tags", default = []) + [LINT_ENABLED],
deps = android_library_deps,
plugins = attrs.get("plugins", default = None),
)
Expand Down
3 changes: 2 additions & 1 deletion rules/android/lint/lint_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,11 @@ def _lint_aspect_impl(target, ctx):
else:
# Current target info
rule_kind = ctx.rule.kind
kotlin = rule_kind == "kt_jvm_library"
android = rule_kind == "android_library" or rule_kind == "android_binary"
library = rule_kind != "android_binary"

enabled = LINT_ENABLED in ctx.rule.attr.tags and android # Currently only android targets
enabled = LINT_ENABLED in ctx.rule.attr.tags and (android or kotlin)

# Dependency info
transitive_lint_node_infos = _transitive_lint_node_infos(ctx)
Expand Down
3 changes: 2 additions & 1 deletion tools/databinding/databinding.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load(":databinding_stubs.bzl", "databinding_stubs")
load("@grab_bazel_common//rules/android/lint:defs.bzl", "LINT_ENABLED")
# load(":databinding_aar.bzl", "databinding_aar")

# TODO(arun) Replace with configurable maven targets
Expand Down Expand Up @@ -119,7 +120,7 @@ def kt_db_android_library(
"@grab_bazel_common//tools/binding-adapter-bridge:binding-adapter-bridge",
"@grab_bazel_common//tools/android:android_sdk",
],
tags = tags,
tags = [tag for tag in tags if tag != LINT_ENABLED],
)
kotlin_targets.append(kotlin_target)

Expand Down

0 comments on commit 4eabb7f

Please sign in to comment.