File tree 5 files changed +31
-128
lines changed
src/main/kotlin/io/github/chao2zhang
5 files changed +31
-128
lines changed Original file line number Diff line number Diff line change 1
1
plugins {
2
- id ' org.jetbrains.kotlin.jvm' version ' 1.4.31 '
3
- id ' org.jetbrains.dokka' version ' 1.4.30 '
2
+ id ' org.jetbrains.kotlin.jvm' version ' 1.4.32 '
3
+ id ' org.jetbrains.dokka' version ' 1.4.32 '
4
4
id ' java-gradle-plugin'
5
5
id ' com.vanniktech.maven.publish' version ' 0.14.2'
6
6
}
7
7
8
8
repositories {
9
9
google()
10
10
mavenCentral()
11
- jcenter {
12
- content {
13
- includeGroup " org.jetbrains.trove4j"
14
- includeGroup " org.jetbrains.kotlinx"
15
- }
16
- }
17
11
}
18
12
19
13
@@ -35,16 +29,8 @@ compileJava {
35
29
}
36
30
37
31
dependencies {
38
- implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31"
39
- constraints {
40
- implementation(" org.jetbrains.kotlin:kotlin-reflect:1.4.31" ) {
41
- because(" Android Gradle Plugin 4.1 depends on Kotlin 1.3.72 but we should not mix 1.3 and 1.4." )
42
- }
43
- implementation(" org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.31" ) {
44
- because(" Android Gradle Plugin 4.1 depends on Kotlin 1.3.72 but we should not mix 1.3 and 1.4." )
45
- }
46
- }
47
- implementation ' com.android.tools.build:gradle-api:4.1.3'
32
+ implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.32"
33
+ implementation ' com.android.tools.build:gradle-api:4.2.1'
48
34
implementation ' org.ow2.asm:asm:9.1'
49
- compileOnly ' com.android.tools.build:gradle:4.1.3 '
35
+ compileOnly ' com.android.tools.build:gradle:4.2.1 '
50
36
}
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ kotlin.code.style=official
2
2
3
3
GROUP =io.github.chao2zhang.livedatadebugger
4
4
POM_ARTIFACT_ID =livedatadebugger
5
- VERSION_NAME =0.0.3
5
+ VERSION_NAME =0.1.0
6
6
7
7
POM_NAME =LiveDataDebugger
8
8
POM_DESCRIPTION =The gradle plugin to make LiveData universally debuggable
Original file line number Diff line number Diff line change
1
+ package io.github.chao2zhang
2
+
3
+ import com.android.build.api.instrumentation.*
4
+ import org.objectweb.asm.ClassVisitor
5
+
6
+ @Suppress(" UnstableApiUsage" )
7
+ abstract class LiveDataClassVisitorFactory : AsmClassVisitorFactory <InstrumentationParameters > {
8
+
9
+ override fun createClassVisitor (classContext : ClassContext , nextClassVisitor : ClassVisitor ) =
10
+ LiveDataClassVisitor (nextClassVisitor)
11
+
12
+ override fun isInstrumentable (classData : ClassData ) =
13
+ classData.className == " androidx.lifecycle.LiveData"
14
+ }
Original file line number Diff line number Diff line change 1
1
package io.github.chao2zhang
2
2
3
+ import com.android.build.api.extension.AndroidComponentsExtension
4
+ import com.android.build.api.instrumentation.FramesComputationMode
5
+ import com.android.build.api.instrumentation.InstrumentationScope
3
6
import com.android.build.gradle.AppExtension
4
7
import com.android.build.gradle.AppPlugin
5
8
import org.gradle.api.Plugin
@@ -8,10 +11,14 @@ import org.gradle.api.Project
8
11
class LiveDataDebuggerPlugin : Plugin <Project > {
9
12
10
13
override fun apply (project : Project ) {
11
- project.plugins.withType(AppPlugin ::class .java) { plugin ->
12
- project.extensions.configure(AppExtension ::class .java) { appExtension ->
13
- appExtension.registerTransform(LiveDataTransform (project.logger))
14
- }
14
+ val androidComponents = project.extensions.getByType(AndroidComponentsExtension ::class .java)
15
+ androidComponents.onVariants {
16
+ it.transformClassesWith(
17
+ classVisitorFactoryImplClass = LiveDataClassVisitorFactory ::class .java,
18
+ scope = InstrumentationScope .ALL ,
19
+ instrumentationParamsConfig = { }
20
+ )
21
+ it.setAsmFramesComputationMode(FramesComputationMode .COMPUTE_FRAMES_FOR_INSTRUMENTED_METHODS )
15
22
}
16
23
}
17
24
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments