leiningen

N.B. The maintainers are on #leiningen on Libera chat IRC. Go there for direct support/bug reports.
Stefano Bertoli 2019-07-10T17:50:42.077400Z

Hi everyone, do someone knows if there is a way to pass data to a clojurescript project (Reagent) when building from leiningen?

Stefano Bertoli 2019-07-10T17:51:37.078500Z

What I would like to do it get the last commit information from the git repo inside the clojurescript project, and pass that information to my project to be able to display it inside the build

Stefano Bertoli 2019-07-10T17:53:48.079800Z

The more general question would be if there is a way to trigger some Clojure code when calling a build command like lein package

2019-07-10T19:05:47.080800Z

Maybe there's a more straightforward answer to your questions, but I've used :filespecs to grab git information and package it during lein uberjar https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L432

2019-07-10T19:06:44.081600Z

I'm not sure how a clojurescript build differs as filespecs is specifically for adding things to a jar file.

Stefano Bertoli 2019-07-10T19:26:37.082300Z

Mmmmh thanks for the answer, I’ll check it out! 😃

2019-07-10T20:17:40.082800Z

@elkiwydev you can pass things to CLJS via :closure-defines

2019-07-10T20:17:44.083Z

as well

2019-07-10T20:17:51.083200Z

this may be reasonable for some usages

2019-07-10T20:18:54.084100Z

within a :cljsbuild in lein project:

:closure-defines  {your.project.ns.name.SOME_DEF ~(find-some-dynamic-build-info)}

2019-07-10T20:19:25.084800Z

And you could do a

(defn find-some-dynamic-build-info []
 ;; lookup things here )
in top of project.clj above the defproject declaration

2019-07-10T20:19:46.085100Z

which in this case, looks like you’d probably be shelling out to git

2019-07-10T20:20:02.085400Z

but it’s pretty open with what you want to do to get whatever information

Stefano Bertoli 2019-07-10T20:25:36.086400Z

Thanks @mikerod, I’ll look for that too!

👍 1