Fork me on GitHub
#leiningen
<
2019-11-28
>
borkdude12:11:19

What's a better way of dealing with this problem?

borkdude12:11:36

I.e. I want to have the version number in some other location than project.clj, so I can use it for other tooling as well

borkdude12:11:56

So far this has worked, but now my linter is complaining about it 😉

borkdude12:11:13

I guess I could just use a templating script

sogaiu14:11:40

@borkdude by templating, do you mean generate project.clj?

mikerod22:11:11

@borkdude I tend to put stuff like that in a car before the defproject to avoid so much read-eval macro literal things happening.

mikerod22:11:07

Typed from a phone with autocorrect hah

borkdude22:11:12

oh I forgot you can do that in project.clj....

borkdude22:11:35

lol, that makes it a lot simpler

mikerod22:11:06

Yeah. I may not have a good example but I believe inline reader eval dispatches can have strange behavior with symbol resolution as well. So I tend to push as much as I can into “normal” code and then just refer to a var or call a fn from the reader dispatch form.

borkdude22:11:11

so:

(require '[clojure.string :as str])
(defn version [] (str/trim (slurp "resources/CLJ_KONDO_VERSION")))
(defproject clj-kondo #=(version) ...)

mikerod22:11:29

Yeah like that.

mikerod22:11:13

Lein also supports the tilde as a special case within defproject, so like ~(version)

mikerod22:11:31

But according to a comment within the codebase that is deprecated for lein 3 hah

borkdude22:11:44

I think I'll just stay with templating, since I already wrote it. I might also be able to grab the deps information from deps.edn and wrangle it in the project.clj or vice versa

mikerod23:11:16

Sure. I could see that