how to download external files in gradle?

前端 未结 7 536
你的背包
你的背包 2020-12-02 09:50

I have a gradle project which requires some data files available somewhere on the internet using http. The goal is that this immutable remote file is pulled once upon first

7条回答
  •  被撕碎了的回忆
    2020-12-02 10:32

    Using following plugin:

    plugins {
        id "de.undercouch.download" version "3.4.3"
    }
    

    For a task which has the purpose of only downloading

    task downloadFile(type: Download) {
        src DownloadURL
        dest destDir
    }
    

    For including download option into your task:

    download {
        src DownloadURL
        dest destDir
    }
    

    For including download option with multiple downloads into your task:

    task downloadFromURLs(){
        download {
            src ([
                   DownloadURL1,
                   DownloadURL2,
                   DownloadURL3
            ])
            dest destDir
        }
    }
    

    Hope it helped :)

提交回复
热议问题