This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-26
Channels
- # babashka (2)
- # calva (3)
- # clj-kondo (8)
- # clojure (40)
- # clojure-europe (21)
- # clojure-nl (1)
- # clojure-norway (33)
- # clojure-uk (4)
- # core-async (8)
- # data-science (11)
- # datomic (64)
- # fulcro (15)
- # helix (4)
- # hyperfiddle (16)
- # keyboards (2)
- # lsp (6)
- # music (9)
- # off-topic (31)
- # polylith (11)
- # portal (1)
- # reitit (14)
- # shadow-cljs (20)
- # tools-deps (5)
- # xtdb (3)
Is it a reasonable idea to extend the poly
tool from within one’s project? I’m considering polylith as a partial replacement to my custom tooling.
Can you be a bit more specific about what you're doing/thinking?
At work, we run the poly
tool via Clojure shell to get lists of changes etc, without trying to use it as a library.
I have a tool that starts a development JVM, has commands and covers some ground that the poly
tool does; I was considering the reasonableness of writing custom commands available within the poly
tool on a specific project.
We started doing something similar as part of our (currently on hold) migration to polylith. Have a dev jvm that pulls in the poly tool and other tools we use and use them to carry out the build pipeline tasks. I don't think poly itself is officially extensible with commands but one can wrap the tool I believe
I use poly as a library calling projects-to-deploy
since that is what polylith's build.clj does. Works well for me.
We get that information via a CLI call from our build.clj
:
(defn- changed-projects
"Produce the list of projects that need building.
`since` should be `:before-tag` or `:after-tag`"
[since]
(let [{:keys [exit out]}
(run-task {:aliases [:poly]
:out :capture
:exit :capture
:main-args
["ws"
"get:changes:changed-or-affected-projects"
(str "since:"
(case since
:before-tag "release"
:after-tag "previous-release"))
"skip:dev"
"color-mode:none"]})]
(if (zero? exit)
(edn/read-string out)
(throw (ex-info "Unable to determine changed projects"
{:exit exit :out out})))))
(I'd be wary of calling any of the Polylith internals from my own code -- but the CLI interface is pretty well-defined and documented)
run-task
is a generic subprocess runner, based on aliases (similar to what's in the http://clojure-doc.org tools.build
cookbook).
It's https://cljdoc.org/d/polylith/clj-poly/0.2.18/doc/ci/polylith-ci-setup#_deploy from the poly tool docs as an example, so I thought we were meant to use that API. But on a second reading, maybe build.clj changed since that was written.?
Here's the 0.2.19-SNAPSHOT version of the API and it seems minimal and offers a reasonably firm guarantee of non-breakage, so I guess that function is safe to depend on (but I wouldn't depend on other namespaces -- and even tho' it says they don't mean to break the test runner, 0.2.19 has breaking changes compared to 0.2.18, but only a couple of test runners exist at this point and one has already been updated to work with both versions): https://cljdoc.org/d/polylith/clj-poly/0.2.19-SNAPSHOT/api/polylith.clj.core.api.interface#api-version
We have an example in the documentation on how to use clj-poly from a build script in the documentation https://cljdoc.org/d/polylith/clj-poly/0.2.18/api/polylith.clj.core.api. In the same page we also say "If you need more access than is exposed by the API at the moment, just reach out to the Polylith team in https://clojurians.slack.com/messages/C013B7MQHJQ and we will try to help out."