Giorgi
02/08/2025, 11:55 AMall { languageSettings.optIn("*") }
but it does not workGiorgi
02/08/2025, 11:55 AMe: file:///Users/Giorgi_Shalvashvili/IdeaProjects/catchclicker/data/src/commonTest/kotlin/com/app/data/bluetooth/dto/SetupPacketTest.kt:40:25 This declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
Moussa
02/08/2025, 12:04 PMbuild.gradle.kts
kotlin {
targets.all {
compilations.all {
compileTaskProvider.configure {
compilerOptions {
// For the usage of expect/actual warning
freeCompilerArgs.add("-Xexpect-actual-classes")
// For not needing to add `ExperimentalCoroutinesApi`
freeCompilerArgs.add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi")
// For not needing to add `ExperimentalUuidApi`
freeCompilerArgs.add("-opt-in=kotlin.uuid.ExperimentalUuidApi")
// For you specific case you would add `kotlin.ExperimentalStdlibApi`
freeCompilerArgs.add("-opt-in=kotlin.ExperimentalStdlibApi")
}
}
}
}
}
OR you can have something like this
kotlin {
sourceSets {
all {
languageSettings {
optIn("kotlin.uuid.ExperimentalUuidApi")
}
}
// OR Per target
commonTest {
languageSettings {
optIn("kotlin.uuid.ExperimentalUuidApi")
}
}
}
}
tapchicoma
02/08/2025, 12:40 PMkotlin {
compilerOptions.optIn(listOf("..."))
}
Giorgi
02/09/2025, 1:25 PMUnresolved reference.
and had to change to compilerOptions.optIn = listOf("...")
. that also did not work. still get errors like This declaration needs opt-in. Its usage must be marked with '@kotlin.ExperimentalStdlibApi' or '@OptIn(kotlin.ExperimentalStdlibApi::class)'
> compilerOptions {
> // For the usage of expect/actual warning
> freeCompilerArgs.add("-Xexpect-actual-classes")
> // For not needing to add ExperimentalCoroutinesApi
> freeCompilerArgs.add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi")
> // For not needing to add ExperimentalUuidApi
> freeCompilerArgs.add("-opt-in=kotlin.uuid.ExperimentalUuidApi")
> // For you specific case you would add kotlin.ExperimentalStdlibApi
> freeCompilerArgs.add("-opt-in=kotlin.ExperimentalStdlibApi")
> }
that will only work for that specific classes. Also other libraries will have their opt-in annotations for example compose.
it's just annoying to keep adding those annotations, especially for small projects that is just for learning.tapchicoma
02/10/2025, 8:37 AM@OptIn
preset in the compilation: https://kotl.in/issueGiorgi
02/10/2025, 11:22 AM