问题描述
我写了一个在我的本地tomcat实例中部署war文件的任务。
以下是gradle任务 -
任务部署(dependsOn:build){
删除'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
copy {
frombuild / libs
到D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps
包括ROOT.war
}
}
问题每次运行部署任务时,我都会面临更新ROOT.war文件但ROOT目录的内容未更新
我已检查文件的时间戳以确定哪些文件已更新。
预先感谢您的帮助!
我已经计算出来了,我需要包装任务在doLast {}块中。因此,最终的任务看起来像 -
pre $ task deploy(dependsOn:build){
doLast {
delete' D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT','D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat- 9.0.0.M18 / webapps / ROOT.war'
复制{
从build / libs
复制到D:/softwares/apache-tomcat-9.0.0.M18/apache -tomcat-9.0.0.M18 / webapps
includeROOT.war
}
}
}
I have written a task for deploying war file in my local tomcat instance. I have few issues in it and need help in it.
Following is gradle task-
task deploy (dependsOn: build){
delete 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
copy {
from "build/libs"
into "D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps"
include "ROOT.war"
}
}
Issue I am facing every time I run deploy task, its updating ROOT.war file but the contents of ROOT directory is not updated
I have checked the timestamps of file to determine which files are updated.
Thanks in advance for help!
I had figured in out, I need to wrap the tasks in doLast{} block. So final tasks looks like-
task deploy (dependsOn: build){
doLast{
delete 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT', 'D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps/ROOT.war'
copy {
from "build/libs"
into "D:/softwares/apache-tomcat-9.0.0.M18/apache-tomcat-9.0.0.M18/webapps"
include "ROOT.war"
}
}
}
这篇关于本地tomcat部署的Gradle任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!