Skip to content

Commit

Permalink
If none of the jars have a spring.components file, it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismgrayftsinc committed Dec 2, 2022
1 parent 1ab3345 commit d194e8c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spring_image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,14 @@ def tar_jars(ctx, files, out):
ctx.actions.run_shell(
inputs = ctx.files._jdk + files,
outputs = [spring_components_file],
command = "touch {file}; for i in {all_paths}; do {jar} xf $i && cat META-INF/spring.components >> {file}; done".format(file = spring_components_file.path, jar = jar_path, all_paths = " ".join(paths)),
command = "touch {file}; for i in {all_paths}; do {jar} xf $i && if [-s META-INF/spring.components ]; then cat META-INF/spring.components >> {file}; fi; done".format(file = spring_components_file.path, jar = jar_path, all_paths = " ".join(paths)),
)

ctx.actions.run_shell(
inputs = ctx.files._jdk + files + [spring_components_file],
outputs = [out],
# Create an empty tarball, then extract all the jars and append the contents into it.
# TODO: get rid of the hardcoded bazel-out path in the first transform.
command = 'tar cf {out} -T /dev/null && if [ -s {scf} ]; then tar rhf {out} --transform "s,bazel-out/k8-fastbuild/bin/,BOOT-INF/classes/META-INF/," {scf}; fi && for i in {all_paths}; do {jar} xf $i && {jar} tf $i | tar rf {out} --transform "s,^,BOOT-INF/classes/," -T -; done'.format(out = out.path, all_paths = " ".join(paths), jar = jar_path, scf = spring_components_file.path),
)

Expand Down

0 comments on commit d194e8c

Please sign in to comment.