I want to be able to query or embed the version string set by the leiningen project and display that value to user. Uses include displaying the version string from the CLI,
Here is how I read my project name and version, note that the project.clj
file is read during compilation and jar file simply contains the string:
(defmacro proj-version []
(some->> (slurp "project.clj") clojure.edn/read-string (drop 1) (take 2) (str/join " ")))
(defn -main []
(println (proj-version))
so for (defproject abc "1.2.3" ...
, when you run -main
it will print:
abc 1.2.3