Melvin Biamont
11/07/2023, 12:02 AMSymbolProcessorProvider
?
I tried to pass its relative path as ksp argument like this:
ksp {
arg("the-file", "src/main/resources/my-file.txt")
}
But then, is there a way to get the root directory of the gradle module which called my ksp processor?mbonnin
11/07/2023, 12:22 AMMelvin Biamont
11/07/2023, 12:25 AMval SymbolProcessorEnvironment.moduleDirectory: File?
get() {
codeGenerator.createNewFileByPath(Dependencies(false), "codegen", "txt").close()
val file = codeGenerator.generatedFile.firstOrNull { it.name == "codegen.txt" } ?: return null
var counter = 0
var buildDirectory: File? = null
var currentDirectory: File? = file
while(buildDirectory == null && counter < 7 && currentDirectory != null) {
if(currentDirectory.name == "build") {
buildDirectory = currentDirectory
}
currentDirectory = currentDirectory.parentFile
counter++
}
return buildDirectory?.parentFile
}
But that´s very sad there is no existing solution 😞ephemient
11/07/2023, 12:48 AMMelvin Biamont
11/07/2023, 1:14 AMksp {
arg("the-file", project.file("src/main/resources/my-file.txt").path)
}
ephemient
11/07/2023, 1:20 AM