Hi. Is it possible to store configuration in a sep...
# announcements
j
Hi. Is it possible to store configuration in a separate file, e.g. config.yaml, and then read it from build.gradle.kts and then for example add data from the file in some sections in build.gradle.kts, e.g. the list of srcDirs? I use gradle dsl (I saw an example in gradle https://stackoverflow.com/questions/48318114/how-to-load-yml-propery-to-gradle but I don't know how to convert to gradle dsl):
Copy code
sourceSets.main {
    withConvention(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::class) {
        // Put components and bases here (src)
        kotlin.srcDirs(
                "kotlin/bases/cli/src",
                "kotlin/components/file/src",
                "kotlin/components/srcreader/src"
        )
    }
}
h
In your gradle.kts you can use project and from it, its properties, eg rootDir, buildDir and so on. You can simply load it with project.rootDir.resolve("foo.yml").readText (recalling from memory, im on my phone) and you have the file contents. The gradle api can then be used programatically the same way you would use it in the rest of your script. In the likes of linesFromFile.forEach { kotlin.srcDir(it) }
j
Thanks for the tips!