with tools build, we can add a version to the jar when building it, but is there a recommended way to go about pulling that version from the (uber)jar file that is being run? I would like to track versions via the jar's pom.xml vs trying to keep things in sync with version tags and ensure the version is set from the tags via an environment variable or other mechanism. Main example usage would be add the running jar's version to log context, as well as system history events/metadata (e.g. this was done by version x.y.z)
you could create a resource (text file) in the jar with the version string. This is, for example, how Clojure's *clojure-version* works - the build creates a file clojure/version.properties which is read when clojure.core is loaded and then parsed into data returned by *clojure-version*
strongly recommended not to pollute the top-level with the resource, put it in a subdir that you "control" like your code
from a tools.build perspective, this is just spit of the version to the resource in the directory you are jarring from
Yeah, I had thought of something like a spit to an EDN file, but wanted to check if there were any general conventions around app version availability from both a larger community and operational interoperability perspectives.
maven will put a pom.xml at META-INF/maven/{groupId}/{artifactId}/pom.xml Leiningen will add a simpler pom.properties file version with a version= entry. See "how do I determine my project's version at runtime?" in the https://leiningen.org/faq.html. These are the conventions for this sort of thing that I am aware of
I wouldn’t rely on that personally in case you change your build process