Skip to content

Commit 3a5a9fd

Browse files
committed
Add enrich-classpath to the Makefile
1 parent 321b692 commit 3a5a9fd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Makefile

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
.PHONY: test eastwood cljfmt install smoketest deploy clean detect_timeout
1+
.PHONY: test eastwood cljfmt install fast-install smoketest deploy clean detect_timeout lein-repl repl lint light-kondo
22
.DEFAULT_GOAL := quick-test
33

44
CLOJURE_VERSION ?= 1.11
55

6+
# The Lein profiles that will be selected for `lein-repl`.
7+
# Feel free to upgrade this, or to override it with an env var named LEIN_PROFILES.
8+
# Expected format: "+dev,+test"
9+
# Don't use spaces here.
10+
LEIN_PROFILES ?= "+dev,+test"
11+
12+
# The enrich-classpath version to be injected.
13+
# Feel free to upgrade this.
14+
ENRICH_CLASSPATH_VERSION="1.17.1"
15+
616
test/resources/cider/nrepl/clojuredocs/export.edn:
717
curl -o $@ https://github.com/clojure-emacs/clojuredocs-export-edn/raw/master/exports/export.compact.edn
818

@@ -100,3 +110,19 @@ clean:
100110
cd test/smoketest && lein with-profile -user clean
101111
rm -f .inline-deps
102112
git checkout resources/cider/nrepl/version.edn
113+
114+
# Create and cache a `java` command. project.clj is mandatory; the others are optional but are taken into account for cache recomputation.
115+
# It's important not to silence with step with @ syntax, so that Enrich progress can be seen as it resolves dependencies.
116+
.enrich-classpath-lein-repl: Makefile project.clj $(wildcard checkouts/*/project.clj) $(wildcard deps.edn) $(wildcard $(HOME)/.clojure/deps.edn) $(wildcard profiles.clj) $(wildcard $(HOME)/.lein/profiles.clj) $(wildcard $(HOME)/.lein/profiles.d) $(wildcard /etc/leiningen/profiles.clj)
117+
bash 'lein' 'update-in' ':plugins' 'conj' "[mx.cider/lein-enrich-classpath \"$(ENRICH_CLASSPATH_VERSION)\"]" '--' 'with-profile' $(LEIN_PROFILES) 'update-in' ':middleware' 'conj' 'cider.enrich-classpath.plugin-v2/middleware' '--' 'repl' | grep " -cp " > $@
118+
119+
# Launches a repl, falling back to vanilla lein repl if something went wrong during classpath calculation.
120+
lein-repl: .enrich-classpath-lein-repl
121+
@if grep --silent " -cp " .enrich-classpath-lein-repl; then \
122+
eval "$$(cat .enrich-classpath-lein-repl) --interactive"; \
123+
else \
124+
echo "Falling back to lein repl... (you can avoid further falling back by removing .enrich-classpath-lein-repl)"; \
125+
lein with-profiles $(LEIN_PROFILES) repl; \
126+
fi
127+
128+
repl: lein-repl

0 commit comments

Comments
 (0)