# Removing / Excluding Task from Dependency

**URL:** <https://discuss.gradle.org/t/removing-excluding-task-from-dependency/48479>\
**Category:** Help/Discuss\
**Created:** [May 14, 2024, 2:30pm UTC](https://discuss.gradle.org/t/removing-excluding-task-from-dependency/48479 "2024-05-14T14:30:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![austinarbor](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@austinarbor](https://discuss.gradle.org/u/austinarbor)\
**Post date:** [May 14, 2024, 2:30pm UTC](https://discuss.gradle.org/t/removing-excluding-task-from-dependency/48479/1 "2024-05-14T14:30:01Z")

</div>

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

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

```
