Skip to content

Conversation

@RickMoynihan
Copy link
Contributor

Implements #20

Extends PR #18 to support overriding a version number in a pom.xml. This allows CI systems etc to easily deploy an artifact with a generated build number, or for a version override to be supplied via the CLI when using :exec-fn



We rename the deploy multi-method to deploy* and consequently there is
a chance this may break any users who were extending this multimethod,
so we can wrap this with a new deploy function.

Also renames :clojars key to :remote to indicate the mechanism for
repositories is more generic than just clojars.
coordinates (coordinates-from-pom pom)
versioned-pom (spit (versioned-pom-filename coordinates) pom)]

(defn- tag-val-replacer [tag->val]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to prefer creating fns which take the required amount of args, and then rather bind the args using partial (to which I'm, ehrm, partial) or with an anon-fn #(replace-tag {version-tag [version] group-id-tag [group-id] ...} %)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Cool. I'm quite partial to doing things that way too ;-) it was even my first instinct, which I held back on because I figured it'd be bikeshedded the other way. Happy to change.

(defn- tag-val-replacer [tag->val]
(fn [{:keys [tag content attrs] :as el}]
(let [replacement-val (tag->val tag ::default)]
(if (= ::default replacement-val)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great use-case for cond->:

(cond-> el
   (not= ::default replacement-val) (assoc :content replacement-val))

It's almost like this is an update right?

(update el :content (fn [c] (if (= ::default replacement-val) c replacement-val)))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed it is. Will revise both of those. Thanks for caring.

versioned-pom (spit (versioned-pom-filename coordinates) pom)]

(defn- tag-val-replacer [tag->val]
(fn [{:keys [tag content attrs] :as el}]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attrs is not used?

Copy link
Owner

@slipset slipset left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some comments, I'm mostly concerned with making the higher-order tag-val-replacer into a normal fn.

@RickMoynihan
Copy link
Contributor Author

FYI I'm less sure about this PR belonging in deps-deploy, really it should be pushed into jar creation, or a pom phase prior to that.

I'll see if we can put this somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants