Gradle: Copy selected files without using the exclude pattern

Copying files in Gradle is very intuitive. It’s easy enough to filter out unwanted files using the exclude pattern. Example (see documentation): task copyTaskWithPatterns(type: Copy) { from ‘src/main/webapp’ into ‘build/explodedWar’ include ‘**/*.html’ include ‘**/*.jsp’ exclude { details -> details.file.name.endsWith(‘.html’) && details.file.text.contains(‘staging’) } } The problem occurs, when you only want Read more…