Gradle :File Opertions
https://www.safaribooksonline.com/library/view/gradle-beyond-the/9781449373801/ch01.html
Gradle: A trivial copy task configuration
task copyPoems(type: Copy) {
from 'text-files'
into 'build/poems'
}
Gradle: A copy task that copies all the poems except the one by Henley
task copyPoems(type: Copy) {
from 'text-files'
into 'build/poems'
exclude '**/*henley*'
}
Gradle: A copy task that only copies Shakespeare and Shelley
task copyPoems(type: Copy) {
from 'text-files'
into 'build/poems'
include '**/sh*.txt'
}
Gradle: A copy task taking files from more than one source directory
task complexCopy(type: Copy) {
from('src/main/templates') {
include '**/*.gtpl'
}
from('i18n')
from('config') {
exclude 'Development*.groovy'
}
into 'build/resources'
}
Gradle: A copy task mapping source directory structure onto a new destination structure
task complexCopy(type: Copy) {
from('src/main/templates') {
include '**/*.gtpl'
into 'templates'
}
from('i18n')
from('config') {
exclude 'Development*.groovy'
into 'config'
}
into 'build/resources'
}
Gradle: Renaming files using regular expressions
task rename(type: Copy) {
from 'source'
into 'dest'
rename(/file-template-(\d+)/, 'production-file-$1.txt')
}
Gradle: Renaming files programmatically
task rename(type: Copy) {
from 'source'
into 'dest'
rename { fileName ->
"production-file${(fileName - 'file-template')}"
}
}
Gradle: Copying a file with keyword expansion
versionId = '1.6'
task copyProductionConfig(type: Copy) {
from 'source'
include 'config.properties'
into 'build/war/WEB-INF/config'
expand([
databaseHostname: 'db.company.com',
version: versionId,
buildNumber: (int)(Math.random() * 1000),
date: new Date()
])
}
No comments:
Post a Comment