I have a gradle script in which I want to copy 3 directories into another folder. But I also have to exclude directories. This is the tree structure I start with:
src > java > tms > common
src > java > tms > dla
src > java > tms > server
src > java > tms > javaserver > common
src > java > tms > javaserver > dock > transaction > local
src > java > tms > javaserver > dock > transaction > tcd
src > java > tms > javaserver > dock > transaction > files
The folders I want to copy are:
src > java > tms > common
src > java > tms > javaserver > common
src > java > tms > transaction > local
src > java > tms > transaction > files
This is the Gradle command I am using:
task copyTmsCoreSharedFiles(type: Copy) {
from ('src/java/com/fedex/ground/tms')
include '**/common/*'
include '**/javaserver/common/*'
include '**/javaserver/dock/transaction/*'
exclude '**/javaserver/dock/transaction/tcd*'
into rootProject.rootDir.getAbsolutePath() +"/target-ant"+"/tmscoreshared"
}
The results are that all folders are created. All of the folders under dock are included. ( When I select only the transaction folder, why are the other folders included?) The exclude directive is not working at all.
Thanks.
This should work:
ext.dest = project.file("target-ant/tmscoreshared")
task copyTmsCoreSharedFiles(type: Copy) {
includeEmptyDirs = false
from ('src/java/com/fedex/ground/tms')
exclude '**/dla/**'
exclude '**/server/**'
exclude '**/tcd/**'
outputs.dir(dest)
}
task clean {
doLast {
dest.delete()
}
}
You can also find a demo here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With