I saw a dependencies {} inside a task definition, what does it mean?

In the following build.gradle there is a dependencies {....} block inside a task .

Will this override the project’s dependencies in this task? and where is this documented , there is no mention of dependencies() in https://docs.gradle.org/current/dsl/org.gradle.api.Task.html

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.

1 Like