*.gradle.kts: catch exceptions during GradleBuildRootManager initialization
^KT-39317 Fixed
This commit is contained in:
+8
-3
@@ -346,10 +346,15 @@ class GradleBuildRootsManager(val project: Project) : GradleBuildRootsLocator(),
|
||||
lastModifiedFiles: LastModifiedFiles = loadLastModifiedFiles(externalProjectPath) ?: LastModifiedFiles(),
|
||||
dataProvider: (buildRoot: VirtualFile) -> GradleBuildRootData?
|
||||
): Imported? {
|
||||
val buildRoot = VfsUtil.findFile(Paths.get(externalProjectPath), true) ?: return null
|
||||
val data = dataProvider(buildRoot) ?: return null
|
||||
try {
|
||||
val buildRoot = VfsUtil.findFile(Paths.get(externalProjectPath), true) ?: return null
|
||||
val data = dataProvider(buildRoot) ?: return null
|
||||
|
||||
return Imported(externalProjectPath, data, lastModifiedFiles)
|
||||
return Imported(externalProjectPath, data, lastModifiedFiles)
|
||||
} catch (e: Exception) {
|
||||
scriptingErrorLog("Cannot load script configurations from file attributes for $externalProjectPath", e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun add(newRoot: GradleBuildRoot) {
|
||||
|
||||
@@ -88,4 +88,8 @@ fun scriptingDebugLog(message: () -> String) {
|
||||
|
||||
fun scriptingInfoLog(message: String) {
|
||||
logger.info("[KOTLIN_GRADLE_DSL] $message")
|
||||
}
|
||||
|
||||
fun scriptingErrorLog(message: String, throwable: Throwable?) {
|
||||
logger.error("[KOTLIN_GRADLE_DSL] $message", throwable)
|
||||
}
|
||||
Reference in New Issue
Block a user