On Github paweloczadly / advanced-gradle-training
Pawel Oczadly
task copy(type: Copy) { from 'src/main/resources' into 'build/resources' }
task complexCopy(type: Copy) { from('src/main/resources') { include '*.xml' exclude '**/secure*.properties' } from('deployment') from('config') { include '*.sql' into 'config' } into 'build/resources' }
. ├── config │ └── init.sql ├── deployment │ ├── prod.properties │ ├── qa.properties │ ├── qa2.properties │ └── staging.properties └── src └── main └── resources └── modules.xml
build ├── config │ ├── init.sql │ └── modules.xml ├── prod.properties └── staging.properties
task copy(type: Copy) { from ('config') { into 'config' } from ('src/main/resources') { into 'config' } from ('deployment') { exclude 'qa*' } into 'build' }
task rename(type: Copy) { from 'src/main/resources' into 'build' rename ('modules.xml', 'extensions.xml') }
Allows to rename file(s) during copy.
task rename(type: Copy) { from('src/main/resources') { rename { "intci-$it" } include '**/*.properties' } from('config') { rename { "jenkins-${(it - 'dev')}" } } into 'build' }
task unzip(type: Copy) { from zipTree('target.zip') into 'destination' }
task zip(type: Zip) { classifier = 'target' from 'src' }
. ├── config │ └── init.sql ├── deployment │ ├── prod.properties │ ├── qa.properties │ ├── qa2.properties │ └── staging.properties └── src └── main └── resources └── modules.xml
task zip(type: Zip) { classifier = 'qa-conf' from('deployment') { include '**/qa*.properties' } }
task unzip(type: Copy) { from zipTree('qa-conf.zip') into 'packages' }