defproject throws an exception on duplicate keys

This commit is contained in:
Peter Garbers 2014-05-22 02:49:01 +02:00
parent 051ec98f10
commit 98d113374f

View file

@ -350,11 +350,19 @@
:repositories repos :repositories repos
:plugin-repositories repos))))) :plugin-repositories repos)))))
(defn- argument-list->argument-map
[args]
(let [keys (filter keyword? args)
unique-keys (set keys)]
(if (= (count keys) (count unique-keys))
(apply hash-map args)
(throw (IllegalArgumentException. "Duplicate Key")))))
(defmacro defproject (defmacro defproject
"The project.clj file must either def a project map or call this macro. "The project.clj file must either def a project map or call this macro.
See `lein help sample` to see what arguments it accepts." See `lein help sample` to see what arguments it accepts."
[project-name version & {:as args}] [project-name version & args]
`(let [args# ~(unquote-project args) `(let [args# ~(unquote-project (argument-list->argument-map args))
root# ~(.getParent (io/file *file*))] root# ~(.getParent (io/file *file*))]
(def ~'project (def ~'project
(make args# '~project-name ~version root#)))) (make args# '~project-name ~version root#))))