Created
August 30, 2018 14:33
-
-
Save StefMa/f744654787df010bafd9646017358aa0 to your computer and use it in GitHub Desktop.
Gradle inferred task dependency
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
open class TestingTask : DefaultTask() { | |
@InputFiles | |
var inputDirs = mutableListOf<Task>() | |
@OutputDirectory | |
var out: File? = null | |
@TaskAction | |
fun createOutputDir() { | |
println("Executed task named ‘$name' \uD83C\uDF89") | |
} | |
} | |
tasks.register("first", TestingTask::class.java) { | |
inputDirs.add(task("emptyTask")) | |
out = File("$buildDir/firstOutput") | |
} | |
tasks.register("second", TestingTask::class.java) { | |
inputDirs.add(tasks.getByName("first")) | |
out = File("$buildDir/secondOutput") | |
} |
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
$ ./gradlew second | |
> Task :first | |
Executed task named 'first' 🎉 | |
> Task :second | |
Executed task named 'second' 🎉 | |
BUILD SUCCESSFUL in 0s | |
2 actionable tasks: 2 executed | |
$ ./gradlew second | |
BUILD SUCCESSFUL in 0s | |
2 actionable tasks: 2 up-to-date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment