Gradle doesn’t define a dependencies block for a Task. In a Groovy build script, delegation would have this work the same as if it were not inside of the task configuration block for most tasks.
However, the shadow plugin specifically adds a method on its ShadowJar task type for filtering dependencies. This is documented in the plugin documentation, shadowJar filtering dependencies. This has no relevancy on other Gradle tasks though.