mirror of
https://github.com/recloudstream/gradle.git
synced 2024-08-14 23:56:59 +00:00
use jar instead of jadx
This commit is contained in:
parent
900dd79458
commit
b33cad4ce8
6 changed files with 13 additions and 41 deletions
|
@ -11,8 +11,8 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
|
||||||
var apkinfo: ApkInfo? = null
|
var apkinfo: ApkInfo? = null
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
fun overrideUrl(url: String) {
|
fun overrideUrlPrefix(url: String) {
|
||||||
apkinfo!!.url = url
|
apkinfo!!.urlPrefix = url
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var pluginClassName: String? = null
|
internal var pluginClassName: String? = null
|
||||||
|
@ -21,8 +21,7 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
|
||||||
class ApkInfo(extension: CloudstreamExtension, release: String) {
|
class ApkInfo(extension: CloudstreamExtension, release: String) {
|
||||||
val cache = extension.userCache.resolve("cloudstream")
|
val cache = extension.userCache.resolve("cloudstream")
|
||||||
|
|
||||||
var url = "https://github.com/recloudstream/cloudstream/releases/download/${release}/app-debug.apk"
|
var urlPrefix = "https://github.com/recloudstream/cloudstream/releases/download/${release}"
|
||||||
val apkFile = cache.resolve("cloudstream.apk")
|
|
||||||
val jarFile = cache.resolve("cloudstream.jar")
|
val jarFile = cache.resolve("cloudstream.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ fun URL.download(file: File, progressLogger: ProgressLogger) {
|
||||||
while (inputStream.read(buf).also { read = it } >= 0) {
|
while (inputStream.read(buf).also { read = it } >= 0) {
|
||||||
os.write(buf, 0, read)
|
os.write(buf, 0, read)
|
||||||
processedBytes += read
|
processedBytes += read
|
||||||
progressLogger.progress("Downloading apk ${toLengthText(processedBytes)}/$sizeText")
|
progressLogger.progress("Downloading ${toLengthText(processedBytes)}/$sizeText")
|
||||||
}
|
}
|
||||||
os.flush()
|
os.flush()
|
||||||
finished = true
|
finished = true
|
||||||
|
|
|
@ -26,19 +26,11 @@ class ApkConfigurationProvider : IConfigurationProvider {
|
||||||
|
|
||||||
apkinfo.cache.mkdirs()
|
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()) {
|
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()))
|
val url = URL("${apkinfo.urlPrefix}/classes.jar")
|
||||||
Dex2jar.from(reader).topoLogicalSort().skipDebug(false).noCode(true).to(apkinfo.jarFile.toPath())
|
url.download(apkinfo.jarFile, createProgressLogger(project, "Download JAR"))
|
||||||
}
|
}
|
||||||
|
|
||||||
project.dependencies.add("compileOnly", project.files(apkinfo.jarFile))
|
project.dependencies.add("compileOnly", project.files(apkinfo.jarFile))
|
||||||
|
|
|
@ -14,9 +14,6 @@ abstract class CleanCacheTask : DefaultTask() {
|
||||||
val extension = project.extensions.getCloudstream()
|
val extension = project.extensions.getCloudstream()
|
||||||
val apkinfo = extension.apkinfo
|
val apkinfo = extension.apkinfo
|
||||||
if (apkinfo == null) return;
|
if (apkinfo == null) return;
|
||||||
if (apkinfo.apkFile.exists()) {
|
|
||||||
apkinfo.apkFile.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (apkinfo.jarFile.exists()) {
|
if (apkinfo.jarFile.exists()) {
|
||||||
apkinfo.jarFile.delete()
|
apkinfo.jarFile.delete()
|
||||||
|
|
|
@ -32,8 +32,7 @@ abstract class CompileDexTask : DefaultTask() {
|
||||||
|
|
||||||
@get:OutputFile
|
@get:OutputFile
|
||||||
abstract val pluginClassFile: RegularFileProperty
|
abstract val pluginClassFile: RegularFileProperty
|
||||||
|
|
||||||
@Suppress("UnstableApiUsage")
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
fun compileDex() {
|
fun compileDex() {
|
||||||
val android = project.extensions.getByName("android") as BaseExtension
|
val android = project.extensions.getByName("android") as BaseExtension
|
||||||
|
|
|
@ -9,6 +9,9 @@ import jadx.plugins.input.dex.DexInputPlugin
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
import org.gradle.api.tasks.TaskAction
|
import org.gradle.api.tasks.TaskAction
|
||||||
import java.util.function.Function
|
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() {
|
abstract class GenSourcesTask : DefaultTask() {
|
||||||
@TaskAction
|
@TaskAction
|
||||||
|
@ -18,26 +21,8 @@ abstract class GenSourcesTask : DefaultTask() {
|
||||||
|
|
||||||
val sourcesJarFile = apkinfo.cache.resolve("cloudstream-sources.jar")
|
val sourcesJarFile = apkinfo.cache.resolve("cloudstream-sources.jar")
|
||||||
|
|
||||||
val args = JadxArgs()
|
val url = URL("${apkinfo.urlPrefix}/app-sources.jar")
|
||||||
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
|
|
||||||
|
|
||||||
args.codeCache = NoOpCodeCache()
|
url.download(sourcesJarFile, createProgressLogger(project, "Download sources"))
|
||||||
args.codeWriterProvider = Function { SimpleCodeWriter(it) }
|
|
||||||
|
|
||||||
JadxDecompiler(args).use { decompiler ->
|
|
||||||
decompiler.registerPlugin(DexInputPlugin())
|
|
||||||
decompiler.load()
|
|
||||||
decompiler.save()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue