mirror of
https://github.com/nextcloud/talk-android
synced 2025-02-02 04:32:02 +00:00
build: Make the DownloadWebRtcTask cacheable
This avoids having to redownload lib after clean (if build cache is enabled) Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
a92dcc075b
commit
bcc1b4ed2b
@ -348,21 +348,32 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CacheableTask
|
||||||
abstract class DownloadWebRtcTask extends DefaultTask {
|
abstract class DownloadWebRtcTask extends DefaultTask {
|
||||||
@Input
|
@Input
|
||||||
abstract Property<String> getVersion()
|
abstract Property<String> getVersion()
|
||||||
|
|
||||||
|
@OutputFile
|
||||||
|
File getLibFile() {
|
||||||
|
return new File("${project.buildDir}/download/${getFileName()}")
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFileName() {
|
||||||
|
def webRtcVersion = version.get()
|
||||||
|
return "libwebrtc-${webRtcVersion}.aar"
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDownloadUrl() {
|
||||||
|
def webRtcVersion = version.get()
|
||||||
|
return "https://github.com/nextcloud-releases/talk-clients-webrtc/releases/download/${webRtcVersion}-RC1/libwebrtc-${webRtcVersion}.aar"
|
||||||
|
}
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
def run() {
|
def run() {
|
||||||
def webRtcVersion = version.get()
|
libFile.parentFile.mkdirs()
|
||||||
def fileName = "libwebrtc-${webRtcVersion}.aar"
|
if (!libFile.exists()) {
|
||||||
def url = "https://github.com/nextcloud-releases/talk-clients-webrtc/releases/download/${webRtcVersion}-RC1/libwebrtc-${webRtcVersion}.aar"
|
new URL(getDownloadUrl()).withInputStream { downloadStream ->
|
||||||
|
libFile.withOutputStream { fileOut ->
|
||||||
File file = new File("${project.buildDir}/download/${fileName}")
|
|
||||||
file.parentFile.mkdirs()
|
|
||||||
if (!file.exists()) {
|
|
||||||
new URL(url).withInputStream { downloadStream ->
|
|
||||||
file.withOutputStream { fileOut ->
|
|
||||||
fileOut << downloadStream
|
fileOut << downloadStream
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user