Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
# AndroidX required by AGP >= 3.6.x
android.useAndroidX=true
# AGP 9+ migration opt-outs until we remove kotlin-android plugin and adopt built-in Kotlin.
android.builtInKotlin=false
android.builtInKotlin=true
android.newDsl=false

android.disableAgpUpgradePrompt=true
Expand Down Expand Up @@ -60,3 +60,6 @@ POM_DEVELOPER_URL=https://github.com/getsentry/
systemProp.org.gradle.internal.http.socketTimeout=120000

android.nonTransitiveRClass=true

# Session Replay runs its unit tests against several Compose versions as AGP test suites.
android.experimental.testSuiteSupport=true
5 changes: 2 additions & 3 deletions sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.errorprone)
alias(libs.plugins.gradle.versions)
Expand Down Expand Up @@ -105,7 +104,7 @@ dependencies {
compileOnly(projects.sentryAndroidFragment)
compileOnly(projects.sentryAndroidTimber)
compileOnly(projects.sentryAndroidReplay)
compileOnly(projects.sentryCompose)
// SPIKE compileOnly(projects.sentryCompose)
compileOnly(projects.sentryAndroidDistribution)

// lifecycle processor, session tracking
Expand Down Expand Up @@ -140,7 +139,7 @@ dependencies {
testImplementation(projects.sentryAndroidFragment)
testImplementation(projects.sentryAndroidTimber)
testImplementation(projects.sentryAndroidReplay)
testImplementation(projects.sentryCompose)
// SPIKE testImplementation(projects.sentryCompose)
testImplementation(projects.sentryAndroidNdk)

testImplementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
import io.sentry.android.timber.SentryTimberIntegration;
import io.sentry.cache.PersistingOptionsObserver;
import io.sentry.cache.PersistingScopeObserver;
import io.sentry.compose.gestures.ComposeGestureTargetLocator;
import io.sentry.compose.viewhierarchy.ComposeViewHierarchyExporter;
import io.sentry.internal.debugmeta.NoOpDebugMetaLoader;
import io.sentry.internal.gestures.GestureTargetLocator;
import io.sentry.internal.modules.NoOpModulesLoader;
Expand Down Expand Up @@ -240,7 +238,8 @@ static void initializeIntegrationsAndProcessors(
SENTRY_COMPOSE_GESTURE_INTEGRATION_CLASS_NAME, options));

if (isComposeAvailable) {
gestureTargetLocators.add(new ComposeGestureTargetLocator(options.getLogger()));
// SPIKE gestureTargetLocators.add(new
// ComposeGestureTargetLocator(options.getLogger()));
}
options.setGestureTargetLocators(gestureTargetLocators);
}
Expand All @@ -251,7 +250,8 @@ static void initializeIntegrationsAndProcessors(
SENTRY_COMPOSE_VIEW_HIERARCHY_INTEGRATION_CLASS_NAME, options)) {

final List<ViewHierarchyExporter> viewHierarchyExporters = new ArrayList<>(1);
viewHierarchyExporters.add(new ComposeViewHierarchyExporter(options.getLogger()));
// SPIKE viewHierarchyExporters.add(new
// ComposeViewHierarchyExporter(options.getLogger()));
options.setViewHierarchyExporters(viewHierarchyExporters);
}

