Permalink
Please sign in to comment.
Browse files
Allow element creation via delegate provider
After considering a few different names for the delegate provider (`new`
/ `factory` / `builder` / `creator` / `creating`) I settled on
`creating`:
* it shares the same prefix with the element creation methods
(`create`) so it's arguably more discoverable
* it reads more like prose, specially when coupled with the type
tasks {
val deploy by creating(Copy::class) {
// ...
}
}
Resolves #35- Loading branch information...
Showing
with
224 additions
and 14 deletions.
- +16 −12 samples/task-dependencies/build.gradle.kts
- +7 −0 src/main/kotlin/org/gradle/script/lang/kotlin/NamedDomainObjectCollectionExtensions.kt
- +82 −1 src/main/kotlin/org/gradle/script/lang/kotlin/NamedDomainObjectContainerExtensions.kt
- +119 −1 src/test/kotlin/org/gradle/script/lang/kotlin/NamedDomainObjectContainerExtensionsTest.kt
| @@ -1,18 +1,22 @@ | ||
| -val helloTask = task("hello") { | ||
| - doLast { println("Hello!") } | ||
| -} | ||
| -task("goodbye") { | ||
| - dependsOn(helloTask) // dependsOn task reference | ||
| - doLast { println("Goodbye!") } | ||
| -} | ||
| +tasks { | ||
| -task("chat") { | ||
| - dependsOn("goodbye") // dependsOn task name | ||
| -} | ||
| + val hello by creating { // refactor friendly task definition | ||
| + doLast { println("Hello!") } | ||
| + } | ||
| + | ||
| + "goodbye" { | ||
| + dependsOn(hello) // dependsOn task reference | ||
| + doLast { println("Goodbye!") } | ||
| + } | ||
| + | ||
| + "chat" { | ||
| + dependsOn("goodbye") // dependsOn task name | ||
| + } | ||
| -task("mixItUp") { | ||
| - dependsOn(helloTask, "goodbye") | ||
| + "mixItUp" { | ||
| + dependsOn(hello, "goodbye") | ||
| + } | ||
| } | ||
| defaultTasks("chat") |
0 comments on commit
2e39859