tony
04/23/2022, 6:12 PMabstract class PrintMessageTask : DefaultTask() {
@get:Input
abstract val inputMessage: Property<String>
@get:OutputFile
abstract val outputFile: RegularFileProperty
@TaskAction
fun run() {
val message = inputMessage.get()
println(message)
outputFile.asFile.get().writeText(message)
}
}
project.tasks.register<PrintMessageTask>("printMessage") {
inputMessage.set(kotlin.random.Random.Default.nextInt().toString())
outputFile.set(
project.layout.buildDirectory.file(
"outputs/logs/message.txt"))
}
Do you think that task will always be up to date, or never up to date? Do you think the answer changes if you're using the configuration cache?CristianGM
04/23/2022, 6:32 PMCristianGM
04/23/2022, 6:33 PMtony
04/23/2022, 6:38 PMCristianGM
04/23/2022, 6:39 PMCristianGM
04/23/2022, 6:41 PMtony
04/23/2022, 6:51 PMgrossws
04/23/2022, 9:16 PMJendrik Johannes
04/25/2022, 8:33 AMRandom.Default.nextInt()
is a ‘computation’ Gradle does not know anything about.
CristianGM
04/25/2022, 8:36 AMJendrik Johannes
04/25/2022, 8:39 AMCristianGM
04/25/2022, 8:41 AMand will probably still take much longernot that we can't use it, but.. 😢
Paul Merlin
04/25/2022, 9:44 AMValueSource
https://docs.gradle.org/current/javadoc/org/gradle/api/provider/ValueSource.htmlPaul Merlin
04/25/2022, 9:45 AMtony
04/25/2022, 4:17 PMPaul Merlin
04/26/2022, 2:58 PM