Expand Down
1 change: 0 additions & 1 deletion sentry-android-distribution/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
id("io.sentry.detekt")
id("io.sentry.spotless")
id("io.sentry.jdk-target")
Expand Down
1 change: 0 additions & 1 deletion sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.detekt")
id("io.sentry.spotless")
Expand Down
1 change: 0 additions & 1 deletion sentry-android-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.detekt")
id("io.sentry.spotless")
Expand Down
1 change: 0 additions & 1 deletion sentry-android-navigation3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.gradle.versions)
id("io.sentry.detekt")
Expand Down
1 change: 0 additions & 1 deletion sentry-android-ndk-outproc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.spotless")
id("io.sentry.jdk-target")
Expand Down
1 change: 0 additions & 1 deletion sentry-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import org.jetbrains.kotlin.config.KotlinCompilerVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.spotless")
id("io.sentry.jdk-target")
Expand Down
134 changes: 114 additions & 20 deletions sentry-android-replay/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import com.android.build.api.variant.HasHostTestsBuilder
import com.android.build.api.variant.HostTestBuilder
import com.android.build.api.variant.HasTestSuites
import com.android.build.api.variant.TestSuiteSourceSet
import io.gitlab.arturbosch.detekt.Detekt
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.gradle.versions)
id("io.sentry.detekt")
Expand Down Expand Up @@ -38,35 +37,41 @@ android {

buildFeatures { compose = true }

// SPIKE: built-in Kotlin requires test and main code to share one JVM target.
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

composeOptions { kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() }

buildTypes {
getByName("debug") { consumerProguardFiles("proguard-rules.pro") }
getByName("release") { consumerProguardFiles("proguard-rules.pro") }
composeUiTestVersions.keys.forEach { name ->
create(name) {
initWith(getByName("release"))
matchingFallbacks += "release"
}
}
}

// AGP 9 only generates unit tests for the testBuildType. The debug variant is
// disabled, so unit tests must target release to run at all.
testBuildType = "release"

kotlin {
compilerOptions.jvmTarget = JvmTarget.JVM_1_8
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

testOptions {
animationsDisabled = true
unitTests.apply {
isReturnDefaultValues = true
isIncludeAndroidResources = true
}
composeUiTestVersions.keys.forEach { name ->
customSuites.create(name) {
targetVariants += "release"
targets.create("jvm")
hostJar { enableAndroidResources = true }
useJunitEngine {
includeEngines += "junit-vintage"
enginesDependencies.add("org.junit.vintage:junit-vintage-engine:5.12.2")
enginesDependencies.add("org.junit.platform:junit-platform-launcher:1.12.2")
}
}
}
}

lint {
Expand All @@ -85,13 +90,24 @@ android {

androidComponents.beforeVariants {
it.enable = !Config.Android.shouldSkipDebugVariant(it.buildType)
if (it.buildType in composeUiTestVersions) {
(it as HasHostTestsBuilder).hostTests[HostTestBuilder.UNIT_TEST_TYPE]?.enable = true
}
androidComponents.onVariants { variant ->
(variant as HasTestSuites).suites.values.forEach { suite ->
suite.sources.filterIsInstance<TestSuiteSourceSet.HostJar>().forEach {
it.kotlin?.addStaticSourceDirectory("src/test/java")
it.java?.addStaticSourceDirectory("src/test/java")
it.resources.addStaticSourceDirectory("src/test/resources")
}
}
}
}

kotlin { explicitApi() }
kotlin {
explicitApi()
compilerOptions.jvmTarget = JvmTarget.JVM_21 // SPIKE
compilerOptions.languageVersion = KotlinVersion.KOTLIN_1_9
compilerOptions.apiVersion = KotlinVersion.KOTLIN_1_9
}

dependencies {
api(projects.sentry)
Expand All @@ -117,9 +133,16 @@ dependencies {
testImplementation(libs.coil.compose)
}

composeUiTestVersions.forEach { (buildType, version) ->
composeUiTestVersions.forEach { (suite, version) ->
val variantSuite = "release${suite.replaceFirstChar { it.uppercase() }}"
configurations
.matching { it.name == "${buildType}UnitTestRuntimeClasspath" }
.matching { it.name == "${variantSuite}Implementation" }
.configureEach { extendsFrom(configurations.testImplementation.get()) }
configurations
.matching {
it.name == "${variantSuite}RuntimeClasspath" ||
it.name == "${variantSuite}HostRuntimeClasspath"
}
.configureEach {
resolutionStrategy.eachDependency {
if (requested.group == "androidx.compose.ui") useVersion(version)
Expand All @@ -135,3 +158,74 @@ tasks.withType<Detekt>().configureEach {
tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions.freeCompilerArgs.add("-opt-in=androidx.compose.ui.ExperimentalComposeUiApi")
}

// SPIKE: suites don't get the mockable android.jar that AGP puts on unit test classpaths.
afterEvaluate {
tasks
.withType<Test>()
.matching { it.name.endsWith("JvmTestSuite") }
.configureEach {
classpath +=
tasks.named<Test>("testReleaseUnitTest").get().classpath.filter { it.name == "android.jar" }
// SPIKE: nor the suite's own processed Java resources.
classpath +=
files(tasks.named(name.replace("test", "process").replace("JvmTestSuite", "JavaRes")))
}
}

// SPIKE: AGP resolves suite runtime classpaths for the standard JVM, which picks Compose's desktop
// artifacts instead of the Android ones.
afterEvaluate {
configurations
.matching { it.name.endsWith("HostRuntimeClasspath") }
.configureEach {
attributes {
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment.ANDROID),
)
attribute(
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.attribute,
org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.androidJvm,
)
}
}
}

// SPIKE: suites don't get the test_config.properties Robolectric reads its resources from.
composeUiTestVersions.keys.forEach { suite ->
val v = "release${suite.replaceFirstChar { it.uppercase() }}"
val writeConfig =
tasks.register("write${v}TestConfig") {
val out = layout.buildDirectory.dir("spike/$v")
outputs.dir(out)
doLast {
val f = out.get().file("com/android/tools/test_config.properties").asFile
f.parentFile.mkdirs()
f.writeText(
"""
android_custom_package=io.sentry.android.replay
android_merged_assets=build/intermediates/assets/$v/merge${v.replaceFirstChar { it.uppercase() }}Assets
android_merged_manifest=build/intermediates/packaged_manifests/$v/process${v.replaceFirstChar { it.uppercase() }}Manifest/AndroidManifest.xml
android_resource_apk=build/intermediates/apk_for_local_test/$v/package${v.replaceFirstChar { it.uppercase() }}ForUnitTest/apk-for-local-test.ap_
"""
.trimIndent(),
)
}
}
afterEvaluate {
tasks.named<Test>("test${v.replaceFirstChar { it.uppercase() }}JvmTestSuite") {
classpath += files(writeConfig)
dependsOn(
"package${v.replaceFirstChar { it.uppercase() }}ForUnitTest",
"merge${v.replaceFirstChar { it.uppercase() }}Assets",
"process${v.replaceFirstChar { it.uppercase() }}Manifest",
)
}
}
}

// SPIKE: AGP doesn't hook test suites into check.
afterEvaluate {
tasks.named("check") { dependsOn(tasks.matching { it.name.endsWith("JvmTestSuite") }) }
}
1 change: 0 additions & 1 deletion sentry-android-sqlite/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.detekt")
id("io.sentry.spotless")
Expand Down
1 change: 0 additions & 1 deletion sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.detekt")
id("io.sentry.spotless")
Expand Down
1 change: 0 additions & 1 deletion sentry-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.spotless")
id("io.sentry.jdk-target")
Expand Down
2 changes: 1 addition & 1 deletion sentry-bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
project.rootProject.subprojects
.filter {
!it.name.startsWith("sentry-samples") &&
it.name != project.name &&
it.name != project.name && it.name != "sentry-compose" /* SPIKE */ &&
!it.name.endsWith("-bom") &&
!it.name.contains("test", ignoreCase = true)
}
Expand Down
1 change: 0 additions & 1 deletion sentry-launchdarkly-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("com.android.library")
alias(libs.plugins.kotlin.android)
alias(libs.plugins.gradle.versions)
id("io.sentry.spotless")
id("io.sentry.jdk-target")
Expand Down
Loading