-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
36 lines (28 loc) · 951 Bytes
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
abstract class ProducerTask : DefaultTask() {
@get:OutputFile
abstract val producedFile: RegularFileProperty
@TaskAction
fun createFile() {
producedFile.asFile.get().writeText("Hello from producer!")
}
}
abstract class ConsumerTask : DefaultTask() {
@get:InputFile
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:NormalizeLineEndings
@get:Optional
abstract val producedFile: RegularFileProperty
@get:Input
@get:Optional
val consumedString: Provider<String> = producedFile.map { it.asFile.readText() }
@TaskAction
fun createFile() {
println(consumedString.get())
}
}
val producerTask by project.tasks.registering(ProducerTask::class) {
producedFile.set(layout.buildDirectory.file(project.file("producer.txt").absolutePath))
}
val consumerTask by project.tasks.creating(ConsumerTask::class) {
producedFile.set(producerTask.map { it.producedFile.get() })
}