Upgrade dex-member-list version to 4.1.1
The old dex-method-list version 3.0.0 used a dalvik-dx that could not parse MethodType introduced in jvm-7 bytecode.
This commit is contained in:
@@ -98,6 +98,7 @@ extra["customDepsOrg"] = "kotlin.build"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://maven.google.com/")
|
||||
maven("https://packages.jetbrains.team/maven/p/ij/intellij-dependencies")
|
||||
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies")
|
||||
gradlePluginPortal()
|
||||
@@ -172,7 +173,7 @@ dependencies {
|
||||
implementation("net.rubygrapefruit:native-platform:${property("versions.native-platform")}")
|
||||
implementation("net.rubygrapefruit:native-platform-windows-amd64:${property("versions.native-platform")}")
|
||||
implementation("net.rubygrapefruit:native-platform-windows-i386:${property("versions.native-platform")}")
|
||||
implementation("com.jakewharton.dex:dex-method-list:3.0.0")
|
||||
implementation("com.jakewharton.dex:dex-member-list:4.1.1")
|
||||
|
||||
implementation("gradle.plugin.com.github.johnrengelman:shadow:${rootProject.extra["versions.shadow"]}")
|
||||
implementation("net.sf.proguard:proguard-gradle:6.2.2")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import com.jakewharton.dex.*
|
||||
import com.jakewharton.dex.DexParser.Companion.toDexParser
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
@@ -56,18 +57,18 @@ abstract class DexMethodCount : DefaultTask() {
|
||||
|
||||
@TaskAction
|
||||
fun invoke() {
|
||||
val methods = dexMethods(jarFile)
|
||||
val methods = jarFile.toDexParser().listMethods()
|
||||
val counts = methods.getCounts().also { this.counts = it }
|
||||
outputDetails(counts)
|
||||
}
|
||||
|
||||
private fun List<DexMethod>.getCounts(): Counts {
|
||||
val byPackage = this.groupingBy { it.`package` }.eachCount()
|
||||
val byClass = this.groupingBy { it.declaringType }.eachCount()
|
||||
val byClass = this.groupingBy { it.declaringTypeFqn }.eachCount()
|
||||
|
||||
val ownPackages = ownPackages.map { list -> list.map { "$it." } }
|
||||
val byOwnPackages = if (ownPackages.isPresent) {
|
||||
this.partition { method -> ownPackages.get().any { method.declaringType.startsWith(it) } }.let {
|
||||
this.partition { method -> ownPackages.get().any { method.declaringTypeFqn.startsWith(it) } }.let {
|
||||
it.first.size to it.second.size
|
||||
}
|
||||
} else (null to null)
|
||||
@@ -167,5 +168,9 @@ fun Project.dexMethodCount(action: DexMethodCount.() -> Unit): TaskProvider<DexM
|
||||
return dexMethodCount
|
||||
}
|
||||
|
||||
private val DexMethod.`package`: String get() = declaringType.substringBeforeLast('.')
|
||||
private val DexMethod.`package`: String get() = declaringTypeFqn.substringBeforeLast('.')
|
||||
private fun Int.padRight() = toString().padStart(5, ' ')
|
||||
|
||||
private val DexMethod.declaringTypeFqn: String get() {
|
||||
return this.render(false).substringBefore(' ')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user