A simple tool for use with tools.deps and the clojure command line
tools, to update a pom.xml
file with overriden values provided by
either :exec-args
data or via the command line.
It is suitable for clojure -X
invocation and usage as a small
library.
It is hoped that this library will soon be made redundant by
tools.build
a rumoured build tool by the Clojure core team.
What should I use this for?
Automatically updating metadata in a Clojure libraries pom.xml
,
typically setting the maven version and scm tag to a build number
provided by your CI system.
Can't I just use clojure -Spom
or clojure -X:deps mvn-pom
?
Yes if you don't mind manually deploying library changes and setting the version number yourself.
If you want to automate the deployment to deploy your clojure library
with a version number determined by CI (e.g. the BUILD_ID
or a
commit SHA) then you probably want to use this simple tool to assist.
Tools deps almost has the functionality to do this, however with
tools.build
on the horizon it's not a feature they care to
prioritise.
Add rickmoynihan/pom-update {:mvn/version "0.1.6"}
to an appropriate
alias in your deps.edn
, e.g.
{:deps { ,,, ,,, }
:aliases {
:update-version {
:extra-deps {rickmoynihan/pom-update {:mvn/version "0.1.6"}}
:exec-fn rickmoynihan.pom/update
:exec-args {:pom/write-strategy :overwrite
:pom/input-file "pom.xml"}}}}
Then at build time, prior to creating a jar for your library run the following command:
clojure -X:update-version :mvn/version "\"$BUILD_NUMBER\"" :scm/tag "\"$BUILD_NUMBER\""
You may also wish to automate calling clojure -X:deps mvn-pom
prior
to the above call (to ensure dependencies etc are synced properly from
deps.edn
into pom.xml
). If you don't do this you'll need to make
sure you commit pom.xml
after each meaningful update to your
deps.edn
.
This library is intended to work with depstar for building library jars, and deps-deploy for deploying them to either clojars or a private maven repository.
Copyright © 2020 Rick Moynihan
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.