generatedKotlin
Represents a set of generated Kotlin source files that are included in this KotlinSourceSet.
Does not include sources added to kotlin. To get all sources including generated use allKotlinSources.
For example, here is a way to create a task generating Kotlin sources:
val generatorTask = project.tasks.register("generator") {
val outputDirectory = project.layout.projectDirectory.dir("src/main/kotlinGen")
outputs.dir(outputDirectory)
doLast {
outputDirectory.file("generated.kt").asFile.writeText(
//language=kotlin
"""
fun printHello() {
println("hello")
}
""".trimIndent()
)
}
}
kotlin.sourceSets.getByName("main").generatedKotlin.srcDir(generatorTask)Content copied to clipboard