Skip to content

Instantly share code, notes, and snippets.

@gleenn
Created March 24, 2017 20:31
Show Gist options
  • Save gleenn/a8a604ebfa807bcd2a8c3341b3573657 to your computer and use it in GitHub Desktop.
Save gleenn/a8a604ebfa807bcd2a8c3341b3573657 to your computer and use it in GitHub Desktop.
add Git SHA to uberjar for Leiningen which can be read at runtime
; Add this to your :profile section in your project.clj:
:uberjar {:aot [spark.core]
:injections [(require '[clojure.java.shell :as shell])
(spit "resources/version.txt"
(clojure.string/trimr
(:out
(shell/sh "git" "rev-parse" "HEAD"))))]}
; You can read the file during runtime like this:
(if-let [resource (clojure.java.io/resource "version.txt")]
(prn (slurp resource)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment