Kotlin / kotlinx-atomicfu

The idiomatic way to use atomic operations in Kotlin
Other
884 stars 57 forks source link

Warning about compileOnly dependency with Kotlin 2.0.20-Beta1 #448

Open lukellmann opened 2 months ago

lukellmann commented 2 months ago

When building a project that uses AtomicFU with Kotlin 2.0.20-Beta1, I get this warning:

w: A compileOnly dependency is used in targets: Kotlin/JS.
Dependencies:
    - org.jetbrains.kotlinx:atomicfu:0.25.0 (source sets: jsMain)

Using compileOnly dependencies in these targets is not currently supported, because compileOnly dependencies must be present during the compilation of projects that depend on this project.

To ensure consistent compilation behaviour, compileOnly dependencies should be exposed as api dependencies.

Example:

    kotlin {
        sourceSets {
            nativeMain {
                dependencies {
                    compileOnly("org.example:lib:1.2.3")
                    // additionally add the compileOnly dependency as an api dependency:
                    api("org.example:lib:1.2.3")
                }
            }
        }
    }

This warning can be suppressed in gradle.properties:

    kotlin.suppressGradlePluginWarnings=IncorrectCompileOnlyDependencyWarning
mvicsokolova commented 1 month ago

This is a new warning introduced in 2.0.20. When JS transformations are enabled (kotlinx.atomicfu.enableJsIrTransformation=true), atomicfu-gradle-plugin adds compileOnly dependency to the library, causing this warning.

This warning is not going to become an error, though users of the Kord library might be affected. I will replace compileOnly with api dependency in the next kotlinx-atomicfu release.