Last active
August 25, 2023 11:12
-
-
Save neogeogre/f20bd146beb61ddc7588a3af306b6a2c to your computer and use it in GitHub Desktop.
add and display gradle kotlin dsl tasks
This file contains hidden or 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
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