Skip to content

Commit

Permalink
Use @// instead of @${workspace_name}// (#558)
Browse files Browse the repository at this point in the history
@// refers to the root workspace of the bazel invocation, regardless of
which repository it's referred to in.

This avoids needing to run `bazel info` from inside the `bazel run`.
  • Loading branch information
illicitonion committed May 12, 2021
1 parent 8feca27 commit 786947c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions private/pin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

set -euo pipefail
readonly maven_install_json_loc={maven_install_location}
# This script is run as a `sh_binary`, so ensure we are in the calling workspace before running Bazel.
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.
# 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
Expand All @@ -31,7 +28,7 @@ else
maven_install(
artifacts = # ...,
repositories = # ...,
maven_install_json = "@$workspace_name//:{repository_name}_install.json",
maven_install_json = "@//:{repository_name}_install.json",
)
load("@{repository_name}//:defs.bzl", "pinned_maven_install")
Expand Down

0 comments on commit 786947c

Please sign in to comment.