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
: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
"The project.clj file must either def a project map or call this macro.
See `lein help sample` to see what arguments it accepts."
[project-name version & {:as args}]
`(let [args# ~(unquote-project args)
[project-name version & args]
`(let [args# ~(unquote-project (argument-list->argument-map args))
root# ~(.getParent (io/file *file*))]
(def ~'project
(make args# '~project-name ~version root#))))