Skip to content

Commit

Permalink
Bundle ASM version within the plugin (#637)
Browse files Browse the repository at this point in the history
* Bundle ASM version within the plugin

* Fix VisitorTest

* Changelog

* Bring unlockTransforms task back
  • Loading branch information
romtsn authored Jan 19, 2024
1 parent a5e8db4 commit 6865616
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Fixes

- Bundle ASM version within the plugin and bump it to `9.4` ([#637](https://github.com/getsentry/sentry-android-gradle-plugin/pull/637))
- This should fix the `java.lang.AssertionError: Class with incorrect id found` exception when using `kotlinx.serialization`
- Fall back to `findTask` if `assembleProvider` of AndroidVariant is null when hooking source bundle and native symbols upload tasks ([#639](https://github.com/getsentry/sentry-android-gradle-plugin/pull/639))

### Dependencies
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object LibsVersion {
const val MIN_SDK_VERSION = 21

const val JUNIT = "4.13.2"
const val ASM = "7.0" // compatibility matrix -> https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/instrumentation/InstrumentationContext#apiversion
const val ASM = "9.4" // compatibility matrix -> https://developer.android.com/reference/tools/gradle-api/7.1/com/android/build/api/instrumentation/InstrumentationContext#apiversion
const val SQLITE = "2.1.0"
const val SENTRY = "6.31.0"
}
Expand Down
4 changes: 2 additions & 2 deletions plugin-build/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ dependencies {
compileOnly(agp74.output)
compileOnly(Libs.PROGUARD)

compileOnly(Libs.ASM)
compileOnly(Libs.ASM_COMMONS)
implementation(Libs.ASM)
implementation(Libs.ASM_COMMONS)

compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin:${KotlinCompilerVersion.VERSION}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class VisitorTest(
val classContext = this.classContext ?: TestClassContext(instrumentable.fqName)
val classVisitor = instrumentable.getVisitor(
classContext,
Opcodes.ASM7,
Opcodes.ASM9,
classWriter,
parameters = TestSpanAddingParameters(inMemoryDir = tmpDir.root)
)
Expand All @@ -72,7 +72,7 @@ class VisitorTest(
// and pass it through CheckClassAdapter to verify that the bytecode is correct and can be accepted by JVM
val bytes = classWriter.toByteArray()
val verifyReader = ClassReader(bytes)
val checkAdapter = CheckClassAdapter(ClassWriter(0), true)
val checkAdapter = CheckClassAdapter(ClassWriter(ClassWriter.COMPUTE_FRAMES), true)
// val methodNamePrintingVisitor = MethodNamePrintingVisitor(Opcodes.ASM7, checkAdapter)
verifyReader.accept(checkAdapter, 0)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.sentry.android.gradle.integration

import io.sentry.android.gradle.util.GradleVersions
import io.sentry.android.gradle.util.PrintBuildOutputOnFailureRule
import io.sentry.android.gradle.util.SemVer
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.OutputStreamWriter
Expand Down Expand Up @@ -96,6 +98,10 @@ abstract class BaseSentryNonAndroidPluginTest(
print(providers.exec {
commandLine 'find', project.gradle.gradleUserHomeDir, '-type', 'f', '-name', 'transforms-3.lock', '-delete'
}.standardOutput.asText.get())
} else {
tasks.register('unlockTransforms', Exec) {
commandLine 'find', project.gradle.gradleUserHomeDir, '-type', 'f', '-name', 'transforms-3.lock', '-delete'
}
}
""".trimIndent()
}
Expand All @@ -107,6 +113,11 @@ abstract class BaseSentryNonAndroidPluginTest(
.withGradleVersion(gradleVersion)
.forwardStdOutput(writer)
.forwardStdError(writer)

if (SemVer.parse(gradleVersion) < GradleVersions.VERSION_7_5) {
// for newer Gradle versions transforms are unlocked at config time instead of a task
runner.appendArguments("unlockTransforms").build()
}
}

@After
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.sentry.android.gradle.integration

import io.sentry.android.gradle.integration.BaseSentryNonAndroidPluginTest.Companion.appendArguments
import io.sentry.android.gradle.util.GradleVersions
import io.sentry.android.gradle.util.PrintBuildOutputOnFailureRule
import io.sentry.android.gradle.util.SemVer
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.OutputStreamWriter
Expand Down Expand Up @@ -114,6 +117,10 @@ abstract class BaseSentryPluginTest(
print(providers.exec {
commandLine 'find', project.gradle.gradleUserHomeDir, '-type', 'f', '-name', 'transforms-3.lock', '-delete'
}.standardOutput.asText.get())
} else {
tasks.register('unlockTransforms', Exec) {
commandLine 'find', project.gradle.gradleUserHomeDir, '-type', 'f', '-name', 'transforms-3.lock', '-delete'
}
}
""".trimIndent()
}
Expand All @@ -126,6 +133,11 @@ abstract class BaseSentryPluginTest(
// .withDebug(true)
.forwardStdOutput(writer)
.forwardStdError(writer)

if (SemVer.parse(gradleVersion) < GradleVersions.VERSION_7_5) {
// for newer Gradle versions transforms are unlocked at config time instead of a task
runner.appendArguments("unlockTransforms").build()
}
}

@After
Expand Down
3 changes: 3 additions & 0 deletions plugin-build/src/test/kotlin/okhttp3/RealCall.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package okhttp3

class RealCall
3 changes: 3 additions & 0 deletions plugin-build/src/test/kotlin/okhttp3/Response.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package okhttp3

class Response
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package okhttp3.internal.connection

object ConnectInterceptor

0 comments on commit 6865616

Please sign in to comment.