Copy and limited filter

I need to unpack (via copy) a jar file as well as filter some of its contents to replace some text in a few XML files. Is there a way to limit “the scope” of the CopySpec#filter application?

The reason I ask is that applying the filter over class files messes up their CAFEBABE bits. So I’d like to limit this to just the XML files.

The CopySpec has filesMatching which accepts a pattern and an action which extends ContentFilterable.


task unpack(type: Copy) {
    filesMatching('**/*.xml') {
        filter ...
1 Like

Sweet! Thanks @jjustinic