Skip to content

Commit

Permalink
Don't create a subpath for extracted_srcjar (#767)
Browse files Browse the repository at this point in the history
This avoids an issue where we declare output to be a prefix of the rule
  • Loading branch information
antonsviridov-src authored Dec 9, 2024
1 parent c3ab8ea commit 62df280
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 9 additions & 0 deletions examples/bazel-example/src/main/java/srcjar_example/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ java_library(
":generated-srcjar",
],
)

java_test(
name = "testing_test",
srcs = [
"Foo.java",
":generated-srcjar",
],
test_class = "Foo",
)
12 changes: 6 additions & 6 deletions scip-java/src/main/resources/scip-java/scip_java.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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],
Expand All @@ -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"):
Expand All @@ -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 != "":
Expand Down

0 comments on commit 62df280

Please sign in to comment.