Super simple trick to get the path of of your project folder in kotlin. You can also use this example snippet for your java or spring project as well.

Example location of your main file

/Users/my-user/code/my-project/src/main/kotlin/com.myproject/Main.kt

Getting project root directory

It doesn't matter where you define you define this function or from where you call, it will always will return you the absolute path of your project.

/Users/my-user/code/my-project/