Open Vampire opened 3 years ago
Thanks for suggestion @Vampire!
However, I am not using Kotlin DSL in my gradle projects and as this is my OSS free-time project I don't have a motivation to work on this refactoring given other priorities.
I may look into this later (could be months), initial suggestions seems helpful. Or feel free to submit a PR.
Thanks!
I could test the Action<>
change.
The Action
change I could easily PR, that costs about 5 minutes to do.
Just tell me if you want the action parameters to replace the closure parameters which will be a source compatible change but not a binary compatible change or additional action overloads.
The other changes, using the property / provider lazy api, not using afterEvaluate, and so on actually has nothing to do with Kotlin DSL compatiblility, just with bad / obsolete practices, reliability and error-proneness. Those are things you should consider even when only supporting Groovy DSL.
At #3 you find a PR with the action changes that should keep binary compatibility. If you don't care about binary compatibility but only about source compatibility, then the closure variants can simply be deleted as Groovy closures can also implement the action interface.
Thanks for PR! Quick question - why are config classes now abstract?
Because they have an abstract method that will be implemented by Gradle magic to inject the object factory.
The object factory is used to instantiate the config classes to add some more Gradle magic for the @HasImplicitReceiver
magic of Action
.
Without that you would have to do
config {
it.debugGpPro = true
}
instead of the intended
config {
debugGpPro = true
}
Aah great, that sounds helpful, thanks @Vampire !
Even better would of course be if you move toward best practices, not having configuration methods like JavaCard.config() but register Config as extension of JavaCard and so on, and more importantly making the extension (and tasks) use the property / provider api for their fields, enabling easy lazy configuration and binding, and removing the need to do afterEvaluate tricks. That would of course be a big breaking change though.
This sounds like a big piece of work and honestly I have no idea how that would work. So I leave it for some experimental PRs.
Please improve Kotlin DSL compatibility. Currently you have to use a lot of
delegateClosureOf
calls, as all the extension hierarchy expectsClosure
arguments. It would already be much better if you additionally provideAction<...>
variants of those methods. Actually you could also make the methods expectAction<...>
instead ofClosure
as both Groovy closures and Kotlin lambdas can implementAction
but that would be a breaking change.Even better would of course be if you move toward best practices, not having configuration methods like
JavaCard.config()
but registerConfig
as extension ofJavaCard
and so on, and more importantly making the extension (and tasks) use the property / provider api for their fields, enabling easy lazy configuration and binding, and removing the need to doafterEvaluate
tricks. That would of course be a big breaking change though.