diff --git a/leiningen-core/src/leiningen/core/project.clj b/leiningen-core/src/leiningen/core/project.clj index 0cba0089e..c09922f36 100644 --- a/leiningen-core/src/leiningen/core/project.clj +++ b/leiningen-core/src/leiningen/core/project.clj @@ -34,7 +34,7 @@ (defn- update-each-contained [m keys f & args] (reduce (fn [m k] (if (contains? m k) - (apply update-in m [k] f args) + (apply update m k f args) m)) m keys)) (defn- update-first [coll pred f] diff --git a/leiningen-core/src/leiningen/core/utils.clj b/leiningen-core/src/leiningen/core/utils.clj index f486e81ac..5181dd9a0 100644 --- a/leiningen-core/src/leiningen/core/utils.clj +++ b/leiningen-core/src/leiningen/core/utils.clj @@ -204,3 +204,11 @@ (cons x (step (rest s) (conj seen fx))))))) xs seen)))] (reverse (step (reverse coll) #{})))) + +(defn ancestor? + "Is a an ancestor of b?" + [a b] + (let [hypothetical-ancestor (.getCanonicalPath (io/file a)) + hypothetical-descendant (.getCanonicalPath (io/file b))] + (and (.startsWith hypothetical-descendant hypothetical-ancestor) + (not (= hypothetical-descendant hypothetical-ancestor))))) diff --git a/leiningen-core/test/leiningen/core/test/classpath.clj b/leiningen-core/test/leiningen/core/test/classpath.clj index 02bbc18c7..594b14b16 100644 --- a/leiningen-core/test/leiningen/core/test/classpath.clj +++ b/leiningen-core/test/leiningen/core/test/classpath.clj @@ -76,7 +76,7 @@ (.mkdirs d1) (spit (io/file d1 "project.clj") (pr-str '(defproject hello "1.0"))) - (is (= (for [path ["src" "dev-resources" "resources" + (is (= (for [path ["src" "dev-resources" "resources" "target/classes" "foo"]] (lthelper/pathify (format "/tmp/lein-sample-project/checkouts/d1/%s" path))) (#'leiningen.core.classpath/checkout-deps-paths project))) diff --git a/project.clj b/project.clj index 36b7e4acd..2ab29bcc7 100644 --- a/project.clj +++ b/project.clj @@ -34,9 +34,7 @@ cemerick.pomegranate classlojure.core clojure.tools.nrepl - clj-http.core - ;; to avoid compile warnings at runtime: - clj-http.client]}} + clj-http.core]}} :test-selectors {:default (complement :disabled) :offline (comp (partial not-any? identity) (juxt :online :disabled))} diff --git a/src/leiningen/clean.clj b/src/leiningen/clean.clj index 9fd6f18c7..0170a95bc 100644 --- a/src/leiningen/clean.clj +++ b/src/leiningen/clean.clj @@ -25,14 +25,6 @@ (.setWritable f true) (io/delete-file f silently))) -(defn- ancestor? - "Is a an ancestor of b?" - [a b] - (let [hypothetical-ancestor (.getCanonicalPath (io/file a)) - hypothetical-descendant (.getCanonicalPath (io/file b))] - (and (.startsWith hypothetical-descendant hypothetical-ancestor) - (not (= hypothetical-descendant hypothetical-ancestor))))) - (defn- protected-paths "Returns a set of leiningen project source directories and important files." [project] @@ -52,7 +44,7 @@ [project path] (let [protected-paths (protected-paths project)] (or (protected-paths (.getCanonicalPath (io/file path))) - (some #(ancestor? % path) protected-paths)))) + (some #(utils/ancestor? % path) protected-paths)))) (defn- protect-clean-targets? "Returns the value of :protect in the metadata map for the :clean-targets @@ -72,7 +64,7 @@ [project clean-target] (when (and (string? clean-target) (protect-clean-targets? project)) - (cond (not (ancestor? (:root project) clean-target)) + (cond (not (utils/ancestor? (:root project) clean-target)) (main/abort (error-msg "Deleting path outside of the project root [\"" clean-target "\"] is not allowed.")) (protected-path? project clean-target) diff --git a/src/leiningen/update_in.clj b/src/leiningen/update_in.clj index 54ee43f27..164fbb195 100644 --- a/src/leiningen/update_in.clj +++ b/src/leiningen/update_in.clj @@ -14,11 +14,9 @@ task+args])) (defn ^:internal update-project [project keys-vec f args] - (let [f #(apply apply (concat (if (seq keys-vec) - [clj/update-in % keys-vec f] - [f %]) - args - [nil]))] + (let [f #(if (seq keys-vec) + (apply clj/update-in % keys-vec f args) + (apply f % args))] (-> (vary-meta (f project) clj/update-in [:without-profiles] f) (project/load-plugins) (project/activate-middleware))))