Update tasks to use plural paths. Use :resource-paths instead of resources.
This commit is contained in:
parent
74c264fa59
commit
ae37356845
9 changed files with 35 additions and 35 deletions
|
@ -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)))
|
||||
|
|
|
@ -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}}))
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)))))
|
||||
|
|
|
@ -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#)
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)))))
|
||||
|
|
Loading…
Reference in a new issue