Is there a way to suppress `Opt-in requirement mar...
# gradle
j
Is there a way to suppress
Opt-in requirement marker XXX is unresolved
warnings? You apparently can't add opt-in args after dependency resolution because freeCompilerArgs is frozen so it makes convention plugins quite annoying because you have to either
@OptIn
everywhere in source, or deal with hundreds of useless build warnings if you opt in with your conventions plugins.
t
Relevant issue: https://youtrack.jetbrains.com/issue/KT-48419/Using-a-RequiresOptIn-API-that-does-not-exist-should-have-an-option-to-not-output-a-warning Not sure workaround is possible if you try to modify this argument based on the resolved dependencies
j
the comments indicate this is not possible anymore 😕
hmm this seems to work, but it really sucks since the dependency has to be explicit as this no longer relies on resolution, its just watching things get added to DependencyHandler
Copy code
configurations.configureEach { c ->
      if (c.isCanBeResolved) {
        c.dependencies.whenObjectAdded {
          if (it is ExternalDependency) {
            if (it.group == "androidx.compose.animation") {
              tasks.withType(KotlinCompilationTask::class.java).configureEach { task ->
                // We only want to apply this compiler arg for modules that use compose
                with(task.compilerOptions.freeCompilerArgs) {
                  add("-opt-in=androidx.compose.animation.ExperimentalAnimationApi")
                  add("-opt-in=androidx.compose.animation.ExperimentalSharedTransitionApi")
                }
              }
            }
            if (it.group == "kotlinx.coroutines") {
              tasks.withType(KotlinCompilationTask::class.java).configureEach { task ->
                // We only want to apply this compiler arg for modules that use compose
                with(task.compilerOptions.freeCompilerArgs) {
                  add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi")
                  add("-opt-in=kotlinx.coroutines.FlowPreview")
                }
              }
            }
          }
        }
      }
    }
t
compiler team said that they are working on the solution via https://youtrack.jetbrains.com/issue/KT-78277
j
Hopefully that will also work for deprecation warnings, i'd like to try suppressing those globally but
-Xsuppress-warning=DEPRECATION
does nothing