Add `android_lint_runner_opts` attribute to `java_toolchain` Allows `java_toolchain` configurations to pass top-level arguments (including `$(location ...)` expansions against `android_lint_data`) directly to the Android Lint runner before `--lintopts`. PiperOrigin-RevId: 1020220044 Change-Id: If70c8a4fd72341d655943ebce5884e27953651e3
diff --git a/java/common/rules/android_lint.bzl b/java/common/rules/android_lint.bzl index d07bb5e..16cf7fe 100644 --- a/java/common/rules/android_lint.bzl +++ b/java/common/rules/android_lint.bzl
@@ -115,6 +115,7 @@ args.add_all("--lint_rules", compilation_info.plugins.processor_jars) args.add("--target_label", ctx.label) args.add("--library", str(is_library).lower()) + args.add_all(linter.runner_opts) javac_opts = compilation_info.javac_options if javac_opts:
diff --git a/java/common/rules/java_toolchain.bzl b/java/common/rules/java_toolchain.bzl index d2e4876..dc62089 100644 --- a/java/common/rules/java_toolchain.bzl +++ b/java/common/rules/java_toolchain.bzl
@@ -180,6 +180,7 @@ data = depset(ctx.files.android_lint_data), jvm_opts = depset([ctx.expand_location(opt, ctx.attr.android_lint_tools) for opt in ctx.attr.android_lint_jvm_opts]), lint_opts = [ctx.expand_location(opt, ctx.attr.android_lint_data) for opt in ctx.attr.android_lint_opts], + runner_opts = [ctx.expand_location(opt, ctx.attr.android_lint_data) for opt in ctx.attr.android_lint_runner_opts], package_config = [dep[JavaPackageConfigurationInfo] for dep in ctx.attr.android_lint_package_configuration], ) @@ -266,7 +267,7 @@ cfg = "exec", allow_files = True, doc = """ -Labels of files available for label-expansion in android_lint_opts. +Labels of files available for label-expansion in android_lint_opts and android_lint_runner_opts. """, ), "android_lint_tools": attr.label_list( @@ -282,6 +283,12 @@ The list of Android Lint arguments. """, ), + "android_lint_runner_opts": attr.string_list( + default = [], + doc = """ +The list of Android Lint runner arguments. + """, + ), "android_lint_jvm_opts": attr.string_list( default = [], doc = """