From 0a65b59d62a11ab6ed52642ddd5c0e726bf82be3 Mon Sep 17 00:00:00 2001 From: IgnatBeresnev Date: Fri, 24 Feb 2023 18:37:26 +0100 Subject: [PATCH] Fix `TypeNotPresentException` in projects without KGP --- .../src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt index 37ec66c13d..6677391baa 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt @@ -17,8 +17,13 @@ internal fun parsePath(path: String): Path = Path.path(path) internal val Project.kotlinOrNull: KotlinProjectExtension? get() = try { project.extensions.findByType() - } catch (e: NoClassDefFoundError) { - null + } catch (e: Throwable) { + when (e) { + // if the user project doesn't have KGP applied, we won't be able to load the class; + // TypeNotPresentException is possible if it's loaded through reified generics. + is NoClassDefFoundError, is TypeNotPresentException, is ClassNotFoundException -> null + else -> throw e + } } internal val Project.kotlin: KotlinProjectExtension