Skip to content

Commit

Permalink
Download plugins. RT/addURL is a nest of filthy lies.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Dec 30, 2011
1 parent 29f3956 commit d3dca71
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/lein
Expand Up @@ -40,7 +40,7 @@ if [ "$LEIN_HOME" = "" ]; then
fi
fi

DEV_PLUGINS="$(ls -1 lib/dev/*jar 2> /dev/null)"
DEV_PLUGINS="$(ls -1 lib/dev/*jar .lein-plugins/*jar 2> /dev/null)"
USER_PLUGINS="$(ls -1 "$LEIN_HOME"/plugins/*jar 2> /dev/null)"

artifact_name () {
Expand Down
4 changes: 4 additions & 0 deletions sample.project.clj
Expand Up @@ -37,9 +37,13 @@
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]]
;; The plugins listed here will be accessible in Leiningen's own
;; process, but not in the project.
:plugins [[lein-tar "1.0.6"]]
;; Dev dependencies are intended for use only during
;; development. Projects that depend on this project will not pull
;; in its dev-dependencies, and they won't be included in the uberjar.
;; These will appear both in Leiningen's process and the project's.
:dev-dependencies [[org.clojure/swank-clojure "1.2.1"]]
;; Global exclusions are applied across the board, as an alternative
;; to duplication for multiple depedencies with the same excluded libraries.
Expand Down
28 changes: 22 additions & 6 deletions src/leiningen/deps.clj
@@ -1,6 +1,7 @@
(ns leiningen.deps
"Download all dependencies and put them in :library-path."
(:require [lancet.core :as lancet])
(:require [lancet.core :as lancet]
[clojure.string :as string])
(:use [leiningen.core :only [repositories-for user-settings
*current-task* no-dev?]]
[leiningen.clean :only [clean]]
Expand Down Expand Up @@ -109,12 +110,13 @@
(.toString (BigInteger. 1 (-> (MessageDigest/getInstance "SHA1")
(.digest (.getBytes content)))) 16))

(defn- deps-checksum [project]
(sha1-digest (pr-str [(:dependencies project)
(:dev-dependencies project)])))
(defn- deps-checksum
([project keys] (sha1-digest (pr-str (map project keys))))
([project] (deps-checksum project [:dependencies :dev-dependencies])))

(defn- new-deps-checksum-file [project]
(File. (:root project) ".lein-deps-sum"))
(defn- new-deps-checksum-file
([project name] (File. (:root project) name))
([project] (new-deps-checksum-file project ".lein-deps-sum")))

(defn- has-dependencies? [project]
(some (comp seq project) [:dependencies :dev-dependencies]))
Expand Down Expand Up @@ -184,11 +186,25 @@
(.mkdirs f)
(copy (.getInputStream jar entry) f)))))

(defn download-plugins [project]
(let [dir (.getAbsolutePath (file (:root project) ".lein-plugins"))]
(when (and (seq (:plugins project))
(or (not (.exists (file dir "checksum")))
(not= (deps-checksum project [:plugins])
(slurp (file dir "checksum")))))
(.setContextClassLoader (Thread/currentThread) (doto classloader prn))
(doseq [plugin (-> (do-deps (assoc project :library-path dir) :plugins)
.getDirectoryScanner .getIncludedFiles)]
#_(clojure.lang.RT/addURL (str "file://" dir "/" plugin)))
(spit (file dir "checksum")
(deps-checksum project [:plugins])))))

(defn deps
"Download :dependencies and put them in :library-path."
[project & [skip-dev]]
(when skip-dev
(println "WARNING: passing an argument to deps is deprecated."))
(download-plugins project)
(when (fetch-deps? project)
(when-not (or (:disable-deps-clean project)
(:disable-implicit-clean project))
Expand Down
3 changes: 2 additions & 1 deletion src/leiningen/jar.clj
Expand Up @@ -35,7 +35,8 @@
([{:keys [group name version]}]
(unix-path (format
"%s/%s/%s/%s/%s-%s.jar"
(.getBasedir (make-local-repo)) (.replace group "." "/") name version name version))))
(.getBasedir (make-local-repo))
(.replace group "." "/") name version name version))))

(defn- script-classpath-for [project deps-fileset system]
(let [deps (when deps-fileset
Expand Down

0 comments on commit d3dca71

Please sign in to comment.