Open enspritz opened 1 month ago
Just riffing on some ideas for simple structuring
; lib/project.clj
:sub ["module-a"
"module-b"
"module-c"
:keys [:exclusions :repositories]]
; lib/module-a/project.clj
:sub [:parent ".."]
Just noticed https://github.com/achin/lein-parent ...
An idea to increase utility of
lein-sub
: Ability to nominate which keys and values inproject.clj
are propagated to / inherited by sub-projects'project.clj
s. This would reduce management load and reliance on humans to correctly propagate such hierarchical information into sub-projects.Keys
In the larger picture, referencing Leiningen's sample.project.clj, I'm not seeing a clear pattern of which keys should be inherited by default and are safe to do so in the general case. Perhaps if
lein-sub
offered an affordance to allow authors to select whichproject.clj
keys are inherited, (using my immediate self-interested needs for the sake of exposition):With a default value of an empty seq or nil or whatever, no surprises will be foisted onto current, unsuspecting
lein-sub
users, and authors would be free to choose their own sets of keys to be subjected to inheritance. Maximal flexibility with no disruption.As authors, our mental models will remain consistent if sub-projects can override inherited KV pairs by providing their own.
Back-references to parent projects
lein
running in sub-projects will need some mechanism for accessing their inherited key/value pairs. Because sub-project path designations can be arbitrary, sub-projects will need to establish "parent" or back-link reckoning on their own terms. Maven solves this using the notion of parent POMs:Leiningen directly uses that mechanism with the
:parent
key. A similar approach seems entirely workable here:This necessitates thinking of nested projects and inheritance of project KVs in multi-level, transitive terms.
Nomenclature: Maven and indeed Leiningen has already established the notion of "parent", although the more correct antonym of "sub" is "super". Maybe there is an opportunity to create a catchy, memorable key to indicate the parent (not) like
:sub-super
.I fully expect management of forward and backward filesystem path references for authors to be a low-load task, easy to debug, nearly pain free. A delight, in fact, for the gains we receive in return!