Unable to use stamp information in `java_binary`'s MANIFEST.MF
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 28/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- java
- Ambito
- build-system
Direzione di ricerca
Inizia con l’attributo deploy_manifest_lines di java_binary e riproduci il problema usando gli esempi .bazelrc e BUILD.bazel. Esamina come il workspace status viene esposto tramite bazel-out/stable-status.txt e bazel-out/volatile-status.txt, quindi definisci un modo supportato per fare arrivare valori personalizzati a META-INF/MANIFEST.MF e verifica il risultato nel test_deploy.jar generato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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...)!
- Lingua principale
- Starlark
- Stelle
- 103
- Fork
- 102
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bazelbuild/rules_java
-
P4
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
bazelbuild/rules_java#360 · 4 commenti · 2 reazioni ·
-
P4
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
bazelbuild/rules_java#354 · 8 commenti ·
-
P3 question
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
bazelbuild/rules_java#339 · 1 commento ·
-
P3
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
bazelbuild/rules_java#325 · 8 commenti ·
-
P4
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
bazelbuild/rules_java#316 · 2 reazioni ·
Tutte le issue di bazelbuild/rules_java
Issue simili
-
status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
area:jail bug security severity:low track:open-source
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
micro-ROS/micro_ros_setup#837 ·