在gradle-cargo插件中配置可部署文件

时间:2015-04-03 08:05:53

标签: tomcat gradle

我正在尝试部署从存储库下载的文件。我无法猜到手头下载的文件版本。那么如何明确地引用这个文件呢?

Ex:我从存储库下载的文件看起来像myfile-1.0.134243.war。我无法明确地将此文件称为file = file("${buildDir}/repo/myfile-1.0.134243.war"),因为我对该版本一无所知。

这就是我的配置现在的样子。

cargo {
   containerId = 'tomcat7x'
   port = 8080
   deployable {
       file = file("${buildDir}/repo").listFiles()[0]
       context = "${project.name}"
   }
   remote {
       hostname = "mytomcatserver"
       username = "${tomcat_username}"
       password = "${tomcat_password}"
       timeout = 6000
   }
}

1 个答案:

答案 0 :(得分:0)

我在downloadtask中添加了doLast任务,从存储库下载artitact。在该任务中,我已经重命名了下载的文件,并删除了所有版本信息,然后将文件引用为 货物配置中file = file("${buildDir}/repo/${project.name}.war")

mydownloadtask.doLast{
   copy {
      from "${buildDir}/repo"
      into "${buildDir}/repo"
      rename (/[a-zA-Z0-9-_\.]+.[a-z]/, "${project.name}.war")
   }
}