Skip to content

Commit 33dbbff

Browse files
committed
More stable require of hotloaded dependencies
- make sure we match up the coords we're interested in with the correct jar from alembic/resolve-dependencies - if some namespace in that jar doesn't load correctly, keep going with the others (compojure.handler, I'm looking at you)
1 parent 38d6c7f commit 33dbbff

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/refactor_nrepl/artifacts.clj

+14-10
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,20 @@
9595
"Once the deps are available on cp we still have to load them and
9696
reset slamhound's cache to make resolve-missing work."
9797
[coords repos]
98-
(try
99-
(let [dep (first (alembic/resolve-dependencies alembic/the-still coords repos nil))
100-
jarfile (JarFile. (:jar dep))]
101-
(dorun (map require (find/find-namespaces-in-jarfile jarfile)))
102-
(slamhound/reset))
103-
(catch ClassNotFoundException _
104-
;; I've seen this happen after adding core.async as a dependency.
105-
;; A failure here isn't a big deal, it only means that resolve-missing
106-
;; isn't going to work until the namespace has been loaded manually.
107-
)))
98+
(let [dep (->> (alembic/resolve-dependencies alembic/the-still coords repos nil)
99+
(some (fn [dep] (when (= (:coords dep) (first coords)) dep))))
100+
jarfile (JarFile. (:jar dep))]
101+
(doseq [namespace (find/find-namespaces-in-jarfile jarfile)]
102+
(try
103+
(require namespace)
104+
(catch Exception _
105+
;; I've seen this happen after adding core.async as a dependency.
106+
;; It also happens if you try to require namespaces that no longer work,
107+
;; like compojure.handler.
108+
;; A failure here isn't a big deal, it only means that resolve-missing
109+
;; isn't going to work until the namespace has been loaded manually.
110+
)))
111+
(slamhound/reset)))
108112

109113
(defn- ensure-quality-coordinates [coordinates]
110114
(let [coords (->> coordinates read-string (take 2) vec)]

0 commit comments

Comments
 (0)