Handle .srcjar inputs in Bazel aspect - #754
Merged
antonsviridov-src merged 6 commits intoOct 10, 2024
Merged
antonsviridov-src merged 6 commits into
antonsviridov-src merged 6 commits into
Conversation
antonsviridov-src
marked this pull request as ready for review
October 10, 2024 10:34
antonsviridov-src
deleted the
antonsviridov-graph-828-scip-java-for-bazel-does-not-handle-srcjar-inputs
branch
October 10, 2024 12:54
|
Thank you very much for taking a look at this, very excited! I decided to build from source and seems to work for most cases. However, it seems to fail when there are 2 java libraries in the same BUILD.bazel that use the same srcjar. Here's an extended example: genrule(
name = "generated-srcjar",
outs = ["sources.srcjar"],
cmd = "echo 'package com.testing; public class Bar {};' > Bar.java && jar cf $(@) Bar.java",
)
java_library(
name = "other_library",
srcs = [
"Baz.java", # create a new file in source at test/Baz.java, alongside test/Foo.java
":generated-srcjar",
],
)
java_library(
name = "testing",
srcs = [
"Foo.java",
":generated-srcjar",
],
) |
|
Also, somewhat of an edge case, but we have some srcjars that end up becoming empty due to Reasons, causing the following error: genrule(
name = "empty-srcjar",
outs = ["sources.srcjar"],
cmd = "touch test.txt && zip $(@) test.txt && zip -d $(@) test.txt",
)
java_library(
name = "testing",
srcs = [
"Foo.java",
":empty-srcjar",
],
)But other than these 2 things, it is looking very promising. Thank you!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The aspect will add a new entry to sourceFiles:
and ScipBuildTool will be able to traverse folders and lookup all source files in them.
Together this allows us to avoid unpacking jars in scip-java (which would entail tracking their location and caching, which would be annoying), instead delegating all that to Bazel.
Test plan