Unable to use stamp information in `java_binary`'s MANIFEST.MF
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu với thuộc tính deploy_manifest_lines của java_binary và tái hiện vấn đề bằng các ví dụ .bazelrc và BUILD.bazel. Kiểm tra cách workspace status được cung cấp thông qua bazel-out/stable-status.txt và bazel-out/volatile-status.txt, sau đó xác định một cách được hỗ trợ để đưa các giá trị tùy chỉnh vào META-INF/MANIFEST.MF và xác minh kết quả trong test_deploy.jar được tạo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
As far as I can tell, it currently isn't possible to use the output from --workspace_status_command in java_* rules. Specifically, it seems like a fairly common use-case (and coincidentally, what I'm currently trying to do 😉) would be to include some form of build information (revision / build date / whatever) in the MANIFEST.MF of a .jar file.
Expected behaviour: able to --stamp a java_binary with custom variables
Actual behaviour: unable to pass through any custom variables to deploy_manifest_lines
Steps to reproduce:
As a fairly trivial reproduction:
# .bazelrc
common --stamp --workspace_status_command=/usr/bin/true --embed_label="Hello"
# BUILD.bazel
java_binary(name = "test", ..., deploy_manifest_lines = [ "Custom-Label: {{BUILD_EMBED_LABEL}}" ])
Running bazel build :test_deploy.jar && unzip -p bazel-bin/test_deploy.jar META-INF/MANIFEST.MF outputs:
...
Custom-Label: {{BUILD_EMBED_LABEL}}
...
rather than the desired:
...
Custom-Label: Hello
...
Extra information
I'm not 100% sure if this has changed in newer versions of rules_java (having a quick glance at the source, it seemed not?) but at least as of v7.x the attribute for deploy_manifest_lines only accepts a list of strings, and states:
The contents of this attribute are not subject to "Make variable" substitution.
It seems like there are maybe two related problems*, one is specific to rules_java and the other is a more general Bazel thing:
java_binaryonly accepts fixed strings fordeploy_manifest_lines- Bazel does not provide convenient access to workspace status vars in macros or custom rules.
From what I've seen in some other places (e.g. rules_oci) there's no good solution to (2), so the pattern seems to be to allow providing a single file to use, and then having a command that generates that file by also reading from the bazel-out/stable-status.txt and bazel-out/volatile-status.txt files, e.g.
# BUILD.bazel
java_manifest(name = "manifest", lines = {"Custom-Label": "{{BUILD_EMBED_LABEL}}")
java_binary(name = "test", ..., deploy_manifest_lines = ":manifest")
* I imagine some people will argue this is a feature, but it doesn't feel like it from here!
If it's possible to do it without generating an intermediate file, that would be even better, but I suspect that won't be the case (at least without some major work to Bazel itself...)!
- Ngôn ngữ chính
- Starlark
- Star
- 103
- Fork
- 102
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bazelbuild/rules_java
-
P4
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
bazelbuild/rules_java#360 · 4 bình luận · 2 reaction ·
-
P4
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
bazelbuild/rules_java#354 · 8 bình luận ·
-
P3 question
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
bazelbuild/rules_java#339 · 1 bình luận ·
-
P3
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
bazelbuild/rules_java#325 · 8 bình luận ·
-
P4
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
bazelbuild/rules_java#316 · 2 reaction ·
Tất cả issue của bazelbuild/rules_java
Issue tương tự
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
priority: p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
googleapis/librarian#7636 ·
-
Bug v3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
Update gh-dash to 4.26.0 Đang mởpackage-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
oSoWoSo/vOid_Community_repOsitory#147 · 1 bình luận ·
-
Builders
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100