Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Last active December 13, 2017 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pesterhazy/645862253e1bb4d309edee5d25dc7a02 to your computer and use it in GitHub Desktop.
Save pesterhazy/645862253e1bb4d309edee5d25dc7a02 to your computer and use it in GitHub Desktop.
Including a build number in Clojure using boot
;; core.clj
(defn version []
(or (some-> "version.txt" clojure.java.io/resource slurp clojure.string/trim)
"unknown"))
;; build.boot
(defn get-version []
(or (System/getenv "CIRCLE_SHA1") "SNAPSHOT"))
(deftask add-version-txt
"Add a file called version.txt to the fileset, for inclusion in the jar"
[]
(with-pre-wrap fs
(let [t (tmp-dir!)]
(spit (clojure.java.io/file t "version.txt") (get-version))
(-> fs (add-resource t) commit!))))
(deftask dist ;; this is just an example - adapt your `dist` task
(comp
(pom :project 'example
:version (get-version))
(add-version-txt)
(uber)
(aot :namespace '#{example.core})
(jar :main 'example.core,
:file "example.jar")
(target :dir #{"target"})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment