问题描述
我添加了一个任务来将战争文件部署到Tomcat中。任务需要做的唯一事情就是将战争文件复制到TOMCAT位置。
有两种方法我可以考虑实现这个...但是对于gradle而言,我不太确定什么更传统/正确(或者它甚至是重要的)。
$ b
task myCopy(type:Copy)
myCopy.configure {
from ('source')
转换为('target')
include('*。war')
}
或
任务myCopy {
doLast {
copy {
from'source'
into'target'
include'* .war'
}
}
}
在大多数情况下(包括这一个),复制任务是更好的选择。除此之外,它会给你自动的最新检查。 copy 方法适用于(由于某种原因)您必须插入现有任务并且不能使用单独任务进行复制的情况。
您的 Copy 任务的代码可以简化为:
$ b $ (转换为('target')
include('*。b'pre> 任务myCopy(类型:复制)战争')
}
I'm adding a task to deploy war files to Tomcat .. the only thing that the task needs to do is copy the war file to the TOMCAT location.
There 2 ways that I can think of implementing this .. but being new to gradle, I'm not quite sure what's more conventional/right (or if it even matters).
task myCopy(type: Copy) myCopy.configure { from('source') into('target') include('*.war') }
or
task myCopy{ doLast{ copy { from 'source' into 'target' include '*.war' } } }
In most cases (including this one), the Copy task is the better choice. Among other things, it will give you automatic up-to-date checking. The copy method is meant for situations where (for some reason) you have to bolt on to an existing task and cannot use a separate task for copying.
The code for your Copy task can be simplified to:
task myCopy(type: Copy) { from('source') into('target') include('*.war') }
这篇关于在Gradle中复制文件的传统方式 - 使用复制任务或复制方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!