This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-25
Channels
- # announcements (9)
- # babashka (38)
- # beginners (41)
- # biff (1)
- # clojure (19)
- # clojure-europe (7)
- # clojure-uk (2)
- # clojurescript (3)
- # code-reviews (30)
- # conjure (4)
- # cursive (8)
- # datomic (32)
- # docker (2)
- # emacs (7)
- # etaoin (2)
- # fulcro (37)
- # graphql (2)
- # jobs (1)
- # jobs-discuss (8)
- # leiningen (10)
- # lsp (36)
- # meander (4)
- # missionary (4)
- # nbb (12)
- # off-topic (1)
- # other-languages (10)
- # pathom (11)
- # re-frame (5)
- # reitit (4)
- # remote-jobs (3)
- # shadow-cljs (13)
- # sql (1)
- # tools-build (4)
- # tools-deps (31)
- # xtdb (2)
Hi folks. I’d like to get the value of some alias
at runtime.
(apply hash-map (drop 3 (let [project-path "project.clj"]
(when (.exists (io/as-file project-path))
(read-string (slurp project-path))))))
I’m using this. The whole file is list: it’s first element is defproject
, the second is the name of the project, and so on. I’m wondering if this drop 3
is reliable or if there’s a better way of doing that.I'd suggest instead sth like
(defproject p "0"
:middleware [~(do
(defn foo [project]
(-> project
(update :jvm-opts conj (str "-Dlein-project=" (pr-str project)))
(update :jvm-opts vec)))
`foo)])
Then you can (read-string (System/getProperty "lein-project"))
in your project replInteresting! The thing is that the tool will be injected on many projects as they are, with no modifications. So unfortunately I can’t use this custom logic. In any case, I didn’t know that was possible, thanks.
I think I forgot to explain the full context here. The code I proposed would reside in a library that is injected in many Clojure services in a pipeline.
It extracts information from tests, so whenever one commits something to a service, that lib runs in the service in a pipeline (with lein update-in
, which appends the lib as a dependency). That’s why I have little control over the service code.