本文介绍了无法排除Gradle复制任务的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个gradle脚本,我想在其中将3个目录复制到另一个文件夹中。但是我还必须排除目录。
这是我开始的树结构:
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
我要复制的文件夹为:
src > java > tms > common
src > java > tms > javaserver > common
src > java > tms > transaction > local
src > java > tms > transaction > files
这是我正在使用的Gradle命令:
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"
}
结果是创建了所有文件夹。
停靠下的所有文件夹都包括在内。 (当我仅选择 transaction 文件夹时,为什么还包括其他文件夹?)
exclude 指令根本不起作用。
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.
谢谢。
推荐答案
这应该有效:
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.
这篇关于无法排除Gradle复制任务的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!