Is this the right way to remove highlight errors f...
# compose-desktop
j
Is this the right way to remove highlight errors for Composables that are using
ExperimentalMaterialApi
? The project is KMP, I know the
sourceSets.all.lanaguageSettings
is the multiplatform way, but both are not working for me, not sure what is the issue but I can only remove the error by adding the
OptInt(...)
to the composable function
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
    kotlinOptions.freeCompilerArgs += "-opt-in=androidx.compose.material.ExperimentalMaterialApi"
}

kotlin {
    android()
    jvm()

    sourceSets {
        all {
            languageSettings.optIn("androidx.compose.material.ExperimentalMaterialApi")
        }
        ...
    }
}
l
Maybe you also need the OptIn itself?
languageSettings.optIn("kotlin.RequiresOptIn")
j
I am going to try
Nop, it doesn't work 😞
l
Hmm... this is what I use in the root build.gradle of my project:
Copy code
subprojects {
  plugins.withType<org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper> {
    configure<org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension> {
      sourceSets.all {
        languageSettings {
          optIn("kotlin.RequiresOptIn")
          optIn("kotlin.ExperimentalStdlibApi")
          // remaining opt-ins
        }
      }
    }
  }
}
e
dunno why
languageSettings.optIn
doesn't work, but
Copy code
kotlin {
    targets.all {
        compilations.all {
            kotlinOptions.freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
        }
    }
}
should
j
nop 😕
l
Your first example is missing the
X
from
-X
, but languageSettings should work 🤔
j
I copied from the docs, but I usually see it with -X too
but neither work, that is strange
I will try to create a minimum repro, thanks both 🙂
minimal repro is not having this issue, I will have to investigate