Unable to use stamp information in `java_binary`'s MANIFEST.MF
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 28/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- java
- Área
- build-system
Línea de trabajo
Comienza con el atributo deploy_manifest_lines de java_binary y reproduce el problema usando los ejemplos .bazelrc y BUILD.bazel. Inspecciona cómo se expone el workspace status a través de bazel-out/stable-status.txt y bazel-out/volatile-status.txt; después, define una forma compatible de hacer llegar valores personalizados a META-INF/MANIFEST.MF y verifica el resultado en el test_deploy.jar generado.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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...)!
- Lenguaje dominante
- Starlark
- Estrellas
- 103
- Forks
- 102
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bazelbuild/rules_java
-
P4
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
bazelbuild/rules_java#360 · 4 comentarios · 2 reacciones ·
-
P4
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
bazelbuild/rules_java#354 · 8 comentarios ·
-
P3 question
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
bazelbuild/rules_java#339 · 1 comentario ·
-
P3
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
bazelbuild/rules_java#325 · 8 comentarios ·
-
P4
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
bazelbuild/rules_java#316 · 2 reacciones ·
Todos los issues de bazelbuild/rules_java
Issues similares
-
type/automation type/tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
priority: p3
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
googleapis/librarian#7636 ·
-
Update gh-dash to 4.26.0 Abiertopackage-update
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
oSoWoSo/vOid_Community_repOsitory#147 · 1 comentario ·
-
Builders
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100