preBuild
タスクを使用して、ビルド前にファイルをダウンロードし、this methodでダウンロードを実行できます。以下は、プライベートリポジトリを使用している場合は、あなたのapp
モジュール
android {
preBuild << {
def url = "https://bitbucket.org/HellGate/jquery-slider/raw/5ab0c31aaa57fb7d321076194f462b472f5f031e/index.html"
def file = new File('app/src/main/assets/index.html')
new URL(url).withInputStream{ i -> file.withOutputStream{ it << i }}
}
}
のassets
ディレクトリにファイルをダウンロードし、基本的な認証スキームusername:password
で資格情報を配置します。この場合
android {
preBuild << {
def url = "https://username:[email protected]/HellGate/jquery-slider/raw/5ab0c31aaa57fb7d321076194f462b472f5f031e/index.html"
def file = new File('app/src/main/assets/index.html')
new URL(url).withInputStream{ i -> file.withOutputStream{ it << i }}
}
}
、あなたが置くことができますそれらはlocal.properties
ファイル(資格情報をコミットしないため):
file_path=app/src/main/assets/index.html
ext_url=https://username:[email protected]/bertrandmartel/test/raw/c489ae46c3de9ad7089f53660a8de616af08265d/youtube.html
あなたpreBuild
タスクのプロパティ読む:[?のGradleで外部ファイルをダウンロードする方法]の
preBuild << {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
if (properties.containsKey("file_path") && properties.containsKey("ext_url")) {
def file = new File(properties.getProperty("file_path"))
def url = properties.getProperty("ext_url")
new URL(url).withInputStream{ i -> file.withOutputStream{ it << i }}
}
else{
println("no properties found")
}
}
可能な複製を(https://stackoverflow.com/questions/17123606/how-to-download-external- files-in-gradle) –