jeremymailen / kotlinter-gradle

Painless, fast ktlint plugin for Gradle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IncrementalJvmCompilerRunnerKt

vitoksmile opened this issue · comments

I'm trying to use 4.0.0 in kotlin dsl module, but the next error appears during gradle sync

Execution failed for task ':plugins:compileKotlin'.
> org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunnerKt

Unable to load class 'org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunnerKt'.

androidBuildTools = "34.0.0"
androidGradlePlugin = "8.1.2"
gradleVersion = "8.1.1"
kotlin = "1.9.10"

Ok, that's an unexpected error. In the test matrix, very similar to this test: https://github.com/jeremymailen/kotlinter-gradle/actions/runs/6444906251/job/17498377490
Just with an older gradle. Could you try gradle 8.4 and see if it goes away? If not, might need to output the buildscript dependencies that are resolved in your case.

I'm having the same issue here, but with old Groovy script:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:kspDebugKotlin'.
> org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunnerKt

kotlin = 1.8.22
androidGradlePlugin = 8.1.2

Gradle is 8.4, so it seems it doesn't fix the issue.

I guess this is the output that you need: https://gist.github.com/xrubioj/069c900460553040d4d4db24439629d5 (dependencies + crash stacktrace)

PD: notice that although ktfmt is also present here, this is because I was testing both linters and not compiling the app. When I've realized that compilation was failing I've just checked out a previous commit.

Is it possible it's a compile issue rather than a compatibility issue? Sometimes it dies with an unhelpful error since the linter itself uses the compiler for parsing, see #333.

If not that, can you provide a snippet of the build dependencies or output of gradle buildEnvironment (particularly the lines that show which version of the kotlin compiler gets resolved?

I've tried to reproduce the error without any luck with this android project config (and 1.8.22, and 1.9.10) with gradle 8.0 and 8.1.1. They work for me.

plugins {
    id("com.android.application") version "8.1.2" apply false
    id("org.jetbrains.kotlin.android") version "1.9.10" apply false
    id("org.jmailen.kotlinter") version "4.0.0" apply false
}

After checking the README.md file I've realized that kotlinter 4.0.0+ requires Kotlin 1.9.0+ (and I was using 1.8.22). After upgrading to Kotlin 1.9.10 everything works fine:

  • ./gradlew lintKotlin works correctly (checked for both with and without lint issues)
  • the app builds

So, this was a no-issue and is fixed for me. Thanks!

created a sample project using kotlinter 4.0.0, build fails
it works, if downgrade to 3.16.0

https://github.com/vitoksmile/TestKotlinterPlugin

@vitoksmile I think what's going on here is a kotlin version requirement clash between what your EditorPlugin is asking for and Kotlinter's kotlin 1.9.0+ requirement.

Notice the output of the build environment

TestKotlinterPlugin % ./gradlew :plugins:buildEnvironment | grep compile
|         |    +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.10 -> 1.9.10
|         |    |    \--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.10 -> 1.9.10 (*)
|         |    |    \--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.10 -> 1.9.10 (*)
|         |    +--- org.jetbrains.kotlin:kotlin-compiler-runner:1.8.10
|         |    |    \--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.8.10 -> 1.9.10 (*)
|         |    +--- org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.8.10
|         |    |    \--- org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.8.10
|         |    \--- org.jetbrains.kotlin:kotlin-scripting-compiler-impl-embeddable:1.8.10 (*)
|         |    |    +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.10 (*)
|         |    +--- org.jetbrains.kotlin:kotlin-compiler-embeddable:1.9.10 (*)

Some of the Kotlin compile components are 1.8.10 which is also what your Idea compiler is set to.

Looks like your gradle wrapper is 8.0, which combined with using the kotlin DSL forces the kotlin version down to 1.8.10.
If you build the project with a newer gradle such as 8.3 it doesn't experience that error.

It looks like we need to update the compatibility matrix to require gradle 8.3 or better if one is using kotlin DSL for build so that we align with the embedded versions here.

Issue disappeared after I updated gradle wrapper to 8.5