Improve error message when plugin isn't found.

This commit is contained in:
Phil Hagelberg 2012-08-10 10:59:11 -07:00
parent 80fc9662fb
commit c6acc122f1
5 changed files with 16 additions and 11 deletions

View file

@ -6,7 +6,8 @@
[clojure.string :as str]
[leiningen.core.user :as user])
(:import (java.util.jar JarFile)
(java.net URL)))
(java.net URL)
(org.sonatype.aether.resolution DependencyResolutionException)))
;; Basically just for re-throwing a more comprehensible error.
(defn- read-dependency-project [root dep]
@ -117,6 +118,12 @@
:mirrors mirrors
:transfer-listener :stdout
:proxy (get-proxy-settings))
(catch DependencyResolutionException e
(binding [*out* *err*]
(println "Check :dependencies and :repositories for typos.")
(println "It's possible the specified jar is not in any repository.")
(println "If so, see \"Free-floating Jars\" under http://j.mp/repeatability"))
(throw (ex-info "Could not resolve dependencies" {:exit-code 1})))
(catch Exception e
(if (and (instance? java.net.UnknownHostException (root-cause e))
(not offline?))

View file

@ -7,8 +7,7 @@
[leiningen.core.user :as user]
[leiningen.core.project :as project]
[leiningen.core.main :as main]
[leiningen.core.classpath :as classpath])
(:import (org.sonatype.aether.resolution DependencyResolutionException)))
[leiningen.core.classpath :as classpath]))
;; # OS detection
@ -55,13 +54,7 @@
(defn prep [project]
;; This must exist before the project is launched.
(.mkdirs (io/file (:compile-path project "/tmp")))
(try (classpath/get-classpath project)
(catch DependencyResolutionException e
(main/info (.getMessage e))
(main/info "Check :dependencies and :repositories for typos.")
(main/info "It's possible the specified jar is not in any repository.")
(main/info "If so, see \"Free-floating Jars\" under http://j.mp/repeatability")
(main/abort)))
(classpath/resolve-dependencies :dependencies project)
(run-prep-tasks project)
(.mkdirs (io/file (:compile-path project "/tmp")))
(when-let [prepped (:prepped (meta project))]

View file

@ -217,6 +217,8 @@ or by executing \"lein upgrade\". ")
(project/load-plugins default-project)))
(try (warn-chaining task-name args)
(apply-task task-name project args)
(catch clojure.lang.ExceptionInfo e
(exit (:exit-code (ex-data e) 1)))
(catch Exception e
(when-let [[_ code] (and (.getMessage e)
(re-find #"Process exited with (\d+)"

View file

@ -40,7 +40,7 @@ than as a subprocess of Leiningen's project.
Use this to save memory or to work around stdin issues."
[project task-name & args]
;; TODO: allow trampoline calls to chain with do
;; TODO: allow trampoline calls to chain with do (does this already work?)
(let [forms (atom [])]
(when (:eval-in-leiningen project)
(main/info "Warning: trampoline has no effect with :eval-in-leiningen."))

View file

@ -7,8 +7,11 @@ See also https://github.com/technomancy/leiningen/issues
- [ ] Recover from interrupted self-install (#719)
- [ ] Honor :local-repo in trampoline (#695)
- [ ] Improve speed of trampoline restarts (#573)
- [ ] Calculate trampoline classpath based on project at time of eval-in-project.
- [ ] Reduce verbosity of Aether. (#610)
- [ ] Isolate target dir per profile (#468)
- [ ] Honor mirror for search indices (#281)
- [ ] Allow search queries on any field. (#243)
- [ ] Drop clojars snapshots from default repos (#241)
** 2.0.0-preview8
- [X] Allow trampoline to work with chaining in do task (#665)