Hello! What is the best way to replace tokens in K...
# gradle
m
Hello! What is the best way to replace tokens in Kotlin source files using Gradle? I've tried this:
Copy code
tasks {
    val processSources by creating(Sync::class) {
        from(kotlin.sourceSets["main"].kotlin)
        into("$buildDir/processed")
        filter<ReplaceTokens>("tokens" to mapOf("VERSION" to project.version))
    }
    "compileKotlin"(KotlinCompile::class) {
        dependsOn(processSources)
        setSource(processSources.destinationDir)
    }
}
but got a bunch of redeclaration errors (it looks like the Kotlin Gradle plugin also takes original source directory from somewhere else):
Copy code
e: /home/me/projects/test/shared/build/processed/com/company/test/shared/Responses.kt: (15, 7): Redeclaration: ResponseUser
e: /home/me/projects/test/shared/src/com/company/test/shared/Responses.kt: (15, 7): Redeclaration: ResponseUser