Skip to content

Commit

Permalink
Fix jq path in :pin runnable (#454)
Browse files Browse the repository at this point in the history
It currently relies on the legacy_external_runfiles behavior where Bazel makes
two copies of the program, at both
pin.runfiles/unpinned_maven/jq and  pin.runfiles/user_repo/external/unpinned_maven/jq

Problem reported on #426
  • Loading branch information
alexeagle authored Sep 9, 2020
1 parent a3a8053 commit 1c41eca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sh_binary(
name = "pin",
srcs = ["pin.sh"],
args = [
"$(location :jq-binary)",
"$(rootpath :jq-binary)",
],
data = [
":jq-binary",
Expand Down
5 changes: 4 additions & 1 deletion private/pin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ readonly maven_install_json_loc={maven_install_location}
readonly execution_root=$(cd "$(dirname "$maven_install_json_loc")" && bazel info execution_root)
readonly workspace_name=$(basename "$execution_root")
# `jq` is a platform-specific dependency with an unpredictable path.
readonly jq=$1
# Note that $(rootpath) will always give external/unpinned_maven/jq, however under --nolegacy_external_runfiles
# there is only pin.runfiles/unpinned_maven/jq not also pin.runfiles/user_repo/external/unpinned_maven/jq
# So replace leading external/ with ../
readonly jq=${1/#external\//..\/}
cat <<"RULES_JVM_EXTERNAL_EOF" | "$jq" --sort-keys --indent 4 . - > $maven_install_json_loc
{dependency_tree_json}
RULES_JVM_EXTERNAL_EOF
Expand Down

0 comments on commit 1c41eca

Please sign in to comment.