Skip to content

Commit b526cfd

Browse files
runningcodeclaude
andcommitted
fix(config-cache): Restore getIsolatedRootProjectDir for Gradle 8.8+
Use isolated.rootProject.projectDirectory on Gradle 8.8+ to avoid deprecated project.rootProject access that will break when project isolation is enforced. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6ab09c5 commit b526cfd

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

plugin-build/src/main/kotlin/io/sentry/android/gradle/util/SentryCliExec.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,29 @@ import io.sentry.android.gradle.tasks.SentryCliExecTask
55
import io.sentry.android.gradle.util.CliFailureReason.OUTDATED
66
import java.io.ByteArrayOutputStream
77
import org.gradle.api.GradleException
8+
import org.gradle.api.Project
9+
import org.gradle.api.file.Directory
810
import org.gradle.process.ExecSpec
911

1012
fun ExecSpec.setSentryPipelineEnv() {
1113
environment("SENTRY_PIPELINE", "sentry-gradle-plugin/${BuildConfig.Version}")
1214
}
1315

16+
private fun Project.getIsolatedRootProjectDir(): Directory {
17+
return if (GradleVersions.CURRENT >= GradleVersions.VERSION_8_8) {
18+
isolated.rootProject.projectDirectory
19+
} else {
20+
rootProject.layout.projectDirectory
21+
}
22+
}
23+
1424
/**
1525
* An ext function for tasks that wrap sentry-cli, which provides common error handling. Must be
1626
* called at configuration phase (=when registering a task).
1727
*/
1828
fun SentryCliExecTask.asSentryCliExec() {
1929
sentryProjectDir.set(project.layout.projectDirectory)
20-
sentryRootDir.set(project.rootProject.layout.projectDirectory)
30+
sentryRootDir.set(project.getIsolatedRootProjectDir())
2131
buildDirectory.set(project.layout.buildDirectory)
2232

2333
isIgnoreExitValue = true

plugin-build/src/test/kotlin/io/sentry/android/gradle/tasks/SentryCliExecTaskTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class SentryCliExecTaskTest {
1919
@Test
2020
fun `cli path is resolved and extracted from resources`() {
2121
val project = createProject()
22-
val cliPath = SentryCliProvider.getCliResourcesExtractionPath(project.layout.buildDirectory).get().asFile
22+
val cliPath =
23+
SentryCliProvider.getCliResourcesExtractionPath(project.layout.buildDirectory).get().asFile
2324

2425
assertTrue(!cliPath.exists())
2526

0 commit comments

Comments
 (0)