Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: "Running tests //..."
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
run: bazel test //... --strategy=AndroidLint=${{ matrix.strategy }}
run: bazel test //... --strategy=AndroidLint=${{ matrix.strategy }} --strategy=AndroidLintAnalyze=${{ matrix.strategy }}
integration-tests:
strategy:
matrix:
Expand All @@ -58,4 +58,4 @@ jobs:
env:
USE_BAZEL_VERSION: ${{ matrix.bazel_version }}
working-directory: ${{ matrix.directory }}
run: bazel test //... --strategy=AndroidLint=${{ matrix.strategy }}
run: bazel test //... --strategy=AndroidLint=${{ matrix.strategy }} --strategy=AndroidLintAnalyze=${{ matrix.strategy }}
15 changes: 15 additions & 0 deletions rules/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ bzl_library(
visibility = ["//visibility:public"],
deps = [
":collect_aar_outputs_aspect",
":lint_analysis_aspect",
],
)

Expand Down Expand Up @@ -106,6 +107,20 @@ bzl_library(
visibility = ["//visibility:public"],
)

bzl_library(
name = "lint_analysis_aspect",
srcs = ["lint_analysis_aspect.bzl"],
visibility = ["//visibility:public"],
deps = [
":collect_aar_outputs_aspect",
":providers",
":utils",
"@rules_android//providers:providers_bzl",
"@rules_java//java:rules",
"@rules_java//java/private:proto_support",
],
)

filegroup(
name = "all_files",
srcs = glob(["*"]),
Expand Down
6 changes: 5 additions & 1 deletion rules/attrs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ load(
":collect_aar_outputs_aspect.bzl",
_collect_aar_outputs_aspect = "collect_aar_outputs_aspect",
)
load(
":lint_analysis_aspect.bzl",
_lint_analysis_aspect = "lint_analysis_aspect",
)

ATTRS = dict(
_lint_wrapper = attr.label(
Expand Down Expand Up @@ -38,7 +42,7 @@ ATTRS = dict(
mandatory = False,
allow_empty = True,
default = [],
aspects = [_collect_aar_outputs_aspect],
aspects = [_collect_aar_outputs_aspect, _lint_analysis_aspect],
doc = "Dependencies that should be on the classpath during execution.",
),
android_lint_config = attr.label(
Expand Down
13 changes: 8 additions & 5 deletions rules/collect_aar_outputs_aspect.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

load("@rules_android//providers:providers.bzl", "AndroidLibraryAarInfo")

ANDROID_LINT_DEPENDENCY_ATTRS = ["deps", "runtime_deps", "exports", "associates"]

AndroidLintAARInfo = provider(
"A provider to collect all aars from transitive dependencies",
fields = {
Expand All @@ -20,13 +22,13 @@ AndroidLintAARNodeInfo = provider(
)

def _collect_aar_outputs_aspect(tgt, ctx):
deps = getattr(ctx.rule.attr, "deps", [])
exports = getattr(ctx.rule.attr, "exports", [])
associates = getattr(ctx.rule.attr, "associates", [])
deps = []
for attr in ANDROID_LINT_DEPENDENCY_ATTRS:
deps.extend(getattr(ctx.rule.attr, attr, []))

# Collect the transitive aar artifacts for the given dependencies
transitive_aar_depsets = []
for dep in deps + exports + associates:
for dep in deps:
if AndroidLintAARInfo in dep:
transitive_aar_depsets.append(dep[AndroidLintAARInfo].transitive_aar_artifacts)

Expand Down Expand Up @@ -73,5 +75,6 @@ def _collect_aar_outputs_aspect(tgt, ctx):

collect_aar_outputs_aspect = aspect(
implementation = _collect_aar_outputs_aspect,
attr_aspects = ["aar", "deps", "exports", "associates"],
attr_aspects = ["aar"] + ANDROID_LINT_DEPENDENCY_ATTRS,
provides = [AndroidLintAARInfo],
)
Loading