diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt index e64e92a..9893cef 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/CloudstreamExtension.kt @@ -11,8 +11,8 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) { var apkinfo: ApkInfo? = null internal set - fun overrideUrl(url: String) { - apkinfo!!.url = url + fun overrideUrlPrefix(url: String) { + apkinfo!!.urlPrefix = url } internal var pluginClassName: String? = null @@ -21,8 +21,7 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) { class ApkInfo(extension: CloudstreamExtension, release: String) { val cache = extension.userCache.resolve("cloudstream") - var url = "https://github.com/recloudstream/cloudstream/releases/download/${release}/app-debug.apk" - val apkFile = cache.resolve("cloudstream.apk") + var urlPrefix = "https://github.com/recloudstream/cloudstream/releases/download/${release}" val jarFile = cache.resolve("cloudstream.jar") } diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/DownloadUtils.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/DownloadUtils.kt index 451cfd3..afda2fb 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/DownloadUtils.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/DownloadUtils.kt @@ -39,7 +39,7 @@ fun URL.download(file: File, progressLogger: ProgressLogger) { while (inputStream.read(buf).also { read = it } >= 0) { os.write(buf, 0, read) processedBytes += read - progressLogger.progress("Downloading apk ${toLengthText(processedBytes)}/$sizeText") + progressLogger.progress("Downloading ${toLengthText(processedBytes)}/$sizeText") } os.flush() finished = true diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/configuration/ApkConfigurationProvider.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/configuration/ApkConfigurationProvider.kt index 913844a..2f1627f 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/configuration/ApkConfigurationProvider.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/configuration/ApkConfigurationProvider.kt @@ -26,19 +26,11 @@ class ApkConfigurationProvider : IConfigurationProvider { apkinfo.cache.mkdirs() - if (!apkinfo.apkFile.exists()) { - project.logger.lifecycle("Downloading apk") - - val url = URL(apkinfo.url) - - url.download(apkinfo.apkFile, createProgressLogger(project, "Download apk")) - } - if (!apkinfo.jarFile.exists()) { - project.logger.lifecycle("Converting apk to jar") + project.logger.lifecycle("Fetching JAR") - val reader: BaseDexFileReader = MultiDexFileReader.open(Files.readAllBytes(apkinfo.apkFile.toPath())) - Dex2jar.from(reader).topoLogicalSort().skipDebug(false).noCode(true).to(apkinfo.jarFile.toPath()) + val url = URL("${apkinfo.urlPrefix}/classes.jar") + url.download(apkinfo.jarFile, createProgressLogger(project, "Download JAR")) } project.dependencies.add("compileOnly", project.files(apkinfo.jarFile)) diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CleanCacheTask.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CleanCacheTask.kt index 0935c2c..f4f8121 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CleanCacheTask.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CleanCacheTask.kt @@ -14,9 +14,6 @@ abstract class CleanCacheTask : DefaultTask() { val extension = project.extensions.getCloudstream() val apkinfo = extension.apkinfo if (apkinfo == null) return; - if (apkinfo.apkFile.exists()) { - apkinfo.apkFile.delete() - } if (apkinfo.jarFile.exists()) { apkinfo.jarFile.delete() diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CompileDexTask.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CompileDexTask.kt index c63df34..b49e4ee 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CompileDexTask.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/CompileDexTask.kt @@ -32,8 +32,7 @@ abstract class CompileDexTask : DefaultTask() { @get:OutputFile abstract val pluginClassFile: RegularFileProperty - - @Suppress("UnstableApiUsage") + @TaskAction fun compileDex() { val android = project.extensions.getByName("android") as BaseExtension diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/GenSourcesTask.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/GenSourcesTask.kt index 5e186c2..7e4a233 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/GenSourcesTask.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/GenSourcesTask.kt @@ -9,6 +9,9 @@ import jadx.plugins.input.dex.DexInputPlugin import org.gradle.api.DefaultTask import org.gradle.api.tasks.TaskAction import java.util.function.Function +import java.net.URL +import com.lagradost.cloudstream3.gradle.download +import com.lagradost.cloudstream3.gradle.createProgressLogger abstract class GenSourcesTask : DefaultTask() { @TaskAction @@ -18,26 +21,8 @@ abstract class GenSourcesTask : DefaultTask() { val sourcesJarFile = apkinfo.cache.resolve("cloudstream-sources.jar") - val args = JadxArgs() - args.setInputFile(apkinfo.apkFile) - args.outDirSrc = sourcesJarFile - args.isSkipResources = true - args.isShowInconsistentCode = true - args.isRespectBytecodeAccModifiers = true - args.isFsCaseSensitive = true - args.isGenerateKotlinMetadata = false - args.isDebugInfo = false - args.isInlineAnonymousClasses = false - args.isInlineMethods = false - args.isReplaceConsts = false + val url = URL("${apkinfo.urlPrefix}/app-sources.jar") - args.codeCache = NoOpCodeCache() - args.codeWriterProvider = Function { SimpleCodeWriter(it) } - - JadxDecompiler(args).use { decompiler -> - decompiler.registerPlugin(DexInputPlugin()) - decompiler.load() - decompiler.save() - } + url.download(sourcesJarFile, createProgressLogger(project, "Download sources")) } } \ No newline at end of file