Skip to content

Add note about output caching and inherited functions#2094

Open
bric3 wants to merge 2 commits into
GradleUp:mainfrom
bric3:patch-1
Open

Add note about output caching and inherited functions#2094
bric3 wants to merge 2 commits into
GradleUp:mainfrom
bric3:patch-1

Conversation

@bric3

@bric3 bric3 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Clarify that inherited CopySpec functions disable output caching, indeed, most are actually invoking the DefaultCopySpec.appendCopyAction which disable output caching.

Changelog not updated as it's not a behavioral change.


  • CHANGELOG's "Unreleased" section has been updated, if applicable.

Clarify that inherited CopySpec functions disable output caching, indeed, most are actually invoking the `DefaultCopySpec.appendCopyAction` which disable output caching.
@bric3 bric3 changed the title chore: Add note about output caching and inherited functions Add note about output caching and inherited functions Jul 8, 2026
[`filesMatching`][Jar.filesMatching], [`filesNotMatching`][Jar.filesNotMatching], or [`eachFile`][Jar.eachFile] functions
to set their `duplicatesStrategy` to `INCLUDE` or `WARN`.

Note, however that functions inherited from [`CopySpec`][CopySpec], such as [`filesMatching`][Jar.filesMatching], [`filesNotMatching`][Jar.filesNotMatching], [`eachFile`][Jar.eachFile], or others, disable the output caching.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no footer link for CopySpec. And any source for 'disable the output caching'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

So I didn't found anything in user doc, but found the information inside the gradle source (9.6 at least)

https://github.com/gradle/gradle/blob/c5f8b7305a09bf706a0270593cdda9372e74ad48/platforms/core-configuration/file-operations/src/main/java/org/gradle/api/internal/file/copy/DefaultCopySpec.java#L510

The DefaultCopySpec methods like fileMatching end up calling eachFile which toggle a flag hasCustomActions that is consulted in AbstractCopyTask the parent to all archive tasks.

https://github.com/gradle/gradle/blob/c5f8b7305a09bf706a0270593cdda9372e74ad48/subprojects/core/src/main/java/org/gradle/api/tasks/AbstractCopyTask.java#L106-L109

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually I walked history a bit and this is pretty old, it was introduced in Gradle 3.2

gradle/gradle@510d032

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants