Kotlin / kotlinx-atomicfu

The idiomatic way to use atomic operations in Kotlin
Other
829 stars 56 forks source link

ClassNotFoundException AtomicfuKotlinGradleSubplugin$AtomicfuKotlinGradleExtension #399

Closed lppedd closed 1 month ago

lppedd commented 4 months ago

AtomicFU 0.23.2 with Kotlin 1.9.22. Happens when importing changes in the IDE, or when attempting to execute any Gradle task.

java.lang.NoClassDefFoundError: org/jetbrains/kotlinx/atomicfu/gradle/AtomicfuKotlinGradleSubplugin$AtomicfuKotlinGradleExtension
    at kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePluginKt.applyAtomicfuCompilerPlugin(AtomicFUGradlePlugin.kt:79)
    at kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePluginKt.access$applyAtomicfuCompilerPlugin(AtomicFUGradlePlugin.kt:1)
    at kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePlugin.apply(AtomicFUGradlePlugin.kt:48)
    at kotlinx.atomicfu.plugin.gradle.AtomicFUGradlePlugin.apply(AtomicFUGradlePlugin.kt:42)
    ...
    at Program.execute(Unknown Source)
    ...
Caused by: java.lang.ClassNotFoundException: org.jetbrains.kotlinx.atomicfu.gradle.AtomicfuKotlinGradleSubplugin$AtomicfuKotlinGradleExtension
    ... 214 more
fzhinkin commented 4 months ago

@lppedd could you please share a reproducer?

lppedd commented 4 months ago

@fzhinkin sure, will come up with a repro soon. Seems like I'm the only one experiencing it, so it would be cool to understand where I'm breaking it.

willflier commented 4 months ago

I also encountered this issue when upgrading from 0.32.1 to 0.32.2. My project is a single pure Kotlin native project.

lppedd commented 4 months ago

Are you using some third party Gradle plugin?
Just to match what I have.

m-sasha commented 4 months ago

Also experiencing this in Compose Multiplatform.

m-sasha commented 4 months ago

Adding

buildscript {
    ...
    dependencies {
        ...
        classpath("org.jetbrains.kotlin:atomicfu:1.9.22")
    }
}

works around this issue.

So looks like a missing dependency in the atomicfu plugin.

lppedd commented 4 months ago

The workaround seems to be working. Thanks @m-sasha

fzhinkin commented 4 months ago

@m-sasha thanks!

The reproducer:

git clone https://github.com/JetBrains/compose-multiplatform-core.git --depth=1 -b v1.6.0-dev1405
./jbdeps/android-sdk/downloadAndroidSdk
sed -i -e 's@atomicFu = "0.23.1"@atomicFu = "0.23.2"@' ./gradle/libs.versions.toml
./gradlew build --stacktrace
mvicsokolova commented 3 months ago

I was investigating this issue and found out that the version of atomicfu complier plugin is not resolved in the configuration of compose. According to our last solution (#386), atomicfu-gradle-plugin provides a transitive atomicfu compiler plugin dependency and relies on the gradle version resolution. So, we provide compiler plugin with the lowest version and expect it to be resolved into the highest version present on the user's classpath.

runtimeOnly "org.jetbrains.kotlin:atomicfu:1.6.21"

I made it work by providing the higher version in the code above and I'm trying to get the core reason.

The bug is reproduced on a sample MPP project with a Native target.

mvicsokolova commented 1 month ago

This issue is fixed since 0.24.0 release