Last active
December 13, 2017 10:50
-
-
Save pesterhazy/645862253e1bb4d309edee5d25dc7a02 to your computer and use it in GitHub Desktop.
Including a build number in Clojure using boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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