Alowaniak
05/23/2018, 11:05 AMplugins{}
block is heavily recommended, isn't using apply<>()
and configure<>
also type-safe? The reason I'm sort of gravitating towards the apply
and configure
is because I feel like you can group it better together then (for e.g. make a `fun setupApplication() { /*appply and configure*/}`; but I'm very new to messing around with gradle and especially kotlin so maybe I'm misguided here?eskatos
05/23/2018, 11:09 AMthe<T>()
and configure<T> {}
are type safe.
The type to use may be hard to discover. When you use the plugins {}
block the Kotlin DSL provides easy to discover Kotlin extensions, saving you some burden.
It also enables type safe configurations accessors for dependencies declaration that you have to replace with string references when using apply
.Alowaniak
05/23/2018, 11:32 AMplugins{}
block you can't provide any context though, for example I'm using the idea
plugin for a workaround (https://youtrack.jetbrains.com/issue/IDEA-188436) so with apply and configure I can do /**
* Workaround for [issue explained here](<https://youtrack.jetbrains.com/issue/IDEA-188436>)
*/
fun resolveIdeaTestDependenciesWorkAround() {
apply<IdeaPlugin>()
@Suppress("UNUSED_VARIABLE") //explicit val and delegate required to configure task
val ideaModule by tasks.getting(GenerateIdeaModule::class) {
module.scopes["COMPILE"]!!["plus"]!! += configurations.testCompile
}
}
Alowaniak
05/23/2018, 11:35 AMconfigureBothMainAndTestSourceSetsUnderSrc
function, and I personally like that composition&grouping better.
Because afaict you can only have 1 plugins{}
blockeskatos
05/23/2018, 12:02 PM