|
1 | 1 | (ns refactor-nrepl.artifacts
|
2 |
| - (:require [alembic.still :as alembic] |
3 |
| - [cheshire.core :as json] |
| 2 | + (:require [cheshire.core :as json] |
4 | 3 | [clojure
|
5 | 4 | [edn :as edn]
|
6 | 5 | [string :as str]]
|
|
107 | 106 | reverse
|
108 | 107 | list*))
|
109 | 108 |
|
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 |
| - |
150 | 109 | (defn hotload-dependency
|
151 | 110 | [{: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."))) |
0 commit comments