Skip to content

Commit f75441e

Browse files
committed
[Fix #231] Drop support for hotloading dependencies
Alembic doesn't work anymore and other better solutions are coming down the line, so this is disabled for now..
1 parent 9e1952c commit f75441e

File tree

4 files changed

+3
-68
lines changed

4 files changed

+3
-68
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Unreleased
4+
* [#231](https://github.com/clojure-emacs/refactor-nrepl/issues/231) hotload-dependencies temporarily disabled due to java 10 issues.
45
* [#215](https://github.com/clojure-emacs/refactor-nrepl/issues/215) Support JVM system proxy in mvn artifacts listing
56
* [#198](https://github.com/clojure-emacs/refactor-nrepl/issues/187) Delay middleware loading to speed up initialization.
67
* Bump [mranderson](https://github.com/benedekfazekas/mranderson) version to fix leiningen 2.8.x incompatibility issues

project.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
:dependencies [[org.clojure/tools.nrepl "0.2.13"]
77
^:source-dep [http-kit "2.2.0"]
88
^:source-dep [cheshire "5.8.0"]
9-
^:source-dep [alembic "0.3.2"]
109
^:source-dep [org.clojure/tools.analyzer.jvm "0.7.1"]
1110
^:source-dep [org.clojure/tools.namespace "0.3.0-alpha3"]
1211
^:source-dep [org.clojure/tools.reader "1.1.1"]

src/refactor_nrepl/artifacts.clj

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns refactor-nrepl.artifacts
2-
(:require [alembic.still :as alembic]
3-
[cheshire.core :as json]
2+
(:require [cheshire.core :as json]
43
[clojure
54
[edn :as edn]
65
[string :as str]]
@@ -107,53 +106,6 @@
107106
reverse
108107
list*))
109108

110-
(defn- make-resolve-missing-aware-of-new-deps
111-
"Once the deps are available on cp we still have to load them and
112-
reset slamhound's cache to make resolve-missing work."
113-
[coords repos]
114-
(let [dep (->> (alembic/resolve-dependencies alembic/the-still coords repos nil)
115-
(some (fn [dep] (when (= (:coords dep) (first coords)) dep))))
116-
jarfile (JarFile. (:jar dep))]
117-
(doseq [namespace (find/find-namespaces-in-jarfile jarfile)]
118-
(try
119-
(require namespace)
120-
(catch Exception _
121-
;; I've seen this happen after adding core.async as a dependency.
122-
;; It also happens if you try to require namespaces that no longer work,
123-
;; like compojure.handler.
124-
;; A failure here isn't a big deal, it only means that resolve-missing
125-
;; isn't going to work until the namespace has been loaded manually.
126-
)))
127-
(slamhound/reset)
128-
(slamhound-regrow/clear-cache!)))
129-
130-
(defn- ensure-quality-coordinates [coordinates]
131-
(let [coords (->> coordinates read-string (take 2) vec)]
132-
(when-not (= (count coords) 2)
133-
(throw (IllegalArgumentException. (str "Malformed dependency vector: "
134-
coordinates))))
135-
(when (stale-cache?)
136-
(update-artifact-cache!))
137-
(if-let [versions (get @artifacts (str (first coords)))]
138-
(when-not ((set versions) (second coords))
139-
(throw (IllegalArgumentException.
140-
(str "Version " (second coords)
141-
" does not exist for " (first coords)
142-
". Available versions are " (pr-str (vec versions))))))
143-
(throw (IllegalArgumentException. (str "Can't find artifact '"
144-
(first coords) "'"))))))
145-
146-
(defn distill [coords repos]
147-
;; Just so we can mock this out during testing
148-
(alembic/distill coords :repositories repos))
149-
150109
(defn hotload-dependency
151110
[{:keys [coordinates]}]
152-
(let [dependency-vector (edn/read-string coordinates)
153-
coords [(->> dependency-vector (take 2) vec)]
154-
repos {"clojars" "http://clojars.org/repo"
155-
"central" "http://repo1.maven.org/maven2/"}]
156-
(ensure-quality-coordinates coordinates)
157-
(distill coords repos)
158-
(make-resolve-missing-aware-of-new-deps coords repos)
159-
(str/join " " dependency-vector)))
111+
(throw (IllegalArgumentException. "Temporarily disabled until a solution for java 10 is found.")))

test/refactor_nrepl/artifacts_test.clj

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,3 @@
4646
(reset! artifacts/artifacts {"org.clojure/clojure" clojure-versions})
4747
(is (= sorted-clojure-versions
4848
(artifacts/artifact-versions {:artifact "org.clojure/clojure"}))))))
49-
50-
(deftest hotload-dependency-throws-exceptions
51-
(reset! artifacts/artifacts {"prismatic/schema" ["0.1"]})
52-
(with-redefs
53-
[artifacts/make-resolve-missing-aware-of-new-deps (fn [& _])
54-
artifacts/stale-cache? (constantly false)
55-
artifacts/distill (constantly true)]
56-
(testing "Throws for non existing version"
57-
(is (thrown? IllegalArgumentException
58-
(artifacts/hotload-dependency
59-
{:coordinates "[prismatic/schema \"1.0\"]"}))))
60-
(testing "Throws for non existing artifact"
61-
(is (thrown? IllegalArgumentException
62-
(artifacts/hotload-dependency
63-
{:coordinates "[imaginary \"1.0\"]"}))))
64-
(testing "No exception when all is OK"
65-
(is (artifacts/hotload-dependency {:coordinates "[prismatic/schema \"0.1\"]"})))))

0 commit comments

Comments
 (0)