https://kotlinlang.org logo
Title
n

Norbi

01/27/2023, 12:59 PM
How can I configure this setting with Gradle Kotlin DSL?
// Groovy config
atomicfu {
  dependenciesVersion = '0.19.0'
}
Content assist does not work in the
build.gradle.kts
file... The related parts extracted from the build file:
plugins {
    kotlin("jvm") version "1.8.0"
    id("org.jetbrains.kotlin.plugin.atomicfu") version "1.8.0"
}

dependencies {
    implementation("org.jetbrains.kotlinx:atomicfu:0.19.0") // <<< Is this necessary?
}

// <<< This does not work, how can I set it?
atomicfu {
  dependenciesVersion = "0.19.0"
}
Thanks.
e

ephemient

01/27/2023, 2:14 PM
you have only applied the new compiler plugin, but you haven't applied the kotlinx-atomicfu plugin that sets things up
it's a bit annoying to use because it's not published like the usual gradle plugin, but
// settings.gradle.kts
pluginManagement {
    repositories {
        mavenCentral()
    }

    plugins {
        resolutionStrategy {
            eachPlugin {
                if (requested.id.id == "kotlinx-atomicfu") useModule("org.jetbrains.kotlinx:atomicfu-gradle-plugin:${requested.version}")
            }
        }
    }
}
// build.gradle.kts
plugins {
    id("kotlinx-atomicfu") version "0.19.0"
}
should do it
you don't need to add the dependency manually nor set the dependency version, it'll default to using the artifact matching the plugin version 0.19.0
a

andylamax

01/28/2023, 1:18 PM
Just asking, why do I have to apply the atomicfu gradle plugin?? is the dependncy itself not enough?? I don't get errors compiling with the library alone
e

ephemient

01/28/2023, 1:24 PM
the dependency alone is not enough, no. the plugin changes the bytecode generated so that it is actually atomic
a

andylamax

01/28/2023, 1:49 PM
Thanks