Gradle task for local tomcat deployment

和自甴很熟 提交于 2020-01-03 05:36:04

问题


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!


回答1:


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"
    }
  }
}


来源:https://stackoverflow.com/questions/44701309/gradle-task-for-local-tomcat-deployment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!