Removing / Excluding Task from Dependency

When using both the spotless plugin and ksp plugin, spotlessApply seems to run kspKotlin and kspTestKotlin which slows down the task.

From the cli, I can prevent this by running ./gradlew spotlessApply -x kspKotlin -x kspTestKotlin, but how can I configure the task in the build file itself so I don’t have to pass the exclusions manually every time?

I tried some different variations of this, but it did not have any effect

tasks {
  spotlessApply {
    val exclude = listOf("kspKotlin", "kspTestKotlin").mapNotNull { findByPath(it) }
    setDependsOn(dependsOn - exclude)
  }
}