Skip to content

Commit d9d89d9

Browse files
committed
Move changes into replay module
1 parent 0e2a446 commit d9d89d9

File tree

6 files changed

+80
-91
lines changed

6 files changed

+80
-91
lines changed

sentry-android-replay/build.gradle.kts

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io.gitlab.arturbosch.detekt.Detekt
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
3+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34

45
plugins {
56
id("com.android.library")
@@ -70,7 +71,6 @@ kotlin { explicitApi() }
7071

7172
dependencies {
7273
api(projects.sentry)
73-
api(projects.sentryCompose)
7474

7575
compileOnly(libs.androidx.compose.ui.replay)
7676
implementation(kotlin(Config.kotlinStdLib, Config.kotlinStdLibVersionAndroid))
@@ -92,6 +92,80 @@ dependencies {
9292
testImplementation(libs.coil.compose)
9393
}
9494

95+
// Compile Compose110Helper.kt against Compose 1.10 where internal LayoutNode accessors
96+
// are mangled with module name "ui" (e.g. getChildren$ui()) instead of "ui_release"
97+
val compose110Classpath by
98+
configurations.creating {
99+
isCanBeConsumed = false
100+
isCanBeResolved = true
101+
attributes {
102+
attribute(Attribute.of("artifactType", String::class.java), "android-classes-jar")
103+
}
104+
}
105+
106+
val compose110KotlinCompiler by
107+
configurations.creating {
108+
isCanBeConsumed = false
109+
isCanBeResolved = true
110+
}
111+
112+
dependencies {
113+
//noinspection UseTomlInstead
114+
compose110Classpath("androidx.compose.ui:ui-android:1.10.0")
115+
//noinspection UseTomlInstead
116+
compose110KotlinCompiler("org.jetbrains.kotlin:kotlin-compiler-embeddable:2.2.0")
117+
}
118+
119+
val compileCompose110 by
120+
tasks.registering(JavaExec::class) {
121+
val sourceDir = file("src/compose110/kotlin")
122+
val outputDir = layout.buildDirectory.dir("classes/kotlin/compose110")
123+
val compileClasspathFiles = compose110Classpath.incoming.files
124+
125+
inputs.dir(sourceDir)
126+
inputs.files(compileClasspathFiles)
127+
outputs.dir(outputDir)
128+
129+
classpath = compose110KotlinCompiler
130+
mainClass.set("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
131+
132+
argumentProviders.add(
133+
CommandLineArgumentProvider {
134+
val cp = compileClasspathFiles.files.joinToString(File.pathSeparator)
135+
outputDir.get().asFile.mkdirs()
136+
listOf(
137+
sourceDir.absolutePath,
138+
"-classpath",
139+
cp,
140+
"-d",
141+
outputDir.get().asFile.absolutePath,
142+
"-jvm-target",
143+
"1.8",
144+
"-language-version",
145+
"1.9",
146+
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
147+
"-Xsuppress-version-warnings",
148+
"-no-stdlib",
149+
)
150+
}
151+
)
152+
}
153+
154+
// Make compose110 output available to the Android Kotlin compilation
155+
val compose110Output = files(compileCompose110.map { it.outputs.files })
156+
157+
tasks.withType<KotlinCompile>().configureEach {
158+
if (name == "compileReleaseKotlin" || name == "compileDebugKotlin") {
159+
dependsOn(compileCompose110)
160+
libraries.from(compose110Output)
161+
}
162+
}
163+
164+
// Include compose110 classes in the AAR
165+
android.libraryVariants.all {
166+
registerPreJavacGeneratedBytecode(project.files(compileCompose110.map { it.outputs.files }))
167+
}
168+
95169
tasks.withType<Detekt>().configureEach {
96170
// Target version of the generated JVM bytecode. It is used for type resolution.
97171
jvmTarget = JavaVersion.VERSION_1_8.toString()

sentry-compose/src/compose110/kotlin/io/sentry/compose/Compose110Helper.kt renamed to sentry-android-replay/src/compose110/kotlin/io/sentry/android/replay/viewhierarchy/Compose110Helper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"EXPOSED_FUNCTION_RETURN_TYPE",
77
)
88

9-
package io.sentry.compose
9+
package io.sentry.android.replay.viewhierarchy
1010

1111
import androidx.compose.ui.node.LayoutNode
1212
import androidx.compose.ui.node.NodeCoordinator

sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ComposeViewHierarchyNode.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import io.sentry.android.replay.util.toOpaque
3030
import io.sentry.android.replay.viewhierarchy.ViewHierarchyNode.GenericViewHierarchyNode
3131
import io.sentry.android.replay.viewhierarchy.ViewHierarchyNode.ImageViewHierarchyNode
3232
import io.sentry.android.replay.viewhierarchy.ViewHierarchyNode.TextViewHierarchyNode
33-
import io.sentry.compose.SentryLayoutNodeHelper
3433
import java.lang.ref.WeakReference
3534
import java.lang.reflect.Method
3635

sentry-compose/src/androidMain/kotlin/io/sentry/compose/SentryLayoutNodeHelper.kt renamed to sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/SentryLayoutNodeHelper.kt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"EXPOSED_FUNCTION_RETURN_TYPE",
77
)
88

9-
package io.sentry.compose
9+
package io.sentry.android.replay.viewhierarchy
1010

1111
import androidx.compose.ui.node.LayoutNode
12-
import org.jetbrains.annotations.ApiStatus
1312

1413
/**
1514
* Provides access to internal LayoutNode members that are subject to Kotlin name-mangling.
@@ -19,8 +18,7 @@ import org.jetbrains.annotations.ApiStatus
1918
* Compose >= 1.10. This class detects the version on first use and delegates to the correct
2019
* accessor.
2120
*/
22-
@ApiStatus.Internal
23-
public object SentryLayoutNodeHelper {
21+
internal object SentryLayoutNodeHelper {
2422
@Volatile private var compose110Helper: Compose110Helper? = null
2523
@Volatile private var useCompose110: Boolean? = null
2624

@@ -33,7 +31,7 @@ public object SentryLayoutNodeHelper {
3331
return helper
3432
}
3533

36-
public fun getChildren(node: LayoutNode): List<LayoutNode> {
34+
fun getChildren(node: LayoutNode): List<LayoutNode> {
3735
return if (useCompose110 == false) {
3836
node.children
3937
} else {
@@ -46,7 +44,7 @@ public object SentryLayoutNodeHelper {
4644
}
4745
}
4846

49-
public fun isTransparent(node: LayoutNode): Boolean {
47+
fun isTransparent(node: LayoutNode): Boolean {
5048
return if (useCompose110 == false) {
5149
node.outerCoordinator.isTransparent()
5250
} else {

sentry-compose/api/android/sentry-compose.api

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ public final class io/sentry/compose/SentryComposeTracingKt {
1414
public static final fun SentryTraced (Ljava/lang/String;Landroidx/compose/ui/Modifier;ZLkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
1515
}
1616

17-
public final class io/sentry/compose/SentryLayoutNodeHelper {
18-
public static final field $stable I
19-
public static final field INSTANCE Lio/sentry/compose/SentryLayoutNodeHelper;
20-
public final fun getChildren (Landroidx/compose/ui/node/LayoutNode;)Ljava/util/List;
21-
public final fun isTransparent (Landroidx/compose/ui/node/LayoutNode;)Z
22-
}
23-
2417
public final class io/sentry/compose/SentryModifier {
2518
public static final field $stable I
2619
public static final field INSTANCE Lio/sentry/compose/SentryModifier;

sentry-compose/build.gradle.kts

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import io.gitlab.arturbosch.detekt.Detekt
22
import org.jetbrains.dokka.gradle.DokkaTask
33
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
44
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
5-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
65

76
plugins {
87
alias(libs.plugins.kotlin.multiplatform)
@@ -119,80 +118,6 @@ android {
119118
}
120119
}
121120

122-
// Compile Compose110Helper.kt against Compose 1.10 where internal LayoutNode accessors
123-
// are mangled with module name "ui" (e.g. getChildren$ui()) instead of "ui_release"
124-
val compose110Classpath by
125-
configurations.creating {
126-
isCanBeConsumed = false
127-
isCanBeResolved = true
128-
attributes {
129-
attribute(Attribute.of("artifactType", String::class.java), "android-classes-jar")
130-
}
131-
}
132-
133-
val compose110KotlinCompiler by
134-
configurations.creating {
135-
isCanBeConsumed = false
136-
isCanBeResolved = true
137-
}
138-
139-
dependencies {
140-
//noinspection UseTomlInstead
141-
compose110Classpath("androidx.compose.ui:ui-android:1.10.0")
142-
//noinspection UseTomlInstead
143-
compose110KotlinCompiler("org.jetbrains.kotlin:kotlin-compiler-embeddable:2.2.0")
144-
}
145-
146-
val compileCompose110 by
147-
tasks.registering(JavaExec::class) {
148-
val sourceDir = file("src/compose110/kotlin")
149-
val outputDir = layout.buildDirectory.dir("classes/kotlin/compose110")
150-
val compileClasspathFiles = compose110Classpath.incoming.files
151-
152-
inputs.dir(sourceDir)
153-
inputs.files(compileClasspathFiles)
154-
outputs.dir(outputDir)
155-
156-
classpath = compose110KotlinCompiler
157-
mainClass.set("org.jetbrains.kotlin.cli.jvm.K2JVMCompiler")
158-
159-
argumentProviders.add(
160-
CommandLineArgumentProvider {
161-
val cp = compileClasspathFiles.files.joinToString(File.pathSeparator)
162-
outputDir.get().asFile.mkdirs()
163-
listOf(
164-
sourceDir.absolutePath,
165-
"-classpath",
166-
cp,
167-
"-d",
168-
outputDir.get().asFile.absolutePath,
169-
"-jvm-target",
170-
"1.8",
171-
"-language-version",
172-
"1.9",
173-
"-opt-in=androidx.compose.ui.ExperimentalComposeUiApi",
174-
"-Xsuppress-version-warnings",
175-
"-no-stdlib",
176-
)
177-
}
178-
)
179-
}
180-
181-
// Make compose110 output available to the Android Kotlin compilation
182-
val compose110Output = files(compileCompose110.map { it.outputs.files })
183-
184-
tasks.withType<KotlinCompile>().configureEach {
185-
if (name == "compileReleaseKotlinAndroid" || name == "compileDebugKotlinAndroid") {
186-
dependsOn(compileCompose110)
187-
libraries.from(compose110Output)
188-
}
189-
}
190-
191-
// Include compose110 classes in the AAR
192-
android.libraryVariants.all {
193-
registerPreJavacGeneratedBytecode(project.files(compileCompose110.map { it.outputs.files }))
194-
}
195-
196121
tasks.withType<Detekt>().configureEach {
197122
// Target version of the generated JVM bytecode. It is used for type resolution.
198123
jvmTarget = JavaVersion.VERSION_1_8.toString()

0 commit comments

Comments
 (0)