To retrieve the project Gradle build file (build.gradle or build.gradle.kts), I used the following code:
val connection = GradleConnector.newConnector().forProjectDirectory(File(it)).connect()
val model = connection.model(GradleProject::class.java)
val gradleProjectModel = model.get()
val sourceFile = gradleProjectModel?.buildScript?.sourceFile?
Unfortunately, when there is an error in the content of the build.gradle(.kts) file the "model.get()" fails with an exception.
Is there another way to retrieve the build.gradle(.kts) file even if there are some errors in the file content?
I can of course use:
val file1 = File(it, "build.gradle")
val file2 = File(it, "build.gradle.kts")
but It's a little bit hard-coded!
Thanks a lot for help