-
-
Notifications
You must be signed in to change notification settings - Fork 140
FAQ
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:
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:
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.
For various reasons, you may want to skip analyzing test dependencies. For example, because it makes the analysis take longer and you’re not concerned about tests at the moment.
To skip test analysis, set the system property dependency.analysis.test.analysis=false. This can be done on an ad hoc basis with -Ddependency.analysis.test.analysis=false, per permanently by setting the following:
gradle.propertiessystemProp.dependency.analysis.test.analysis=false