Liking cljdoc? Tell your friends :D

build-provenance.write

Build-time helper: emit META-INF/<group>/<artifact>/build-provenance.edn alongside compiled classes, capturing git provenance metadata.

Intended usage from a tools.build build.clj, immediately before b/jar:

(require '[build-provenance.write :as bp])

(bp/write! {:lib       'com.example/my-library
            :version   "1.2.3"
            :class-dir "target/classes"})

Emits target/classes/META-INF/com.example/my-library/build-provenance.edn, which b/jar then packs into the resulting JAR.

Best-effort: if git is unavailable on PATH, the project is not a git working tree, or HEAD is detached, unknowable string fields are emitted as nil and :dirty is conservatively true. The writer never throws on a git failure (only on programmer errors in the input map).

Build-time helper: emit META-INF/<group>/<artifact>/build-provenance.edn
alongside compiled classes, capturing git provenance metadata.

Intended usage from a tools.build build.clj, immediately before b/jar:

    (require '[build-provenance.write :as bp])

    (bp/write! {:lib       'com.example/my-library
                :version   "1.2.3"
                :class-dir "target/classes"})

Emits target/classes/META-INF/com.example/my-library/build-provenance.edn,
which b/jar then packs into the resulting JAR.

Best-effort: if git is unavailable on PATH, the project is not a git
working tree, or HEAD is detached, unknowable string fields are emitted
as nil and :dirty is conservatively true. The writer never throws on a
git failure (only on programmer errors in the input map).
raw docstring

collectclj

(collect {:keys [lib version]})

Return a build-provenance map for the given lib + version. No I/O on target — caller decides where to write. Useful for reuse from non-build contexts (e.g. babashka scripts).

Throws on programmer errors: :lib must be a qualified symbol like 'group/artifact, :version must be a string.

Return a build-provenance map for the given lib + version. No I/O on
target — caller decides where to write. Useful for reuse from non-build
contexts (e.g. babashka scripts).

Throws on programmer errors: :lib must be a qualified symbol like
'group/artifact, :version must be a string.
sourceraw docstring

resource-pathclj

(resource-path lib)
(resource-path lib fmt)

Return the per-artifact resource path for build provenance. fmt is :edn (default) or :json. Public so callers can locate the resource themselves (e.g. for tests or alternative I/O).

Return the per-artifact resource path for build provenance. fmt is :edn
(default) or :json. Public so callers can locate the resource themselves
(e.g. for tests or alternative I/O).
sourceraw docstring

write!clj

(write! {:keys [lib class-dir] :as opts})

Collect git provenance and write two parallel resource files under class-dir:

META-INF/<group>/<artifact>/build-provenance.edn   (canonical Clojure shape, kebab-case keys)
META-INF/<group>/<artifact>/build-provenance.json  (camelCase keys, for non-Clojure consumers)

Both are sourced from a single collect call, so the contents cannot drift. Returns a map {:edn <abs-path> :json <abs-path>}.

Required keys: :lib (qualified symbol), :version (string), :class-dir (string).

Collect git provenance and write two parallel resource files under
class-dir:

    META-INF/<group>/<artifact>/build-provenance.edn   (canonical Clojure shape, kebab-case keys)
    META-INF/<group>/<artifact>/build-provenance.json  (camelCase keys, for non-Clojure consumers)

Both are sourced from a single `collect` call, so the contents cannot
drift. Returns a map {:edn <abs-path> :json <abs-path>}.

Required keys: :lib (qualified symbol), :version (string),
:class-dir (string).
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close