Given https://clojurians.slack.com/archives/C03S1KBA2/p1725754474109679 there doesn't seem to be a way to specify a single Clojure version for a monorepo that has different directories with their own deps.edn.
Or is there still an approach that doesn't involve programmatic deps.edn manipulation and version duplication?
I guess it's somewhat ironic that Ask got closed as a duplicate of an Ask I posted four years ago...
Huh, apparently there are no notifications from the website when an Ask is closed.
@alexmiller I'd say that the two Asks are different, especially when the linked Jira ticket is considered.
The Jira ticket talks about multiple people/projects/tools/aliases - all of that is irrelevant to the Ask that I've posted.
Neither the older Ask nor the Jira ticket talk about the version of Clojure - which is my only concern here.
Within the context of what I'm doing, all the bullet points in the Jira ticket work just fine where I have a single common directory with all the common dependencies. But it still doesn't let me specify the version of Clojure, and only Clojure.
Is it not multiple projects sharing config?
Depends on what you mean by "project". In my case, it's a single directory with a structure like this:
root
- src
- ...
- lib
- common
- deps.edn
- lib1
- deps.edn
- lib2
- deps.edn
- deps.edn
I specify all the common deps in lib/comon/deps.edn, everything works perfectly.
With the only exception of the version of org.clojure/clojure.FWIW, our adoption of Polylith side-stepped the problem that led me to Ask that, so I never followed up, but originally I was looking for something similar to what Eugene is Asking for... and I assumed that whatever solution eventually came along would include fixing the org.clojure/clojure version across projects (currently, the only option is an alias and :override-deps?).
there are potentially several ways to give new functionality here
This is part of why Polylith uses a top-level deps.edn with a :dev alias as the way to run a REPL for the whole monorepo, and then a primary deps.edn for each "project" that gets built. You have to specify Clojure's version in :dev (for the REPL) and for each project, but not for any components within the repo.
That works for run-time, but doesn't play nice with at least Cursive because sub-projects are resolved separately (which makes sense, since they have their own deps.edn each).
There's a recently-added setting in Cursive to support Polylith, I think?
But I don't use Polylith. :) It's a drastic overkill in my case.
(it was a longstanding problem with Cursive that it didn't play nice with Polylith, but Colin did a lot of work this past year on getting that to work I think?)
I'm suggesting that whatever he changed in Cursive would help here...?
@cfleming What do you think?
Among any potentially relevant options, I only see "Resolve over whole project" but I have no idea what it means and entails.
I also think that I can specify Clojure version for the whole project implicitly, via choosing the right deps.clj version. But that's, well, implicit. And it doesn't yet have a version that brings in 1.12.0.
I think "Resolve over whole project" is how it supports the top-level deps.edn as applying across everything -- it was part of the Polylith support, I'm pretty sure.
That flag was added for Polylith, but I'm not sure it helps in this case - it depends on the structure of your app. What that flag does is: when Cursive is resolving a symbol, instead of just checking the current module (a project, in deps terms, i.e. something with a deps.edn), it will check the whole project. This is because Polylith allows you to have code in one module which needs to refer to code in another module, without an explicit dependency between them.
So, if you have one deps project, which pulls in code from other secondary deps projects without an explicit dependency, that flag will help. But it doesn't do anything at the deps level.
As far as I know, the answer to p-himik's question is "no". I don't think there's any way to do that, since aliases in deps are not transitive and there's no concept of anything like build variables.
Personally, for Cursive I have a few scripts which update my deps files programmatically using rewrite-clj, which feels janky but in practice isn't as terrible as I thought it would be.
Thanks for the clarification on that @cfleming
I guess my approach, in that case, would be to do as much as possible via build.clj at the top-level, and have it perform the project-specific operations programmatically and inject the top-level version of Clojure into each sub-project's basis when it is doing stuff? I'd need more details about exactly what operations you wanted to run on those sub-projects where you'd want a fixed, overriding version of Clojure applied...
Created https://ask.clojure.org/index.php/14112/way-specify-clojure-version-across-all-deps-files-monorepo