diff --git a/app/build.gradle b/app/build.gradle index c8b624fe4..e5f18c638 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' @@ -348,39 +349,6 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { } } -@CacheableTask -abstract class DownloadWebRtcTask extends DefaultTask { - @Input - abstract Property 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){ version = webRtcVersion } diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 000000000..11e63336f --- /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' \ No newline at end of file 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..0c2c0f614 --- /dev/null +++ b/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 . + */ + +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("${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 + } + } + } + } +} \ No newline at end of file