4

What would be the equivament of the following in Kotlin DSL (build.gradle.kts)?

processResources {
    from(sourceSets.main.resources.srcDirs) {
        filter ReplaceTokens, tokens: [version: version]
    }
}
Gieted
  • 835
  • 6
  • 21
  • Does this answer your question? [How to configure the processResources task in a Gradle Kotlin build](https://stackoverflow.com/questions/40096007/how-to-configure-the-processresources-task-in-a-gradle-kotlin-build) – Tom Sep 16 '20 at 12:27
  • No question you linked asks how to set processResources task and I'm asking how to rewrite a specific processResources function to Kotlin – Gieted Sep 16 '20 at 12:35

1 Answers1

11

It's actually super easy:

tasks.processResources {
    expand("version" to project.version)
}

And then just put ${version} in resource and it will be replaced with your project version

Gieted
  • 835
  • 6
  • 21
  • Thank you so much for this answer. It works and helped me with my issue as well. :) – FNL Jan 22 '22 at 15:10