Skip to content

Commit

Permalink
Fix TypeNotPresentException in projects without KGP (#2890)
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Feb 24, 2023
1 parent b730bf4 commit 9297e6d
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -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
Expand Down

0 comments on commit 9297e6d

Please sign in to comment.