From 9d0af4ff0c7990476a29ff38051b6c25fff47609 Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Mon, 2 Dec 2024 11:26:38 -0800 Subject: [PATCH] Only run lint_tests on java_library not java_export Running list_tests on java_export will run afoul by trying to run spotbugs on included dependency that will clearly fail like `java_proto_library`. Instead, the lint tests should only operate on the sources that comprise the `java_library` the export target eventually creates. fixes #314 --- java/private/library.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/java/private/library.bzl b/java/private/library.bzl index ae493863..4606a2a0 100644 --- a/java/private/library.bzl +++ b/java/private/library.bzl @@ -71,7 +71,12 @@ def java_test(name, **kwargs): def java_export(name, maven_coordinates, pom_template = None, deploy_env = None, visibility = None, **kwargs): """Adds linting tests to `rules_jvm_external`'s `java_export`""" - create_lint_tests(name, **kwargs) + + # Only run the lint tests on the java_library target and not the java_export target which will include + # other sources within it. + # https://github.com/bazel-contrib/rules_jvm_external/blob/534e62d14655e01048b90ef89ab1acaf0caa7348/private/rules/java_export.bzl#L85C5-L85C31 + lib_name = "%s-lib" % name + create_lint_tests(lib_name, **kwargs) _java_export( name = name, maven_coordinates = maven_coordinates,