Get libwebrtc using gradle

Stephen Paul Weber created

Change summary

.builds/debian-stable.yml |  5 -----
build.gradle              | 16 +++++++++++++++-
2 files changed, 15 insertions(+), 6 deletions(-)

Detailed changes

.builds/debian-stable.yml 🔗

@@ -22,11 +22,6 @@ tasks:
     echo y | android/cmdline-tools/tools/bin/sdkmanager "build-tools;29.0.2"
     touch ~/.android/repositories.cfg
     yes | android/cmdline-tools/tools/bin/sdkmanager --licenses
-- libwebrtc: |
-    cd cheogram-android
-    mkdir libs
-    cd libs
-    wget -qO libwebrtc.aar https://cloudflare-ipfs.com/ipfs/QmeqMiLxHi8AAjXobxr3QTfa1bSSLyAu86YviAqQnjxCjM/libwebrtc.aar
 - build: |
     cd cheogram-android
     ./gradlew assembleCheogramFreeSystemDebug

build.gradle 🔗

@@ -18,6 +18,20 @@ repositories {
     jcenter()
 }
 
+// https://stackoverflow.com/a/38105112/8611
+def urlFile = { url, name ->
+    File file = new File("$buildDir/download/${name}")
+    file.parentFile.mkdirs()
+    if (!file.exists()) {
+        new URL(url).withInputStream { downloadStream ->
+            file.withOutputStream { fileOut ->
+                fileOut << downloadStream
+            }
+        }
+    }
+    files(file.absolutePath)
+}
+
 configurations {
     playstoreImplementation
     compatImplementation
@@ -77,7 +91,7 @@ dependencies {
 
     implementation 'com.google.guava:guava:30.1.1-android'
     quicksyImplementation 'io.michaelrocks:libphonenumber-android:8.12.36'
-    implementation fileTree(include: ['libwebrtc.aar'], dir: 'libs')
+    implementation urlFile('https://cloudflare-ipfs.com/ipfs/QmeqMiLxHi8AAjXobxr3QTfa1bSSLyAu86YviAqQnjxCjM/libwebrtc.aar', 'libwebrtc.aar')
 }
 
 ext {