-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Produced source JARs don't correspond to files in class JAR #8277
Comments
Create
Check Gerrit Code Review: [1]. We do it like I described above and we put JARs and source-JARs created by Bazel to Maven Central:
and check the structure of the resulted JAR an source-JAR. [1] https://github.com/GerritCodeReview/gerrit/blob/master/java/com/google/gerrit/common/BUILD |
@davido thank you for your suggestion! however, my intention is to preserve the directory structure we currently have where directories represent logical separation of modules and not necessarily java packaging |
## What is the goal of this PR? Bazel upgrade to `0.29.0` planned across all repos is going to break all CI because newest version doesn't work with our custom Java toolchain (due to bazelbuild/bazel#8659). However, we found a different way to approach the original problem (described in bazelbuild/bazel#8277) which is modifying the IntelliJ Bazel plugin. This solution does not require custom Java toolchain and therefore it'll be removed. ## What are the changes implemented in this PR? Stop using custom `java_toolchain` [with modified `singlejar` binary] for all builds
We've addressed it by using a workaround on plugin level: bazelbuild/intellij#1206, bazelbuild/intellij#1207 |
@vmax Can you re-open this issue? Alternatively, I can open a new issue for source path normalization in created "-src.jar" in I am facing a similar problem, when trying to migrate existing project to Bazel an I think, that this should be fixed in Bazel. Consider this directory structure (that I cannot change): <workspace_root>/foo/org/example/app/Test.java The build file is put in java_library(
name = "foo",
srcs = glob(["org/**/*.java"]),
) When building "foo/org/example/app/Test.java" Note, that if I rename the foo directory to one of these directories:
then the "foo" directory is stripped. One approach to fix that would be to provide One workaround, that can be done now, is to create # TODO(davido): Remove that hack to create source package without the wrong path prefix.
java_binary(
name = "foo-src-binary",
main_class = "Dummy.java",
resources = glob(["org/**/*.java"]),
resource_strip_prefix = "foo",
)
# TODO(davido): Remove that hack to rename the java_binary source with ".jar" suffix
# to zip file with ".srcjar" suffix so that java_library can accept it.
genrule2(
name = "foo-src",
cmd = "mv $< $@",
srcs = [":foo-src-binary_deploy.jar"],
outs = ["foo.srcjar"],
)
java_library(
name = "foo",
srcs = [":foo-src"],
) |
@davido I think you should open another one: you might have another reasons for wanting to have a correct source JAR and will then be able to convince Bazel team to look at them 🙂 |
Description of the problem / feature request:
Source JARs produced currently replicate the structure of source files used to build the class JAR. Example:
Given this example, I would expect source JAR to contain structure similar to the following:
Feature requests: what underlying problem are you trying to solve with this feature?
We need produced source JARs to have the same structure as class files inside class JAR so that:
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
What operating system are you running Bazel on?
macOS Mojave 10.14.4
What's the output of
bazel info release
?release 0.25.0
Have you found anything relevant by searching the web?
—
The text was updated successfully, but these errors were encountered: