Slackbot
07/11/2023, 2:31 AMAdam
07/11/2023, 7:06 AM// settings.gradle.kts
val rootGradle: Gradle = generateSequence(gradle) { it.parent }.last()
val projectsRootDir: File = rootGradle.rootProject.projectDir
It will recursively fetch the root gradle instance, and generateSequence()
will stop when the parent is null
.
I thought it up a while a go, but I haven’t had a chance to use it in anger so I’m curious if it works!Adam
07/11/2023, 7:14 AMSettings file '/projects/my-gradle-project/settings.gradle.kts' line: 22
The root project is not yet available for build.
Adam
07/11/2023, 7:35 AM// settings.gradle.kts
val rootGradle: Gradle = generateSequence(gradle) { it.parent }.last()
val projectsRootDir: File = rootGradle.startParameter.currentDir
Gábor Török
07/11/2023, 2:04 PMincludeBuild
statements.
there are still some straightforward solutions on how to find the right directory, the bigger question is how not to duplicate that code for each project's settings file...
groovy builds are easy - I just calculate the thing in the init script, and add it to the extensions. however in kotlin dsl this seems to be an impossible task for some reason?Vampire
07/11/2023, 2:34 PMGábor Török
07/11/2023, 8:41 PMVampire
07/11/2023, 8:54 PM