Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ForteScarlet opened this issue Sep 21, 2024 · 0 comments
Open

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

ForteScarlet opened this issue Sep 21, 2024 · 0 comments

Comments

@ForteScarlet
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant