detekt: Applying Detekt from external Gradle file fails with: Unable to load class 'com.android.build.gradle.BaseExtension'
Steps to Reproduce
I intended to upgrade detekt version from 1.9.1 to latest 1.16.0-RC1 in android project and build failed. The project uses classic groovy gradle files. It is nice to mention that i apply detekt as a seperate gradle script.
Here is the current detekt.gradle script
buildscript {
ext.detektVersion = '1.9.1'
repositories {
jcenter()
}
dependencies {
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion"
}
}
apply plugin: io.gitlab.arturbosch.detekt.DetektPlugin
detekt {
// some options
}
And that is how it’s applied into app
apply from: '../scripts/detekt.gradle'
As i see 1.11.1 is the latest version which can be built without a problem. Starting 12.0.0 to the latest version, build fails. Gradle plugin versions are the latest one.
Stacktrace
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
> com/android/build/gradle/BaseExtension
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':app'.
Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
Caused by: java.lang.NoClassDefFoundError: com/android/build/gradle/BaseExtension
at io.gitlab.arturbosch.detekt.internal.DetektAndroid$registerDetektAndroidTasks$1.execute(DetektAndroid.kt:59)
at io.gitlab.arturbosch.detekt.internal.DetektAndroid$registerDetektAndroidTasks$1.execute(DetektAndroid.kt:21)
Caused by: java.lang.ClassNotFoundException: com.android.build.gradle.BaseExtension
... 139 more
* Get more help at https://help.gradle.org
BUILD FAILED in 435ms
Also #3476 #3260 these issues experienced similar exceptions as far as i can see.
Environment
- Version of detekt used: 1.16.0-RC1
- Version of Gradle used (if applicable): 4.1.2
- Version of Kotlin: 1.4.21
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (14 by maintainers)
1.11.1
and1.12.0-RC1
syncs correctly and1.12.0
fails with said error