-
-
Notifications
You must be signed in to change notification settings - Fork 37
feat(snapshot): Merge snapshot extension into main sentry DSL #1136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
740f5f4
205521b
540e044
953aa3b
efb2185
1b238cf
954e694
9b46899
156a70c
191da17
3584c01
d8e6b5a
eea14a7
d6133d1
f77e724
cf3b2bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,9 @@ import com.android.build.api.instrumentation.InstrumentationParameters | |
| import com.android.build.api.instrumentation.InstrumentationScope | ||
| import com.android.build.api.variant.ApplicationAndroidComponentsExtension | ||
| import com.android.build.api.variant.ApplicationVariant | ||
| import com.android.build.api.variant.HostTestBuilder.Companion.UNIT_TEST_TYPE | ||
| import com.android.build.api.variant.Variant | ||
| import com.android.build.gradle.BaseExtension | ||
| import com.android.build.gradle.internal.utils.setDisallowChanges | ||
| import io.sentry.android.gradle.SentryPlugin.Companion.sep | ||
| import io.sentry.android.gradle.SentryPropertiesFileProvider.getPropertiesFilePath | ||
|
|
@@ -20,6 +22,7 @@ import io.sentry.android.gradle.SentryTasksProvider.getMappingFileProvider | |
| import io.sentry.android.gradle.extensions.SentryPluginExtension | ||
| import io.sentry.android.gradle.instrumentation.SpanAddingClassVisitorFactory | ||
| import io.sentry.android.gradle.services.SentryModulesService | ||
| import io.sentry.android.gradle.snapshot.GenerateSnapshotTestsTask | ||
| import io.sentry.android.gradle.sourcecontext.OutputPaths | ||
| import io.sentry.android.gradle.sourcecontext.SourceContext | ||
| import io.sentry.android.gradle.tasks.GenerateDistributionPropertiesTask | ||
|
|
@@ -46,6 +49,7 @@ import org.gradle.api.file.Directory | |
| import org.gradle.api.provider.Provider | ||
| import org.gradle.api.provider.SetProperty | ||
| import org.gradle.api.tasks.TaskProvider | ||
| import org.gradle.api.tasks.testing.Test | ||
| import org.gradle.internal.build.event.BuildEventListenerRegistryInternal | ||
|
|
||
| fun ApplicationAndroidComponentsExtension.configure( | ||
|
|
@@ -78,7 +82,9 @@ fun ApplicationAndroidComponentsExtension.configure( | |
| } | ||
| } | ||
|
|
||
| variant.configureSnapshotsTasks(project, extension, cliExecutable, sentryOrg, sentryProject) | ||
| if (extension.snapshots.enabled.get()) { | ||
| variant.configureSnapshotsTasks(project, extension, cliExecutable, sentryOrg, sentryProject) | ||
| } | ||
|
runningcode marked this conversation as resolved.
|
||
|
|
||
| if (isVariantAllowed(extension, variant.name, variant.flavorName, variant.buildType)) { | ||
| val paths = OutputPaths(project, variant.name) | ||
|
|
@@ -461,21 +467,74 @@ private fun ApplicationVariant.configureSnapshotsTasks( | |
| cliExecutable: Provider<String>, | ||
| sentryOrg: String?, | ||
| sentryProject: String?, | ||
| ): TaskProvider<SentryUploadSnapshotsTask> { | ||
| ) { | ||
| val variant = AndroidVariant74(this) | ||
| val sentryProps = getPropertiesFilePath(project, variant) | ||
| val taskSuffix = name.capitalized | ||
|
|
||
| return SentryUploadSnapshotsTask.register( | ||
| project = project, | ||
| extension = extension, | ||
| sentryTelemetryProvider = null, | ||
| cliExecutable = cliExecutable, | ||
| sentryOrgOverride = sentryOrg, | ||
| sentryProjectOverride = sentryProject, | ||
| applicationId = applicationId, | ||
| sentryProperties = sentryProps, | ||
| taskSuffix = name.capitalized, | ||
| ) | ||
| // Register the upload task | ||
| val uploadTask = | ||
| SentryUploadSnapshotsTask.register( | ||
| project = project, | ||
| extension = extension, | ||
| sentryTelemetryProvider = null, | ||
| cliExecutable = cliExecutable, | ||
| sentryOrgOverride = sentryOrg, | ||
| sentryProjectOverride = sentryProject, | ||
| applicationId = applicationId, | ||
| sentryProperties = sentryProps, | ||
| taskSuffix = taskSuffix, | ||
| ) | ||
|
sentry[bot] marked this conversation as resolved.
|
||
|
|
||
| // Wire Paparazzi test generation and upload task when the Paparazzi plugin is applied | ||
| project.pluginManager.withPlugin("app.cash.paparazzi") { | ||
| val android = project.extensions.getByType(BaseExtension::class.java) | ||
|
|
||
| project.dependencies.add( | ||
| "testImplementation", | ||
| "io.github.sergio-sastre.ComposablePreviewScanner:android:0.8.1", | ||
| ) | ||
|
|
||
| val generateTask = | ||
| GenerateSnapshotTestsTask.register( | ||
| project, | ||
| extension.snapshots, | ||
| android, | ||
| this@configureSnapshotsTasks, | ||
| ) | ||
|
|
||
| if (AgpVersions.isAGP90(AgpVersions.CURRENT)) { | ||
| hostTests[UNIT_TEST_TYPE]?.apply { | ||
| sources.java?.addGeneratedSourceDirectory( | ||
| generateTask, | ||
| GenerateSnapshotTestsTask::outputDir, | ||
| ) | ||
| } | ||
| } else { | ||
| @Suppress("DEPRECATION_ERROR") | ||
| unitTest?.apply { | ||
| sources.java?.addGeneratedSourceDirectory( | ||
| generateTask, | ||
| GenerateSnapshotTestsTask::outputDir, | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| project.afterEvaluate { | ||
| // Not all variants have unit test tasks (e.g. users can disable them), | ||
|
Comment on lines
+523
to
+524
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The Suggested FixMove the registration of Prompt for AI Agent |
||
| // so skip wiring if the task doesn't exist. | ||
| val testTaskName = "test${taskSuffix}UnitTest" | ||
| if (testTaskName !in project.tasks.names) return@afterEvaluate | ||
|
|
||
| val testTask = project.tasks.named(testTaskName, Test::class.java) | ||
| uploadTask.configure { task -> | ||
| task.dependsOn("recordPaparazzi$taskSuffix") | ||
|
sentry[bot] marked this conversation as resolved.
|
||
| task.snapshotsPath.fileProvider( | ||
| testTask.map { it.outputs.files.files.first { file -> file.name == "snapshots" } } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.