Browse files

Ensure explicit deps calls override :checksum-deps.

  • Loading branch information...
1 parent 32ebf41 commit 7c067a5e3334e7160bebc2cb5cff0aa597adc532 @technomancy committed Nov 11, 2011
Showing with 28 additions and 7 deletions.
  1. +6 −3 src/leiningen/core.clj
  2. +4 −2 src/leiningen/deps.clj
  3. +18 −2 test/leiningen/test/deps.clj
View
9 src/leiningen/core.clj
@@ -186,6 +186,8 @@ Warning: alpha; subject to change."
;;; Task execution
+(def ^{:dynamic true} *current-task* nil)
+
(def aliases (atom {"--help" "help" "-h" "help" "-?" "help" "-v" "version"
"--version" "version" "überjar" "uberjar" "cp" "classpath"
"int" "interactive"}))
@@ -251,9 +253,10 @@ Warning: alpha; subject to change."
(defn apply-task [task-name project args not-found]
(let [task (resolve-task task-name not-found)]
(if-let [parameters (matching-arity? task-name project args)]
- (if (project-accepted? parameters)
- (apply task project args)
- (apply task args))
+ (binding [*current-task* task-name]
+ (if (project-accepted? parameters)
+ (apply task project args)
+ (apply task args)))
(let [args (arglists task-name)]
(if (and (not project) (project-needed? args))
(abort "Couldn't find project.clj, which is needed for" task-name)
View
6 src/leiningen/deps.clj
@@ -1,7 +1,8 @@
(ns leiningen.deps
"Download all dependencies and put them in :library-path."
(:require [lancet.core :as lancet])
- (:use [leiningen.core :only [repositories-for user-settings no-dev?]]
+ (:use [leiningen.core :only [repositories-for user-settings
+ *current-task* no-dev?]]
[leiningen.clean :only [clean]]
[leiningen.util.maven :only [make-dependency]]
[leiningen.util.file :only [delete-file-recursively]]
@@ -121,7 +122,8 @@
(defn fetch-deps? [project]
(let [deps-checksum-file (new-deps-checksum-file project)]
(and (has-dependencies? project)
- (or (empty? (.list (File. (:library-path project))))
+ (or (= "deps" *current-task*)
+ (empty? (.list (File. (:library-path project))))
(not (:checksum-deps project (:checksum-deps (user-settings))))
(not (.exists deps-checksum-file))
(not= (slurp deps-checksum-file) (deps-checksum project))))))
View
20 test/leiningen/test/deps.clj
@@ -1,6 +1,6 @@
(ns leiningen.test.deps
- (:use [leiningen.core :only [read-project defproject]]
- [leiningen.deps :only [deps]]
+ (:use [leiningen.core :only [read-project defproject apply-task]]
+ [leiningen.deps :only [deps do-deps]]
[clojure.test]
[clojure.java.io :only [file]]
[leiningen.util.file :only [delete-file-recursively]]
@@ -95,3 +95,19 @@
(is (= (conj (get-in native-lib-files-map [(get-os) (get-arch)]) ".gitkeep")
(set (for [f (rest (file-seq (native-arch-path native-project)))]
(.getName f))))))
+
+(deftest test-checksum-deps
+ (delete-file-recursively (:library-path sample-project) true)
+ (deps (assoc sample-project :checksum-deps true))
+ (let [deps-ran (atom false)]
+ (binding [do-deps (fn [& _] (reset! deps-ran true))]
+ (deps (assoc sample-project :checksum-deps true))
+ (is (not @deps-ran)))))
+
+(deftest test-explicit-checksum-deps
+ (delete-file-recursively (:library-path sample-project) true)
+ (deps (assoc sample-project :checksum-deps true))
+ (let [deps-ran (atom false)]
+ (binding [do-deps (fn [& _] (reset! deps-ran true))]
+ (apply-task "deps" (assoc sample-project :checksum-deps true) [] #())
+ (is @deps-ran))))

0 comments on commit 7c067a5

Please sign in to comment.