From ae3735684572b613d21e78ac7aed2e87a5d6133b Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Wed, 22 Feb 2012 16:43:17 -0800 Subject: [PATCH] Update tasks to use plural paths. Use :resource-paths instead of resources. --- .../src/leiningen/core/classpath.clj | 4 ++-- leiningen-core/src/leiningen/core/project.clj | 4 ++-- .../test/leiningen/core/test/classpath.clj | 2 +- .../test/leiningen/core/test/project.clj | 24 +++++++++---------- src/leiningen/check.clj | 2 +- src/leiningen/compile.clj | 16 ++++++------- src/leiningen/jar.clj | 6 ++--- src/leiningen/javac.clj | 4 ++-- src/leiningen/pom.clj | 8 +++---- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/leiningen-core/src/leiningen/core/classpath.clj b/leiningen-core/src/leiningen/core/classpath.clj index efbcc3eb..d4974770 100644 --- a/leiningen-core/src/leiningen/core/classpath.clj +++ b/leiningen-core/src/leiningen/core/classpath.clj @@ -16,7 +16,7 @@ (defn- checkout-dep-paths [project dep dep-project] (concat (:source-paths dep-project) - (:resources-paths dep-project) + (:resource-paths dep-project) [(:compile-path dep-project)])) (defn- checkout-deps-paths @@ -68,7 +68,7 @@ [project] (for [path (concat (:test-paths project) (:source-paths project) - (:resources-paths project) + (:resource-paths project) [(:compile-path project)] (checkout-deps-paths project) (map #(.getAbsolutePath %) (resolve-dependencies project))) diff --git a/leiningen-core/src/leiningen/core/project.clj b/leiningen-core/src/leiningen/core/project.clj index 33cf7cfd..22a22b3c 100755 --- a/leiningen-core/src/leiningen/core/project.clj +++ b/leiningen-core/src/leiningen/core/project.clj @@ -22,7 +22,7 @@ args)) (def defaults {:source-paths ["src"] - :resources-paths ["resources"] + :resource-paths ["resources"] :test-paths ["test"] :native-path "native" :compile-path "target/classes" @@ -89,7 +89,7 @@ (def default-profiles "Profiles get merged into the project map. The :dev and :user profiles are active by default." - (atom {:default {:resources-paths ["dev-resources"]} + (atom {:default {:resource-paths ["dev-resources"]} :test {} :debug {:debug true}})) diff --git a/leiningen-core/test/leiningen/core/test/classpath.clj b/leiningen-core/test/leiningen/core/test/classpath.clj index 60ec8503..7fec34dc 100644 --- a/leiningen-core/test/leiningen/core/test/classpath.clj +++ b/leiningen-core/test/leiningen/core/test/classpath.clj @@ -14,7 +14,7 @@ :repositories (:repositories project/defaults) :root "/tmp/lein-sample-project" :source-paths ["/tmp/lein-sample-project/src"] - :resources-paths ["/tmp/lein-sample-project/resources"] + :resource-paths ["/tmp/lein-sample-project/resources"] :test-paths ["/tmp/lein-sample-project/test"]}) (deftest test-resolve-deps diff --git a/leiningen-core/test/leiningen/core/test/project.clj b/leiningen-core/test/leiningen/core/test/project.clj index 6b67bff4..b07cd6f7 100755 --- a/leiningen-core/test/leiningen/core/test/project.clj +++ b/leiningen-core/test/leiningen/core/test/project.clj @@ -12,7 +12,7 @@ (def paths {:source-paths ["src"], :test-paths ["test"], - :resources-paths ["dev-resources" "resources"], + :resource-paths ["dev-resources" "resources"], :compile-path "classes", :native-path "native", :target-path "target"}) @@ -49,25 +49,25 @@ ;; TODO: test omit-default ;; TODO: test reading project that doesn't def project -(def test-profiles (atom {:qa {:resources-paths ["/etc/myapp"]} - :test {:resources-paths ["test/hi"]} +(def test-profiles (atom {:qa {:resource-paths ["/etc/myapp"]} + :test {:resource-paths ["test/hi"]} :tes :test :dev {:test-paths ["test"]}})) (deftest test-merge-profile-paths (with-redefs [default-profiles test-profiles] (is (= ["/etc/myapp" "test/hi" "blue-resources" "resources"] - (-> {:resources-paths ["resources"] - :profiles {:blue {:resources-paths ["blue-resources"]}}} + (-> {:resource-paths ["resources"] + :profiles {:blue {:resource-paths ["blue-resources"]}}} (merge-profiles [:qa :tes :blue]) - :resources-paths))) + :resource-paths))) (is (= ["/etc/myapp" "test/hi" "blue-resources"] - (-> {:resources-paths ^:displace ["resources"] - :profiles {:blue {:resources-paths ["blue-resources"]}}} + (-> {:resource-paths ^:displace ["resources"] + :profiles {:blue {:resource-paths ["blue-resources"]}}} (merge-profiles [:qa :tes :blue]) - :resources-paths))) + :resource-paths))) (is (= ["replaced"] - (-> {:resources-paths ["resources"] - :profiles {:blue {:resources-paths ^:replace ["replaced"]}}} + (-> {:resource-paths ["resources"] + :profiles {:blue {:resource-paths ^:replace ["replaced"]}}} (merge-profiles [:blue :qa :tes]) - :resources-paths))))) + :resource-paths))))) diff --git a/src/leiningen/check.clj b/src/leiningen/check.clj index 51a34fe9..ddb9b4f3 100644 --- a/src/leiningen/check.clj +++ b/src/leiningen/check.clj @@ -6,7 +6,7 @@ (defn check "Check syntax and warn on reflection." ([project] - (let [nses (mapcat ns/namespaces-in-dir (:source-path project)) + (let [nses (mapcat ns/namespaces-in-dir (:source-paths project)) action `(doseq [ns# '~nses] ;; load will add the .clj, so can't use ns/path-for. (let [ns-file# (-> (str ns#) diff --git a/src/leiningen/compile.clj b/src/leiningen/compile.clj index 7a9aa972..dba99189 100644 --- a/src/leiningen/compile.clj +++ b/src/leiningen/compile.clj @@ -13,14 +13,14 @@ (defn- find-namespaces-by-regex [project nses] (let [[res syms] ((juxt filter remove) regex? nses)] (if (seq res) - (set (for [re res n (mapcat ns/namespaces-in-dir (:source-path project)) + (set (for [re res n (mapcat ns/namespaces-in-dir (:source-paths project)) :when (re-find re (name n))] n)) nses))) -(defn- compile-main? [{:keys [main source-path] :as project}] +(defn- compile-main? [{:keys [main source-paths] :as project}] (and main (not (:skip-aot (meta main))) - (some #(.exists (io/file % (ns/path-for main))) source-path))) + (some #(.exists (io/file % (ns/path-for main))) source-paths))) (defn compilable-namespaces "Returns a seq of the namespaces that are compilable, regardless of whether @@ -28,7 +28,7 @@ [project] (let [nses (:aot project) nses (if (= :all nses) - (mapcat ns/namespaces-in-dir (:source-path project)) + (mapcat ns/namespaces-in-dir (:source-paths project)) (find-namespaces-by-regex project nses))] (if (compile-main? project) (conj nses (:main project)) @@ -44,7 +44,7 @@ class-file (io/file (:compile-path project) (.replace clj-path "\\.clj" "__init.class"))] (or (not (.exists class-file)) - (> (.lastModified (io/file (:source-path project) clj-path)) + (> (.lastModified (io/file (:source-paths project) clj-path)) (.lastModified class-file))))) (compilable-namespaces project))) @@ -63,11 +63,11 @@ ;; source-path)))))) ;; (defn- class-in-project? [project f] -;; (or (has-source-package? project f (:source-path project)) -;; (has-source-package? project f (:java-source-path project)) +;; (or (has-source-package? project f (:source-paths project)) +;; (has-source-package? project f (:java-source-paths project)) ;; (.exists (io/file (str (.replace (.getParent f) ;; (:compile-path project) -;; (:source-path project)) ".clj"))))) +;; (:source-paths project)) ".clj"))))) ;; (defn- relative-path [project f] ;; (let [root-length (if (= \/ (last (:compile-path project))) diff --git a/src/leiningen/jar.clj b/src/leiningen/jar.clj index df525afa..ef3bc523 100644 --- a/src/leiningen/jar.clj +++ b/src/leiningen/jar.clj @@ -153,10 +153,10 @@ {:type :bytes :path "project.clj" :bytes (.getBytes (slurp (str (:root project) "/project.clj")))}] [{:type :path :path (:compile-path project)} - {:type :paths :paths (:resources-path project)}] + {:type :paths :paths (:resource-paths project)}] (if-not (:omit-source project) - [{:type :paths :paths (:source-path project)} - {:type :paths :paths (:java-source-path project)}]) + [{:type :paths :paths (:source-paths project)} + {:type :paths :paths (:java-source-paths project)}]) (if-let [jar-inclusions (:jar-inclusions project)] [{:type :paths :paths jar-inclusions}]) ;; (shell-wrapper-filespecs project deps-fileset) diff --git a/src/leiningen/javac.clj b/src/leiningen/javac.clj index f85785de..3627b1dd 100644 --- a/src/leiningen/javac.clj +++ b/src/leiningen/javac.clj @@ -35,7 +35,7 @@ (defn- run-javac-task "Run javac to compile all source files in the project." [project args] - (let [files (mapcat extract-java-source (:java-source-path project)) + (let [files (mapcat extract-java-source (:java-source-paths project)) compile-path (:compile-path project)] (when (pos? (count files)) (println "Compiling" (count files) "source files to" compile-path) @@ -47,7 +47,7 @@ (defn javac "Compile Java source files. -Add a :java-source-path key to project.clj to specify where to find them. +Add a :java-source-paths key to project.clj to specify where to find them. Any options passed will be given to javac. One place where this can be useful is `lein javac -verbose`." [project & args] diff --git a/src/leiningen/pom.clj b/src/leiningen/pom.clj index b5d9dbe8..13cc389d 100644 --- a/src/leiningen/pom.clj +++ b/src/leiningen/pom.clj @@ -131,16 +131,16 @@ (defmethod xml-tags ::build ([_ project] (let [dev-project (project/merge-profiles project [:dev]) - [src & extra-src] (:source-path project) - [test & extra-test] (:test-path dev-project)] + [src & extra-src] (:source-paths project) + [test & extra-test] (:test-paths dev-project)] [:build [:sourceDirectory src] [:testSourceDirectory test] - (if-let [resources (:resources-path project)] + (if-let [resources (:resource-paths project)] (when (not (empty? resources)) (vec (concat [:resources] (map (fn [x] [:resource [:directory x]]) resources))))) - (if-let [resources (:resources-path dev-project)] + (if-let [resources (:resource-paths dev-project)] (when (not (empty? resources)) (vec (concat [:testResources] (map (fn [x] [:testResource [:directory x]]) resources)))))