Skip to content

Commit

Permalink
Use aether data to figure out repository id for listener output
Browse files Browse the repository at this point in the history
For "important" events, aether gives us enough info to figure
out which repo it is happening from.  Lets use it instead
of trying to match from project data.

Previously matching from the project data would be incorrect
and output failures or not output anything for transative repos.
  • Loading branch information
xeqi committed Dec 15, 2012
1 parent c07259f commit 723671b
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions leiningen-core/src/leiningen/core/classpath.clj
Expand Up @@ -126,32 +126,31 @@
:transfer-listener
(bound-fn [e]
(let [{:keys [type resource error]} e]
(let [{:keys [repository name size]} resource]
(case type
:started
(println "Retrieving"
name
(if (neg? size)
""
(format "(%sk)"
(Math/round (double (max 1 (/ size 1024))))))
"from"
(or (first (first (filter #(= repository (:url (second %)))
repositories)))
repository))
:corrupted
(when error
(println "Failed to download" name "from"
(or (first (first (filter #(= repository (:url (second %)))
repositories)))
repository)
":"
(.getMessage error)))
:failed
(when (and (= repository (:url (second (last repositories))))
error)
(println "Failed to download" name))
nil))))
(let [{:keys [repository name size trace]} resource]
(let [aether-repos (if trace (.getRepositories (.getData trace)))]
(case type
:started
(if-let [repo (first (filter
#(or (= (.getUrl %) repository)
;; sometimes the "base" url
;; doesn't have a slash on it
(= (str (.getUrl %) "/") repository))
aether-repos))]
(println "Retrieving"
name
"from"
(.getId repo))
;;else case happens for metadata files
)
:corrupted
(when error
(println (.getMessage error)))
:failed
(when (and error
(= (.getRepository error)
(last aether-repos)))
(println "Failed to download" name))
nil)))))
:proxy (get-proxy-settings))
(catch DependencyResolutionException e
(binding [*out* *err*]
Expand Down

0 comments on commit 723671b

Please sign in to comment.