-
-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use revamped enrich-classpath plugin (#3364)
- Loading branch information
Showing
7 changed files
with
245 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
# This wrapper script adds enrich-classpath's (https://github.com/clojure-emacs/enrich-classpath) functionalities to the `clojure` binary. | ||
# It works by accepting the `clojure` binary as the first argument, and whatever arguments you'd pass to `clojure` as the rest. | ||
# sample usage: clojure.sh clojure -Asome-alias <<< "(System/getProperty \"java.class.path\")" | ||
|
||
clojure="$1" | ||
# remove it from "$@"/"$*": | ||
shift | ||
|
||
file="deps.edn" | ||
|
||
if [ ! -e $file ]; then | ||
echo "$file not found." | ||
$clojure "$@" | ||
elif [[ "$*" == *Spath* ]]; then | ||
echo "-Spath was passed; skipping enrich-classpath." | ||
$clojure "$@" | ||
elif [[ "$*" == *Scp* ]]; then | ||
echo "-Scp was passed; skipping enrich-classpath." | ||
$clojure "$@" | ||
else | ||
|
||
here="$PWD" | ||
there=$(mktemp -d -t mytempdir.XXXXXX) | ||
|
||
# don't let local deps.edn files interfere: | ||
cd "$there" | ||
|
||
# enrich-classpath will emit a command starting by "clojure", or print a stacktrace: | ||
output=$(2>&1 "$clojure" -Sforce -Srepro -J-XX:-OmitStackTraceInFastThrow -J-Dclojure.main.report=stderr -Sdeps '{:deps {mx.cider/tools.deps.enrich-classpath {:mvn/version "1.15.3"}}}' -M -m cider.enrich-classpath.clojure "$clojure" "$here" "true" "$@") | ||
cmd=$(tail -n1 <(echo "$output")) | ||
|
||
cd "$here" | ||
|
||
if grep --silent "^$clojure" <<< "$cmd"; then | ||
# eval is necessary because $cmd contains arguments that have been processed through pr-str. | ||
eval "$cmd" | ||
else | ||
# Print errors: | ||
echo "$output" | ||
$clojure "$@" | ||
fi | ||
|
||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.