Skip to content
Advertisement

How to exclude all files under a directory in Gradle?

packagingOptions {
 exclude 'org/apache/commons/codec/language/bm/gen_approx_portuguese.txt'
}

For example, this one will exclude 1 file. But how to exclude all file under a directory?

like: org/apache/commons/codec/language/bm/
folder? . does not work 🙂

Advertisement

Answer

wild card can be used to enforce action to multiple file in directory. See this:-

packagingOptions {
 exclude 'org/apache/commons/codec/language/bm/*'
}

You can also exclude a file/directory with out specifying the full path this way:-

packagingOptions {
    exclude '**/language/bm/*'
}

Note: this will exclude any language/bm/ any where in the path

Advertisement