Skip to content

Commit

Permalink
Add test coverage for --experimental_run_android_lint_on_java_rules
Browse files Browse the repository at this point in the history
… and implement it in Starlark

PiperOrigin-RevId: 440900201
  • Loading branch information
cushon authored and copybara-github committed Apr 11, 2022
1 parent 50533c2 commit 896c92f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public boolean addTestSupportToCompileTimeDeps() {
return addTestSupportToCompileTimeDeps;
}

@Override
public boolean runAndroidLint() {
return runAndroidLint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ public interface JavaConfigurationApi extends StarlarkValue {
doc = "The value of the --experimental_one_version_enforcement flag.")
String starlarkOneVersionEnforcementLevel();

@StarlarkMethod(
name = "run_android_lint",
structField = true,
doc = "The value of the --experimental_run_android_lint_on_java_rules flag.")
boolean runAndroidLint();

@StarlarkMethod(
name = "multi_release_deploy_jars",
structField = true,
Expand Down
3 changes: 2 additions & 1 deletion src/main/starlark/builtins_bzl/common/java/android_lint.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def android_lint_action(ctx, source_files, source_jars, compilation_info):
"""

# assuming that linting is enabled for all java rules i.e.
# --experimental_run_android_lint_on_java_rules=true and
# --experimental_limit_android_lint_to_android_constrained_java=false

# --experimental_run_android_lint_on_java_rules= is checked in java_common.bzl

if not (source_files or source_jars):
return None

Expand Down
5 changes: 1 addition & 4 deletions src/main/starlark/builtins_bzl/common/java/java_common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ def basic_java_library(
_direct_source_jars = java_info.source_jars,
)

# TODO(b/131760365): This is a hack, since the Starlark APIs don't have
# an explicit test for "host" or "tool" configuration.
if not (ctx.configuration == ctx.host_configuration or
ctx.bin_dir.path.find("-exec-") >= 0) and not neverlink:
if ctx.fragments.java.run_android_lint:
generated_source_jars = [
output.generated_source_jar
for output in java_info.java_outputs
Expand Down

0 comments on commit 896c92f

Please sign in to comment.