Added support for :exact-lein-version.
This commit is contained in:
parent
20922b067a
commit
fefe94d124
3 changed files with 33 additions and 0 deletions
|
@ -348,6 +348,21 @@ These get replaced with the corresponding values from the project map."
|
||||||
(.load reader))
|
(.load reader))
|
||||||
(.getProperty "version")))))
|
(.getProperty "version")))))
|
||||||
|
|
||||||
|
(def ^:private exact-version-error
|
||||||
|
"This project has :exact-lein-version set to \"%s\", while you have %s.")
|
||||||
|
|
||||||
|
(defn versions-match? [v1 v2]
|
||||||
|
(let [v1 (string/trim (first (string/split v1 #"-" 2)))
|
||||||
|
v2 (string/trim (first (string/split v2 #"-" 2)))]
|
||||||
|
(= v1 v2)))
|
||||||
|
|
||||||
|
(defn- verify-exact-version
|
||||||
|
[{:keys [exact-lein-version]}]
|
||||||
|
(when-not (versions-match? exact-lein-version (leiningen-version))
|
||||||
|
(abort (format exact-version-error
|
||||||
|
exact-lein-version
|
||||||
|
(leiningen-version)))))
|
||||||
|
|
||||||
(defn version-satisfies? [v1 v2]
|
(defn version-satisfies? [v1 v2]
|
||||||
(let [v1 (map #(Integer. %) (re-seq #"\d+" (first (string/split v1 #"-" 2))))
|
(let [v1 (map #(Integer. %) (re-seq #"\d+" (first (string/split v1 #"-" 2))))
|
||||||
v2 (map #(Integer. %) (re-seq #"\d+" (first (string/split v2 #"-" 2))))]
|
v2 (map #(Integer. %) (re-seq #"\d+" (first (string/split v2 #"-" 2))))]
|
||||||
|
@ -415,6 +430,7 @@ intentional please see `lein help faq` for details."))
|
||||||
(let [project (if (.exists (io/file *cwd* "project.clj"))
|
(let [project (if (.exists (io/file *cwd* "project.clj"))
|
||||||
(project/read (str (io/file *cwd* "project.clj")))
|
(project/read (str (io/file *cwd* "project.clj")))
|
||||||
(default-project))]
|
(default-project))]
|
||||||
|
(when (:exact-lein-version project) (verify-exact-version project))
|
||||||
(when (:min-lein-version project) (verify-min-version project))
|
(when (:min-lein-version project) (verify-min-version project))
|
||||||
(configure-http)
|
(configure-http)
|
||||||
(resolve-and-apply project raw-args))
|
(resolve-and-apply project raw-args))
|
||||||
|
|
|
@ -91,6 +91,18 @@
|
||||||
["one-or-two" "clojure" "2"] ["3"]
|
["one-or-two" "clojure" "2"] ["3"]
|
||||||
["fixed-and-var-args" "one"] []))
|
["fixed-and-var-args" "one"] []))
|
||||||
|
|
||||||
|
(deftest test-versions-match
|
||||||
|
(is (versions-match? "1.2.12" "1.2.12"))
|
||||||
|
(is (versions-match? "3.0" "3.0"))
|
||||||
|
(is (versions-match? " 12.1.2" "12.1.2 "))
|
||||||
|
(is (not (versions-match? "1.2" "1.3")))
|
||||||
|
(is (not (versions-match? "1.2.0" "1.2")))
|
||||||
|
(is (not (versions-match? "1.2" "1.2.0")))
|
||||||
|
(is (versions-match? "2.1.3-SNAPSHOT" "2.1.3"))
|
||||||
|
(is (versions-match? " 2.1.3-SNAPSHOT" "2.1.3"))
|
||||||
|
(is (versions-match? "2.1.3" "2.1.3-FOO"))
|
||||||
|
(is (not (versions-match? "3.0.0" "3.0.1-BAR"))))
|
||||||
|
|
||||||
(deftest test-version-satisfies
|
(deftest test-version-satisfies
|
||||||
(is (version-satisfies? "1.5.0" "1.4.2"))
|
(is (version-satisfies? "1.5.0" "1.4.2"))
|
||||||
(is (not (version-satisfies? "1.4.2" "1.5.0")))
|
(is (not (version-satisfies? "1.4.2" "1.5.0")))
|
||||||
|
|
|
@ -36,6 +36,11 @@
|
||||||
;; relies on features only found in newer Leiningen versions.
|
;; relies on features only found in newer Leiningen versions.
|
||||||
:min-lein-version "2.0.0"
|
:min-lein-version "2.0.0"
|
||||||
|
|
||||||
|
;; You can require a specific version of Leiningen. In case of mismatch
|
||||||
|
;; execution will abort. When versions are compared, suffixes such as
|
||||||
|
;; "-SNAPSHOT" are dropped.
|
||||||
|
;; :exact-lein-version "2.8.2"
|
||||||
|
|
||||||
;;; Dependencies, Plugins, and Repositories
|
;;; Dependencies, Plugins, and Repositories
|
||||||
;; Dependencies are listed as [group-id/name version]; in addition
|
;; Dependencies are listed as [group-id/name version]; in addition
|
||||||
;; to keywords supported by Pomegranate, you can use :native-prefix
|
;; to keywords supported by Pomegranate, you can use :native-prefix
|
||||||
|
|
Loading…
Reference in a new issue