Does anyone have an example of applying detekt ins...
# detekt
s
Does anyone have an example of applying detekt inside a precompiled convention plugin for Gradle? When I try to follow https://docs.gradle.org/current/samples/sample_convention_plugins.html#compiling_convention_plugins, I'm getting
Copy code
Unable to load class 'org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension'.

This is an unexpected error. Please file a bug containing the idea.log file.
s
Strange, I'm doing basically the same thing (modulo the
refreshVersions
stuff), but I get
Copy code
Caused by: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/gradle/dsl/KotlinJvmProjectExtension
	at io.gitlab.arturbosch.detekt.internal.DetektJvm.registerTasks(DetektJvm.kt:13)
	at io.gitlab.arturbosch.detekt.DetektPlugin$registerDetektJvmTasks$1.invoke(DetektPlugin.kt:42)
	at io.gitlab.arturbosch.detekt.DetektPlugin$registerDetektJvmTasks$1.invoke(DetektPlugin.kt:41)
	at io.gitlab.arturbosch.detekt.DetektPlugin.registerDetektJvmTasks$lambda$0(DetektPlugin.kt:41)
e
Do you have a classpath dependency on KGP?
s
What's KGP?
e
Kotlin Gradle Plugin
You can add it to the classpath with
org.jetbrains.kotlin:kotlin-gradle-plugin:<version>
s
Hmm, could be. It might be hidden inside a
subprojects
clause, if that applied to
buildSrc
, too.
e
It should be added either in
settings.gradle.kts
or in a
buildscript.dependencies
in your root
build.gradle.kts
s
Ah, so you're saying I should have a dependency on KGP? I though you were saying that having it might cause my problem.
e
Right, you should have a dependency on KGP. Detekt's plugin is probably depending on it, but not propagating the transitive dependency to your project.
316 Views