Skip to content

Unable to load class 'org.jetbrains.kotlin.name.FqName' #65

Closed
@ForteScarlet

Description

@ForteScarlet

When I try to upgrade the Kotlin version from 2.0.20 to 2.1.0-Beta1, I get the following error when referencing the plugin in Gradle:

Unable to load class 'org.jetbrains.kotlin.name.FqName'
org.jetbrains.kotlin.name.FqName

Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

After some experimentation, I realized that the kotlin-compiler that the plugin depends on is compileOnly if the compilation and distribution configuration of this plugin remains unchanged.
Reference:

This worked in 2.0.20 (and earlier), but not in 2.1.0-Beta1.
I'm guessing that perhaps in 2.1.0-Beta1 there was some change in the way dependencies are passed within Gradle's kotlin plugin, so that the kotlin-compiler doesn't do it anymore.

I'm going to keep the original way of compiling and distributing in the 2.1.0-Beta1-0.9.2 version of this plugin for now.
If you have a similar problem after updating Kotlin with this plugin, try the following solution.

plugins {
    kotlin("jvm") version "2.1.0-Beta1"
    id("love.forte.plugin.suspend-transform") version "2.1.0-Beta1-0.9.2"
}

group = "..."
version = "..."

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        // Add `kotlin-compiler` for classpath here
        classpath("org.jetbrains.kotlin:kotlin-compiler:2.1.0-Beta1")
    }
}

suspendTransform {
  // ...
}

However, in local testing I'm not sure if using id("...") directly works, so if the above doesn't work, you can try that too:

plugins {
    kotlin("jvm") version "2.1.0-Beta1"
}
group = "..."
version = "..."

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        // Add plugin for classpath here
        classpath("love.forte.plugin.suspend-transform:suspend-transform-plugin-gradle:2.1.0-Beta1-0.9.2")
        // Add `kotlin-compiler` for classpath here
        classpath("org.jetbrains.kotlin:kotlin-compiler:2.1.0-Beta1")
    }
}

apply(plugin = "love.forte.plugin.suspend-transform")

extensions.getByType<SuspendTransformGradleExtension>().apply {
    // ...
}

If this persists until after 2.1.0 is released, then I'll change the kotlin-compiler passability from compileOnly to implementation (or api ?).

Note

If there is a better solution, or if I have said or understood anything wrong, feel free to share or correct me!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions