Embed version string from leiningen project in application

前端 未结 5 1021
执念已碎
执念已碎 2020-12-16 16:44

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,

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 17:20

    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
    

提交回复
热议问题