This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
kotlin-dsl-samples/samples/task-dependencies/build.gradle.kts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 lines (35 sloc)
987 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* An example Gradle task. | |
*/ | |
open class GreetingTask : DefaultTask() { | |
val message = project.objects.property<String>() | |
@TaskAction | |
fun greet() = println(message.get()) | |
} | |
tasks { | |
// `hello` is a `TaskProvider<GreetingTask>` | |
val hello by registering(GreetingTask::class) { | |
message.set("Hello!") | |
} | |
// `goodbye` is a `TaskProvider<GreetingTask>` | |
val goodbye by registering(GreetingTask::class) | |
// Every `NamedDomainObjectProvider<T>` can be lazily configured as follows | |
goodbye { | |
dependsOn(hello) | |
} | |
// Existing container elements can be lazily configured via the `String` invoke DSL | |
"goodbye"(GreetingTask::class) { | |
message.set("Goodbye!") | |
} | |
// Regular API members are also available | |
register("chat") | |
} | |
// ... | |
tasks { | |
// Existing container elements can be lazily brought into scope | |
val goodbye by existing | |
"chat" { | |
dependsOn(goodbye) | |
} | |
} | |
defaultTasks("chat") |