salesforce / rules_spring

Bazel rule for building Spring Boot apps as a deployable jar
BSD 3-Clause "New" or "Revised" License
224 stars 48 forks source link

Executable shell script isn't runnable from repository root #110

Open simontoens opened 3 years ago

simontoens commented 3 years ago

The springboot rule is_executable. During the build phase, the springboot rule generates a shell script, which bazel then calls when the user invokes "bazel run". Sometimes, for debugging, it is useful to be able to run this shell script by itself. This doesn't work from the repository root - instead the current directory has to be "bazel-bin". This doesn't match the behavior of other shell scripts generated by rules that are executable - they are typically runnable from the repo root.

For example, assuming this target is the springboot rule target: projects/services/myservice:myservice

This doesn't work (from the repo root): bazel-bin/projects/services/myservice/myservice

This does work, but it is less convenient: cd bazel-bin && projects/services/myservice/myservice

drmercer-lucid commented 2 years ago

Just a note, in v2.1.0 onward, this is now even more broken than before (probably related to #143). Neither running from the repo root nor running from bazel-bin work anymore:

$ bazel-bin/my-project/my-project_deploy
bazel-bin/my-project/my-project_deploy: line 15: external/rules_spring/springboot/default_bazelrun_script.sh: No such file or directory
$ cd bazel-bin && my-project/my-project_deploy
my-project/my-project_deploy: line 15: external/rules_spring/springboot/default_bazelrun_script.sh: No such file or directory

Can confirm that cd bazel-bin && my-project/my-project_deploy does work on 2.0.0, though.