Skip to content

Commit

Permalink
Fix TypeNotPresentException in projects without KGP
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Feb 24, 2023
1 parent 1040288 commit 0a65b59
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
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 0a65b59

Please sign in to comment.