Skip to content

Commit c2b4083

Browse files
committed
OK, so relative paths in project maps was the wrong way to go.
1 parent 1fe2fed commit c2b4083

File tree

5 files changed

+50
-36
lines changed

5 files changed

+50
-36
lines changed

leiningen-core/src/leiningen/core/project.clj

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,19 @@
140140
(profiles-for project profiles-to-apply))
141141
{:without-profiles project}))
142142

143+
(defn- absolutize [root path]
144+
(if (coll? path) ; paths can be either strings or collections of strings
145+
(map (partial absolutize root) path)
146+
(str (io/file root path))))
147+
148+
(defn- absolutize-path [project key]
149+
(if (re-find #"-path$" (name key))
150+
(update-in project [key] (partial absolutize (:root project)))
151+
project))
152+
153+
(defn- absolutize-paths [project]
154+
(reduce absolutize-path project (keys project)))
155+
143156
(defn read
144157
"Read project map out of file, which defaults to project.clj."
145158
([file profiles]
@@ -149,6 +162,6 @@
149162
(when-not project
150163
(throw (Exception. "project.clj must define project map.")))
151164
(ns-unmap *ns* 'project) ; return it to original state
152-
(merge-profiles @project profiles)))
165+
(absolutize-paths (merge-profiles @project profiles))))
153166
([file] (read file [:dev :user]))
154167
([] (read "project.clj")))

leiningen-core/test/leiningen/core/test/project.clj

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,40 @@
1010
(with-redefs [user/plugins (constantly {})]
1111
(f))))
1212

13+
(def paths {:source-path ["src"],
14+
:test-path ["test"],
15+
:resources-path ["dev-resources" "resources"],
16+
:compile-path "classes",
17+
:native-path "native",
18+
:target-path "target"})
19+
20+
(def expected {:name "leiningen", :group "leiningen",
21+
:version "2.0.0-SNAPSHOT",
22+
:url "https://github.com/technomancy/leiningen"
23+
24+
:disable-implicit-clean true,
25+
:eval-in :leiningen,
26+
:license {:name "Eclipse Public License"}
27+
28+
:dependencies '[[leiningen-core "2.0.0-SNAPSHOT"]
29+
[clucy "0.2.2"] [lancet "1.0.1"]
30+
[robert/hooke "1.1.2"]
31+
[stencil "0.2.0"]],
32+
:twelve 12 ; testing unquote
33+
34+
:repositories [["central" {:url "http://repo1.maven.org/maven2"}]
35+
["clojars" {:url "http://clojars.org/repo/"}]]})
36+
1337
(deftest test-read-project
14-
(is (= {:name "leiningen", :group "leiningen", :version "2.0.0-SNAPSHOT",
15-
:url "https://github.com/technomancy/leiningen"
16-
17-
:source-path ["src"],
18-
:compile-path "classes",
19-
:test-path ["test"],
20-
:resources-path ["dev-resources" "resources"],
21-
:native-path "native",
22-
:target-path "target",
23-
24-
:disable-implicit-clean true,
25-
:eval-in :leiningen,
26-
:license {:name "Eclipse Public License"}
27-
28-
:dependencies '[[leiningen-core "2.0.0-SNAPSHOT"]
29-
[clucy "0.2.2"] [lancet "1.0.1"]
30-
[robert/hooke "1.1.2"]
31-
[stencil "0.2.0"]],
32-
:twelve 12 ; testing unquote
33-
34-
;; wtf, (= [#"^\."] [#"^\."]) <- false
35-
;; :jar-exclusions [#"^\."],
36-
;; :uberjar-exclusions [#"^META-INF/DUMMY.SF"],
37-
:repositories [["central" {:url "http://repo1.maven.org/maven2"}]
38-
["clojars" {:url "http://clojars.org/repo/"}]]}
39-
(dissoc (read "dev-resources/p1.clj")
40-
:description :root :jar-exclusions :uberjar-exclusions))))
38+
(let [actual (read "dev-resources/p1.clj")]
39+
(doseq [[k v] expected]
40+
(is (= (k actual) v)))
41+
(doseq [[k path] paths
42+
:when (string? path)]
43+
(is (= (k actual) (str (:root actual) "/" path))))
44+
(doseq [[k path] paths
45+
:when (coll? path)]
46+
(is (= (k actual) (for [p path] (str (:root actual) "/" p)))))))
4147

4248
;; TODO: test omit-default
4349
;; TODO: test reading project that doesn't def project

src/leiningen/deps.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
(doseq [jar (jar-files files)
4242
entry (enumeration-seq (.entries jar))
4343
:when (.startsWith (.getName entry) "native/")]
44-
(let [f (io/file (:root project) (:native-path project)
44+
(let [f (io/file (:native-path project)
4545
(subs (.getName entry) (count "native/")))]
4646
(if (.isDirectory entry)
4747
(.mkdirs f)

src/leiningen/test.clj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ each namespace and print an overall summary."
4949
nses (if (or (empty? args) (every? keyword? args))
5050
;; maybe this is stupid and all *-path entries should
5151
;; be absolute?
52-
(sort (apply concat (for [test-path (:test-path project)]
53-
(ns/namespaces-in-dir
54-
(io/file (:root project) test-path)))))
55-
56-
#_(mapcat (:test-path project))
52+
(sort (mapcat ns/namespaces-in-dir (:test-path project)))
5753
(filter symbol? args))
5854
selectors (map (merge {:all '(constantly true)}
5955
(:test-selectors project)) (filter keyword? args))

test/leiningen/test/deps.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
(deps native-project)
8585
(is (= (conj (get-in native-lib-files-map [(eval/get-os) (eval/get-arch)])
8686
".gitkeep")
87-
(set (for [f (rest (file-seq (io/file (:root native-project)
88-
(eval/native-arch-path
87+
(set (for [f (rest (file-seq (io/file (eval/native-arch-path
8988
native-project))))]
9089
(.getName f))))))

0 commit comments

Comments
 (0)