Does anyone have recommendations (pref existing on...
# multiplatform
e
Does anyone have recommendations (pref existing ones) for gradle plugins that turn a directory of files (text files in my case) into a .kt file with string vals holding the contents of the files?
b
you mean like const val fileName = "file content"?
That can be achieved with just a few lines of scripting. Consider this script. You can either make it executable (
chmod +x script.kts
) and run it as any other script (the extension can even be removed) like
./script.kts targetDir out.kt
, or alternativelly run it with kotlin compiler directly
kotlinc -script script.kts targetDir out.kt
r
You can copy that into a gradle task, too, if you want it integrated into your build (just add it as a dependency for the
compileKotlin
task for your source set, and ideally setup caching inputs & outputs).
Or use [buildconfig](https://github.com/gmazzo/gradle-buildconfig-plugin) to handle the generation
e
A custom task will do. It is just that I will be using such a task in many places, so maybe better to write it as a plugin?
Will have a look at buildconfig too