Embed version string from leiningen project in application

前端 未结 5 1032
执念已碎
执念已碎 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:12

    Someone has written a nice library for handling this: https://github.com/trptcolin/versioneer

    It works for lein projects, both running in lein and from an uberjar. Use it like the following (taken from the Github page):

    Add this to your project.clj:

    [trptcolin/versioneer "0.2.0"]
    

    Then, in your code, do something like this, where GROUP-ID and ARTIFACT-ID are the usual Leiningen/Maven identifiers for your project.

    user=> (require '[trptcolin.versioneer.core :as version])
    nil
    user=> (version/get-version "GROUP-ID" "ARTIFACT-ID")
    "1.2.3-SNAPSHOT"
    

提交回复
热议问题