I have a tree of files that I\'d like to copy with Gradle, and for some of the files (e.g. ending in .txt), I\'d like to do some property substitions. For example, I have:<
Thanks to the link from Opal in the comments, I found a solution. The link shows that it is possible to have multiple from
sources and each of these can have a separate expand
treatment. Thus, in my case, I only wanted to expand .txt
files, so I split the from
into two parts using include
& exclude
as follows:
task "copyAndroidAssets$flavor" (type: Copy,
dependsOn: ["cleanAndroidAssets", "copyAndroidRes$flavor"] ) {
from ("build/assets/${flavorLc}/release/") {
include '**/*.txt'
expand ( versionName: versionName, versionCode: versionCode )
}
from ("build/assets/${flavorLc}/release/") {
exclude '**/*.txt'
}
into '../android/assets'
expand ( versionName: myVersionName, versionCode: myVersionCode )
}