We want to add cache bursting of some assets/urls of our app based on the app version. So we need to be able to read the version from the
buid.boot file itself in our app.
No idea how to do it, reading the docs of boot doesn’t help me so far… Any pointer appreciated !
Not sure how to read it from boot but you could always generate a version file in resources and read that file.
Or if you can set the manifest Implementation-Version during build you can read the jar version via Java. That also requires :aot for the Clojure namespace.
If you use the
pom task to include a
pom.xml in the artifact, you can read it from there.
user> (require '[clojure.java.io :as io])
user> (require '[clojure.data.xml :refer :all])
user> (def xml-str (slurp (io/resource "META-INF/maven/my/project/pom.xml")))
user> (->> xml-str parse-str :content (filter #(= :version (:tag %))) first :content first)
Thanks guys, we went this way finally: create a dumb version.txt file in resources and read it both from build.boot (
(def version (slurp "version.txt")) and from our code. Simple enough.
Beware when using anything from the classpath with such a generic name. Should any library include a
version.txt it will be loaded before yours thus giving you the “wrong” version.
Always ensure to namespace everything on the classpath.