Skip to content

Instantly share code, notes, and snippets.

@neogeogre
Last active August 25, 2023 11:12
Show Gist options
  • Save neogeogre/f20bd146beb61ddc7588a3af306b6a2c to your computer and use it in GitHub Desktop.
Save neogeogre/f20bd146beb61ddc7588a3af306b6a2c to your computer and use it in GitHub Desktop.
add and display gradle kotlin dsl tasks
tasks.register("before") {
doLast {
val myVar = "Hello variable"
println(myVar)
}
}
tasks.register("after") {
doLast {
println("Hello, 2!")
}
}
tasks.named<Test>("test") {
dependsOn("before")
finalizedBy("after")
}
tasks.register("listTasks") {
doFirst {
println("Available tasks: ${project.tasks.forEach { println(it.name) }}")
}
}
tasks.named("build") {
dependsOn("customTask") // creates implicit dependencies
mustRunAfter("customTask") // controls the execution order
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment