Skip to content

Instantly share code, notes, and snippets.

@PaoloMilano
Last active June 2, 2020 16:40
Show Gist options
  • Save PaoloMilano/ca5e655e0246442499d8b201d8477759 to your computer and use it in GitHub Desktop.
Save PaoloMilano/ca5e655e0246442499d8b201d8477759 to your computer and use it in GitHub Desktop.
import extensions.writeXlmWithTags
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
import java.io.File
internal open class ColorsTask : DefaultTask(){
@get:OutputFile
lateinit var outputFile: File
@get:Input
val colorsMap = mapOf(
"color1" to "#00ff00",
"color2" to "#ff0000",
"color3" to "#00ffff"
)
@TaskAction
fun makeResources() {
colorsMap.entries.joinToString { (colorName, color) ->
"\n <color name=\"$colorName\">$color</color>"
}.also { xml ->
outputFile.writeXlmWithTags(xml)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment