Desired Behavior
Provide a generic way for a Clojure-based task to accept dynamic configuration as a map, supporting additional EDN types: Keyword and Symbol.
Something maybe like:
interface EdnAdapter {
put(Object key, Object value)
put(Object key, Action<EdnAdapter> config)
putIn(List keys, Object value)
putIn(List keys, Action<EdnAdapter> config)
}
where usage would look like (rough take at it):
compiler {
put(kw('optimizations'), kw('advanced'))
put(kw('modules')) {
put(kw('common')) {
put(kw('output-to'), 'public/js/common.js')
put(kw('entries'), [sym('sample.common')] as Set)
}
put(kw('cart')) {
put(kw('output-to'), 'public/js/cart.js')
put(kw('entries'), [sym('sample.cart'), sym('sample.shopping')] as Set)
}
}
}
It would be nice to get something cleaner than this. A couple challenges:
- Keywords and symbol support. They aren't valid Java identifiers so you can't just do something like
:stuff = 'things'.
- Can't be too Groovy specific, since we would want this to work in Kotlin DSL too.
Context
Right now, the plugin has to statically provide every single option for any Clojure tool we call out to (e.g. ClojureScript compiler, Figwheel). Most of those tools accept EDN maps as config, and have a very dynamic sense of what can be provided in them.
For example, neither ClojureScript nor Figwheel document a :devcards option, but DevCards relies on a :devcards key to be in the compiler environment to decide whether to actually create the cards.
It is very difficult to provide support for these kinds of things, as there's always another option or another tool that will require more.
The major caveat here is that to leverage Gradle, we must still identify certain values as input files/directories or output files/directories. These are needed for Gradle's incremental build support to decide whether or not to re-run tasks.
Desired Behavior
Provide a generic way for a Clojure-based task to accept dynamic configuration as a map, supporting additional EDN types: Keyword and Symbol.
Something maybe like:
where usage would look like (rough take at it):
compiler { put(kw('optimizations'), kw('advanced')) put(kw('modules')) { put(kw('common')) { put(kw('output-to'), 'public/js/common.js') put(kw('entries'), [sym('sample.common')] as Set) } put(kw('cart')) { put(kw('output-to'), 'public/js/cart.js') put(kw('entries'), [sym('sample.cart'), sym('sample.shopping')] as Set) } } }It would be nice to get something cleaner than this. A couple challenges:
:stuff = 'things'.Context
Right now, the plugin has to statically provide every single option for any Clojure tool we call out to (e.g. ClojureScript compiler, Figwheel). Most of those tools accept EDN maps as config, and have a very dynamic sense of what can be provided in them.
For example, neither ClojureScript nor Figwheel document a
:devcardsoption, but DevCards relies on a:devcardskey to be in the compiler environment to decide whether to actually create the cards.It is very difficult to provide support for these kinds of things, as there's always another option or another tool that will require more.
The major caveat here is that to leverage Gradle, we must still identify certain values as input files/directories or output files/directories. These are needed for Gradle's incremental build support to decide whether or not to re-run tasks.