如何通过Gradle上传多个文件

时间:2016-04-06 21:44:40

标签: gradle upload

您能否建议将多个文件上传到远程WebDav服务器的任务?

我可以使用以下脚本实现它。它只有一个问题 - 它将文件添加到文件名

version = "1.0"

configurations {
    myConfig
}

artifacts{
    //files is a directory where upload files are placed
    for (def f : file("files").listFiles()) {
        myConfig f
    }
}

task publish(type: Upload) {
    configuration = configurations.myConfig

    repositories {
        maven {
            url "WEB_DAV_URL_HERE"
        }
    }

}

1 个答案:

答案 0 :(得分:0)

Gradle可以直接调用bash,Tanis.7x已经回答了这类问题:

task upload(type:Exec) {
      executable "/bin/sh"
      args "-c", "curl -k -F [...]"
   }
}

Gradle task to publish / upload android apk to Http Server

上传多个文件几乎不需要修改。

然后更改为how to upload file to server by curl,您可以修复它〜