【问题标题】:How to upload multiple files by Gradle如何通过 Gradle 上传多个文件
【发布时间】:2016-04-08 18:17:30
【问题描述】:

您能否建议将多个文件上传到远程 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"
        }
    }

}

【问题讨论】:

  • 当然,为什么不呢。如果可以在 groovy 中完成,则可以在 gradle 中完成。如果可以在 java 代码或命令行实用程序中完成,则可以从 gradle 调用。
  • 我相信通过 gradle 是可能的。怎么样?
  • 您能否详细介绍一下您目前在 gradle 之外是如何做到这一点的?然后我可以指出如何在 gradle 中实现相同的目标。

标签: gradle upload


【解决方案1】:

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,就可以修好了~

【讨论】:

  • 我认为应该可以仅通过 gradle 上传文件(不带 bash)
猜你喜欢
  • 2018-11-01
  • 2016-10-08
  • 2015-04-28
  • 2019-12-23
  • 1970-01-01
  • 2021-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多