Created
June 8, 2020 14:57
-
-
Save PaoloMilano/76fbd6c9430c14fc0a152597a210d64e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import extensions.writeXlmWithTags | |
import org.gradle.api.DefaultTask | |
import org.gradle.api.tasks.InputFile | |
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 | |
// We now take a file and will therefore change the annotation to reflect this | |
@get:InputFile | |
lateinit var inputFile: File | |
@TaskAction | |
fun makeResources() { | |
// Simple CSV parsing mechanism. For more complex use cases we may want to use a dedicated library | |
inputFile.readLines().map { color -> | |
color.split(",") | |
}.joinToString { | |
"\n <color name=\"${it[0]}\">${it[1]}</color>" | |
}.also { xml -> | |
outputFile.writeXlmWithTags(xml) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment