From 62df280959628882b4faf8bba27a492c45ac430f Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Mon, 9 Dec 2024 16:09:02 +0000 Subject: [PATCH] Don't create a subpath for extracted_srcjar (#767) This avoids an issue where we declare output to be a prefix of the rule --- .../bazel-example/src/main/java/srcjar_example/BUILD | 9 +++++++++ scip-java/src/main/resources/scip-java/scip_java.bzl | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/bazel-example/src/main/java/srcjar_example/BUILD b/examples/bazel-example/src/main/java/srcjar_example/BUILD index dce48b36..a5afe5fe 100644 --- a/examples/bazel-example/src/main/java/srcjar_example/BUILD +++ b/examples/bazel-example/src/main/java/srcjar_example/BUILD @@ -26,3 +26,12 @@ java_library( ":generated-srcjar", ], ) + +java_test( + name = "testing_test", + srcs = [ + "Foo.java", + ":generated-srcjar", + ], + test_class = "Foo", +) diff --git a/scip-java/src/main/resources/scip-java/scip_java.bzl b/scip-java/src/main/resources/scip-java/scip_java.bzl index 1525597f..93337381 100644 --- a/scip-java/src/main/resources/scip-java/scip_java.bzl +++ b/scip-java/src/main/resources/scip-java/scip_java.bzl @@ -9,7 +9,7 @@ different contents. This aspect is needed for scip-java to inspect the structure of the Bazel build and register actions to index all java_library/java_test/java_binary targets. The result of running this aspect is that your bazel-bin/ directory will contain -many *.scip (https://github.com/sourcegraph/scip) and +many *.scip (https://github.com/sourcegraph/scip) and *.semanticdb (https://scalameta.org/docs/semanticdb/specification.html) files. These files encode information about which symbols are referenced from which locations in your source code. @@ -66,13 +66,13 @@ def _scip_java(target, ctx): if len(source_files) == 0: return None - + output_dir = [] for source_jar in source_jars: - dir = ctx.actions.declare_directory(ctx.label.name + "/extracted_srcjar/" + source_jar.short_path) + dir = ctx.actions.declare_directory(ctx.label.name + ".extracted_srcjar/" + source_jar.short_path) output_dir.append(dir) - + ctx.actions.run_shell( inputs = javac_action.inputs, outputs = [dir], @@ -99,7 +99,7 @@ def _scip_java(target, ctx): launcher_javac_flags = [] compiler_javac_flags = [] - + # In different versions of bazel javac options are either a nested set or a depset or a list... javac_options = [] if hasattr(compilation, "javac_options_list"): @@ -108,7 +108,7 @@ def _scip_java(target, ctx): javac_options = compilation.javac_options for value in javac_options: - # NOTE(Anton): for some bizarre reason I see empty string starting the list of + # NOTE(Anton): for some bizarre reason I see empty string starting the list of # javac options - which then gets propagated into the JSON config, and ends up # crashing the actual javac invokation. if value != "":