Selaa lähdekoodia

Move DownloadWebRtcTask to buildSrc for cleaner build.gradle

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Álvaro Brey 3 vuotta sitten
vanhempi
commit
ce3ff3f1a4

+ 1 - 33
app/build.gradle

@@ -24,6 +24,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  */
 import com.github.spotbugs.snom.SpotBugsTask
 import com.github.spotbugs.snom.SpotBugsTask
+import com.nextcloud.talk.gradle.DownloadWebRtcTask
 
 
 apply plugin: 'com.android.application'
 apply plugin: 'com.android.application'
 apply plugin: 'kotlin-android'
 apply plugin: 'kotlin-android'
@@ -348,39 +349,6 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
     }
     }
 }
 }
 
 
-@CacheableTask
-abstract class DownloadWebRtcTask extends DefaultTask {
-    @Input
-    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
-    def run() {
-        libFile.parentFile.mkdirs()
-        if (!libFile.exists()) {
-            new URL(getDownloadUrl()).withInputStream { downloadStream ->
-                libFile.withOutputStream { fileOut ->
-                    fileOut << downloadStream
-                }
-            }
-        }
-    }
-}
-
 tasks.register('downloadWebRtc', DownloadWebRtcTask){
 tasks.register('downloadWebRtc', DownloadWebRtcTask){
     version = webRtcVersion
     version = webRtcVersion
 }
 }

+ 22 - 0
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 <https://www.gnu.org/licenses/>.
+*/
+
+apply plugin: 'groovy'

+ 62 - 0
buildSrc/src/main/groovy/com/nextcloud/talk/gradle/DownloadWebRtcTask.groovy

@@ -0,0 +1,62 @@
+/*
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+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<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/${getFileName()}"
+    }
+
+    @TaskAction
+    def run() {
+        libFile.parentFile.mkdirs()
+        if (!libFile.exists()) {
+            new URL(getDownloadUrl()).withInputStream { downloadStream ->
+                libFile.withOutputStream { fileOut ->
+                    fileOut << downloadStream
+                }
+            }
+        }
+    }
+}