-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
starlark impl of java_common.pack_sources generates invalid srcjar when inputs come from external repository #20882
Labels
Comments
@bazel-io fork 7.0.1 |
rbeasley
added a commit
to rbeasley/bazel
that referenced
this issue
Jan 13, 2024
This commit tweaks the Starlark implementation of `java_common.pack_sources` to behave more like its original Java counterpart. Specifically, we don't use `file.short_path`, because when `file` comes from an external repository, `short_path` will have a `../<externalrepo>` prefix. Resolves bazelbuild#20882.
rbeasley
changed the title
starlark impl of java_common.pack_sources generates invalid srcjar when inputs come from separate repository
starlark impl of java_common.pack_sources generates invalid srcjar when inputs come from external repository
Jan 13, 2024
/cc @hvadehra |
hvadehra
added
P1
I'll work on this now. (Assignee required)
and removed
untriaged
labels
Jan 15, 2024
bazel-io
pushed a commit
to bazel-io/bazel
that referenced
this issue
Jan 15, 2024
Fixes bazelbuild#20882 PiperOrigin-RevId: 598608807 Change-Id: If9230cd1c143eef09beabaf33cb1cb56e4540ae1
meteorcloudy
pushed a commit
that referenced
this issue
Jan 16, 2024
) Fixes #20882 Commit 6ae53e5 PiperOrigin-RevId: 598608807 Change-Id: If9230cd1c143eef09beabaf33cb1cb56e4540ae1 --------- Co-authored-by: Googler <[email protected]> Co-authored-by: hvd <[email protected]>
A fix for this issue has been included in Bazel 7.0.1 RC2. Please test out the release candidate and report any issues as soon as possible. Thanks! |
@bazel-io fork 7.1.0 |
bazel-io
pushed a commit
to bazel-io/bazel
that referenced
this issue
Jan 22, 2024
Fixes bazelbuild#20882 PiperOrigin-RevId: 598608807 Change-Id: If9230cd1c143eef09beabaf33cb1cb56e4540ae1
github-merge-queue bot
pushed a commit
that referenced
this issue
Jan 23, 2024
) Fixes #20882 Commit 6ae53e5 PiperOrigin-RevId: 598608807 Change-Id: If9230cd1c143eef09beabaf33cb1cb56e4540ae1 --------- Co-authored-by: Googler <[email protected]> Co-authored-by: keertk <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Description of the bug:
Under Bazel 7, when feeding sources from an external repository to
java_common.pack_sources
, the sources are mapped to illegal paths beginning with../
. For example, if we pass@foo//:dummy.txt
topack_sources
, we'll end up with a jar containing../foo/dummy.txt
.Which category does this issue belong to?
Java Rules
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Which operating system are you running Bazel on?
Linux
What is the output of
bazel info release
?release 7.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Yes. 6da7f21
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
I suspect that the Java and Starlark implementations aren't quite the same:
bazel/src/main/starlark/builtins_bzl/common/java/java_helper.bzl
Lines 295 to 299 in 2f899ef
bazel/src/main/java/com/google/devtools/build/lib/rules/java/SingleJarActionBuilder.java
Lines 139 to 146 in 2f899ef
Compare
resource.getRootRelativePath()
tofile.short_path
.IIUC, then based on the table at https://github.com/bazelbuild/rules_pkg/blob/main/pkg/mappings.bzl#L166-L177, instead of using
file.short_path
it should instead bepaths.relativize(file.path, paths.normalize(paths.join(file.root.path, file.owner.workspace_root)))
.The text was updated successfully, but these errors were encountered: