Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9d3072e
fix(android): Generate sentry.options.json into build folder instead …
antonis Sep 18, 2026
4d7e879
docs(changelog): Reference PR #6751
antonis Sep 18, 2026
e855733
fix(android): Wire lint tasks to generateSentryOptions and clear opt-…
antonis Sep 18, 2026
1746faa
fix(android): Warn on stale sentry.options.json left in src/main/assets
antonis Sep 18, 2026
dd7a0bb
fix(android): Generate modules.json into build folder instead of sour…
antonis Sep 18, 2026
6abb40c
docs(changelog): Reference PR #6753
antonis Sep 18, 2026
8208e15
fix(android): Scope modules.json fallback to variant source set and w…
antonis Sep 18, 2026
45a7bba
Merge branch 'main' into al/fix-gradle-sentry-options-generated-assets
antonis Sep 21, 2026
26b65e8
Merge branch 'al/fix-gradle-sentry-options-generated-assets' into al/…
antonis Sep 21, 2026
b9eb181
fix(android): Scope modules lint dependency to the exact variant and …
antonis Sep 21, 2026
a2fcc04
refactor(android): Make the modules lint-dependency matcher verb-agno…
antonis Sep 21, 2026
f6b5d2d
fix(android): Order and re-key modules collection to avoid source-map…
antonis Sep 21, 2026
6b561ff
perf(android): Resolve collect-modules script path lazily
antonis Sep 22, 2026
c2007f8
test(android): Add GradleTestKit tests for sentry.gradle.kts asset tasks
antonis Sep 18, 2026
22fba77
test(android): Add regression test for variant-scoped modules lint de…
antonis Sep 21, 2026
8af1547
test(android): Scrub host SENTRY_* env and tighten lint-scope regression
antonis Sep 21, 2026
8f80327
test(android): Assert ktlint tasks are not wired to the modules task
antonis Sep 21, 2026
5217d5e
test(android): Cover modules.json survival across source-map cleanup
antonis Sep 21, 2026
d8e4648
test(android): Cover invalid-JSON fallback in generateSentryOptions
antonis Sep 22, 2026
9a2fcea
test(android): Track host AGP/compileSdk and share fixture scaffolding
antonis Sep 22, 2026
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

- Declare optional peer dependencies so imports resolve under strict and Plug'n'Play package managers ([#6729](https://github.com/getsentry/sentry-react-native/pull/6729))
- Honor `shutdownTimeout` on iOS ([#6749](https://github.com/getsentry/sentry-react-native/pull/6749))
- Android Gradle plugin no longer writes generated `sentry.options.json` into your source tree during builds ([#6751](https://github.com/getsentry/sentry-react-native/pull/6751))
- Android Gradle plugin no longer writes generated `modules.json` into your source tree during release builds ([#6753](https://github.com/getsentry/sentry-react-native/pull/6753))
- Fix Mac Catalyst linking the wrong `Sentry.xcframework` slice ([#6758](https://github.com/getsentry/sentry-react-native/pull/6758))

### Internal
Expand Down
9 changes: 9 additions & 0 deletions packages/core/RNSentryAndroidTester/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ android {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
// Absolute path to the script plugin under test and the Android SDK, so the GradleTestKit
// functional tests can apply the real sentry.gradle.kts and point a fixture build at the SDK.
systemProperty 'sentry.gradle.script', new File(rootDir, '../sentry.gradle.kts').absolutePath
systemProperty 'sentry.android.sdkDir', android.sdkDirectory.absolutePath
// AGP version and compileSdk the fixtures should use, taken from THIS host build so they track
// it instead of pinning a stale AGP/SDK that silently diverges when the host is bumped.
systemProperty 'sentry.android.agpVersion', com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
systemProperty 'sentry.android.compileSdk', android.compileSdk.toString()
}
}

Expand All @@ -48,6 +56,7 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.test:core-ktx:1.6.1'
testImplementation 'junit:junit:4.13.2'
testImplementation gradleTestKit()
testImplementation 'org.mockito:mockito-core:5.10.0'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.2.1'
testImplementation 'org.robolectric:robolectric:4.14.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package io.sentry.react.gradle

import org.gradle.testkit.runner.GradleRunner
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import java.io.File

/**
* Shared GradleTestKit scaffolding for the `sentry.gradle.kts` script-plugin functional tests.
*
* Both concrete tests stand up a minimal `com.android.application` fixture in a temp dir, apply the
* real script, and drive tasks through GradleTestKit. The parts that don't vary between them live
* here: the system properties injected by the host build (`app/build.gradle`), the invariant fixture
* files (settings, local.properties, stub manifest), path escaping, and a runner with the host
* `SENTRY_*` environment scrubbed for determinism.
*
* The AGP version and `compileSdk` come from the host build too (not hardcoded), so the fixtures track
* whatever the host is on instead of pinning a stale toolchain that silently diverges on a bump.
*/
abstract class BaseSentryGradleTest {
@get:Rule
val tempFolder = TemporaryFolder()

protected val scriptPath: String =
System.getProperty("sentry.gradle.script") ?: error("sentry.gradle.script system property not set")
protected val sdkDir: String =
System.getProperty("sentry.android.sdkDir") ?: error("sentry.android.sdkDir system property not set")
protected val agpVersion: String =
System.getProperty("sentry.android.agpVersion") ?: error("sentry.android.agpVersion system property not set")
protected val compileSdk: String =
System.getProperty("sentry.android.compileSdk") ?: error("sentry.android.compileSdk system property not set")

protected lateinit var projectDir: File

/** Escape Windows path separators so an absolute path is safe inside a Groovy string literal. */
protected fun String.esc(): String = replace("\\", "\\\\")

/** Write the fixture files that are identical across every test: settings, local.properties, manifest. */
protected fun writeCommonFixture() {
File(projectDir, "settings.gradle").writeText(
"""
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
}
}
rootProject.name = "fixture"
""".trimIndent(),
)

File(projectDir, "local.properties").writeText("sdk.dir=${sdkDir.esc()}")

val manifestDir = File(projectDir, "src/main")
manifestDir.mkdirs()
File(manifestDir, "AndroidManifest.xml").writeText("<manifest />")
}

/**
* A [GradleRunner] for [projectDir] with the host `SENTRY_*` variables scrubbed (the script reads
* several at configuration time), plus any [extraEnv] a specific test needs.
*/
protected fun baseRunner(
vararg args: String,
extraEnv: Map<String, String> = emptyMap(),
): GradleRunner =
GradleRunner
.create()
.withProjectDir(projectDir)
.withArguments(*args, "--stacktrace")
.withEnvironment(System.getenv().filterKeys { !it.startsWith("SENTRY_") } + extraEnv)
.forwardOutput()
}
Loading
Loading