diff --git a/app/build.gradle b/app/build.gradle
index 69e7ee500..3ecd67bde 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -24,6 +24,7 @@
* along with this program. If not, see .
*/
import com.github.spotbugs.snom.SpotBugsTask
+import com.nextcloud.talk.gradle.DownloadWebRtcTask
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
@@ -33,20 +34,6 @@ apply plugin: 'com.github.spotbugs'
apply plugin: 'io.gitlab.arturbosch.detekt'
apply plugin: "org.jlleitschuh.gradle.ktlint"
-def urlFile = { url, fileName ->
- File file = new File("$buildDir/download/${fileName}")
- file.parentFile.mkdirs()
- if (!file.exists()) {
- new URL(url).withInputStream { downloadStream ->
- file.withOutputStream { fileOut ->
- fileOut << downloadStream
- }
- }
- }
- files(file.absolutePath)
-}
-
-
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
@@ -147,7 +134,6 @@ android {
}
check.dependsOn 'spotbugsGplayDebug', 'lint', 'ktlintCheck', 'detekt'
- lint.dependsOn 'preBuild'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
@@ -176,10 +162,16 @@ ext {
powermockVersion = "2.0.9"
retrofit2Version = "2.9.0"
workVersion = "2.6.0"
- markwonVersion = "4.6.2"
+ markwonVersion = "4.6.2"
espressoVersion = "3.4.0"
}
+def webRtcVersion = "96.4664.0"
+tasks.register('downloadWebRtc', DownloadWebRtcTask){
+ version = webRtcVersion
+}
+preBuild.dependsOn('downloadWebRtc')
+
configurations.all {
exclude group: 'com.google.firebase', module: 'firebase-core'
exclude group: 'com.google.firebase', module: 'firebase-analytics'
@@ -253,8 +245,7 @@ dependencies {
kapt "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
implementation 'eu.davidea:flexible-adapter:5.1.0'
implementation 'eu.davidea:flexible-adapter-ui:1.0.0'
- implementation urlFile('https://github.com/nextcloud-releases/talk-clients-webrtc/releases/download/96.4664.0-RC1/libwebrtc-96.4664.0.aar',
- 'libwebrtc-96.4664.0.aar')
+ implementation fileTree(downloadWebRtc.getOutputPath())
implementation 'com.yarolegovich:lovely-dialog:1.1.1'
implementation 'com.yarolegovich:mp:1.1.6'
implementation 'me.zhanghai.android.effortlesspermissions:library:1.1.0'
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
new file mode 100644
index 000000000..2b70f1a88
--- /dev/null
+++ b/buildSrc/build.gradle
@@ -0,0 +1,22 @@
+/*
+* Nextcloud Talk application
+*
+* @author Álvaro Brey
+* Copyright (C) 2022 Álvaro Brey
+* Copyright (C) 2022 Nextcloud GmbH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*/
+
+apply plugin: 'groovy'
diff --git a/buildSrc/src/main/groovy/com/nextcloud/talk/gradle/DownloadWebRtcTask.groovy b/buildSrc/src/main/groovy/com/nextcloud/talk/gradle/DownloadWebRtcTask.groovy
new file mode 100644
index 000000000..36d69f1d1
--- /dev/null
+++ b/buildSrc/src/main/groovy/com/nextcloud/talk/gradle/DownloadWebRtcTask.groovy
@@ -0,0 +1,67 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Álvaro Brey
+ * Copyright (C) 2022 Álvaro Brey
+ * Copyright (C) 2022 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.nextcloud.talk.gradle
+
+import org.gradle.api.DefaultTask
+import org.gradle.api.provider.Property
+import org.gradle.api.tasks.CacheableTask
+import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.OutputFile
+import org.gradle.api.tasks.TaskAction
+
+@CacheableTask
+abstract class DownloadWebRtcTask extends DefaultTask {
+ @Input
+ abstract Property getVersion()
+
+ @OutputFile
+ File getLibFile() {
+ return new File(getOutputPath())
+ }
+
+ 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/${getFileName()}"
+ }
+
+ String getOutputPath() {
+ return "${project.buildDir}/download/${getFileName()}"
+ }
+
+ @TaskAction
+ def run() {
+ libFile.parentFile.mkdirs()
+ if (!libFile.exists()) {
+ logger.lifecycle("Downloading libWebRTC ${version.get()} from ${getDownloadUrl()}")
+ new URL(getDownloadUrl()).withInputStream { downloadStream ->
+ libFile.withOutputStream { fileOut ->
+ fileOut << downloadStream
+ }
+ }
+ }
+ }
+}