-
-
Notifications
You must be signed in to change notification settings - Fork 140
FAQ
Tony Robalik edited this page Jun 30, 2021
·
3 revisions
TypeNotPresentException: Type org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension in Kotlin jvm library
This error is due to the unavoidable fact that, if your build uses Kotlin in any of its subprojects, then this plugin’s classes must be loaded in the same classloader as the Kotlin Gradle Plugin. This is discussed in the Gradle community slack here. To understand what’s going on, consider the following:
root
build.gradle
plugins {
id("com.autonomousapps.dependency-analysis") version("<latest-version>")
}library/build.gradleplugins {
id("org.jetbrains.kotlin.jvm") version("<latest-version>")
}If you now try to invoke either ./gradlew buildHealth or ./gradlew library:projectHealth, the build will fail with a TypeNotPresentException. Fixing this is simple:
root
build.gradle
plugins {
id("com.autonomousapps.dependency-analysis") version("<latest-version>")
id("org.jetbrains.kotlin.jvm") version("<latest-version>") apply false
}library/build.gradleplugins {
id("org.jetbrains.kotlin.jvm") // version would be an error
}The reason this solves the problem is that it loads both this plugin and the Kotlin Gradle Plugin in the same classloader. This limitation may one day go away, but you should not hold your breath.