Search code examples
gradlegradle-kotlin-dsl

How to read properties file in resources folder of buildSrc module?


I need to read properties file located inside resources folder of buildSrc special module to create kotlin object which will be accessible by other project modules. I tried to put this properties file

  1. in the root project folder(this case sometimes works sometimes not, so I look for more reliable case)
  2. inside of buildSrc folder directly
  3. and now trying by putting inside "conventional" resources folder inside buildSrc which even highlighted by ide as recognized resources folder

But during assembling of modules I get Exception file not found on the line load()

So 2 questions:

  1. where properties file should be located
  2. how to read it from kotlin inside buildSrc module.

project structure dependencies.kt


Solution

  • After trying different variants I have found 100% stable and working variant - instead of reading a properties file, parsing it and validating input - just use kotlin objects as ready to use configuration! With this approach the problem of a current folder and accessibility of resources is gone which is what I needed. Property in kt files