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

Investigation of the bug with plugin order application. #385

Closed
wants to merge 6 commits into from

Conversation

mvicsokolova
Copy link
Collaborator

@mvicsokolova mvicsokolova commented Dec 14, 2023

See the issue: #384
The order in which atomicfu-gradle-plugin and kotlin-gradle-plugin are added to the classpath defines actual dependencies found on the classpath.
Also, the description of this problem for coroutines: Kotlin/kotlinx.coroutines#3984

Started to fail after these change in atomicfu #377 : atomicfu compiler plugin should be manually added to the classpath by the user.

To reproduce:

  1. Publish the current version of atomicfu locally:
    ./gradlew clean publishToMavenLocal
  2. Go to the project directory (it's an isolated sample project):
    cd integration-testing/examples/plugin-order-bug/
  3. Run the project build:
    gradle clean build

It fails with the error:

> Task :compileCommonMainKotlinMetadata FAILED
e: file:///Users/Maria.Sokolova/IdeaProjects/kotlinx-atomicfu-new/integration-testing/examples/plugin-order-bug/src/commonMain/kotlin/AtomicSampleClass.kt:7:8 Unresolved reference: kotlinx
e: file:///Users/Maria.Sokolova/IdeaProjects/kotlinx-atomicfu-new/integration-testing/examples/plugin-order-bug/src/commonMain/kotlin/AtomicSampleClass.kt:8:8 Unresolved reference: kotlinx
e: file:///Users/Maria.Sokolova/IdeaProjects/kotlinx-atomicfu-new/integration-testing/examples/plugin-order-bug/src/commonMain/kotlin/AtomicSampleClass.kt:12:22 Unresolved reference: atomic
e: file:///Users/Maria.Sokolova/IdeaProjects/kotlinx-atomicfu-new/integration-testing/examples/plugin-order-bug/src/commonMain/kotlin/AtomicSampleClass.kt:22:24 Unresolved reference: reentrantLock

FAILURE: Build failed with an exception.

  1. Change the order of atomicfu-gradle-plugin and kotlin-gradle-plugin in the buildscript:
dependencies {
        // If the order of adding atomicfu-gradle-plugin and kotlin-gradle-pluin to the classpath is changed, 
        // then atomicfu dependency is not added to the classpath
        classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${libs.versions.atomicfuVersion.get()}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlinVersion.get()}")
        classpath("org.jetbrains.kotlin:atomicfu:${libs.versions.kotlinVersion.get()}")
    }

The build is successful 🙃

What changes is the the Kotlin compiler classpath. When kotlin-gradle-plugin is applied first no org.jetbrains.kotlinx-atomicfu-0.23.2-SNAPSHOT-commonMain-GuV53w.klib is found, hence the compilation error is thrown.

To check Kotlin compiler args, I ran the build with --debug and found :compileCommonMainKotlinMetadata Kotlin compiler args: -classpath

@fzhinkin
Copy link
Contributor

@mvicsokolova this one should be closed, right?

@mvicsokolova
Copy link
Collaborator Author

Yes, the issue was fixed here: #386

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

Successfully merging this pull request may close these issues.

2 participants