Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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