Skip to content
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

Fix permission denied error when extracting sentry-cli concurrently #748

Merged
merged 16 commits into from
Aug 5, 2024
Merged
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
### Fixes

- Fix plugin for spring-dependency-management 1.1.6 ([#741](https://github.com/getsentry/sentry-android-gradle-plugin/pull/741))
- Make `SentryUploadNativeSymbolsTask` configuration-cache compatible ([#747](https://github.com/getsentry/sentry-android-gradle-plugin/pull/747))
- Fix `permission denied` error when extracting sentry-cli concurrently ([#748](https://github.com/getsentry/sentry-android-gradle-plugin/pull/748))

### Dependencies

Expand Down
2 changes: 1 addition & 1 deletion plugin-build/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ dependencies {
testImplementationAar(Libs.SQLITE)
testImplementationAar(Libs.SQLITE_FRAMEWORK)
testRuntimeOnly(files(androidSdkPath))
testImplementation(Libs.SENTRY_ANDROID)
testImplementationAar(Libs.SENTRY_ANDROID)
testImplementationAar(Libs.SENTRY_ANDROID_OKHTTP)
testImplementationAar(Libs.SENTRY_OKHTTP)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ internal object SentryCliProvider {
/**
* Tries to extract the sentry-cli from resources if the computedCliPath does not exist.
*/
@Synchronized
internal fun maybeExtractFromResources(buildDir: File, cliPath: String): String {
val cli = File(cliPath)
if (!cli.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ abstract class SentryUploadNativeSymbolsTask : SentryCliExecTask() {
@get:Internal
abstract val variantName: Property<String>

private val buildDir: Provider<File> = project.layout.buildDirectory.asFile

override fun getArguments(args: MutableList<String>) {
args.add("debug-files")
args.add("upload")
Expand All @@ -46,7 +48,7 @@ abstract class SentryUploadNativeSymbolsTask : SentryCliExecTask() {
// where {variantName} could be debug/release...
args.add(
File(
project.buildDir,
buildDir.get(),
"intermediates${sep}merged_native_libs${sep}${variantName.get()}"
).absolutePath
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,78 @@ class SentryPluginConfigurationCacheTest :
`is`(true)
)

appBuildFile.writeText(
// language=Groovy
"""
plugins {
id "com.android.application"
id "io.sentry.android.gradle"
}

android {
namespace 'com.example'
}

sentry {
includeNativeSources = true
uploadNativeSymbols = true
includeProguardMapping = true
autoUploadProguardMapping = true
autoInstallation.enabled = false
telemetry = false
}
""".trimIndent()
)

val runner = runner.withArguments(
"--configuration-cache",
"--build-cache",
":app:clean",
":app:assembleRelease"
":app:assembleRelease",
"--stacktrace"
)

val run = runner.build()
assertTrue(run.output) { "BUILD SUCCESSFUL" in run.output }
}

@Test
fun `native symbols upload task respects configuration cache`() {
assumeThat(
"SentryUploadNativeSymbolsTask only supports " +
"configuration cache from Gradle 7.5 onwards",
GradleVersions.CURRENT >= GradleVersions.VERSION_7_5,
`is`(true)
)
appBuildFile.writeText(
// language=Groovy
"""
plugins {
id "com.android.application"
id "io.sentry.android.gradle"
}

android {
namespace 'com.example'
}

sentry {
includeNativeSources = true
uploadNativeSymbols = true
includeProguardMapping = false
autoUploadProguardMapping = false
autoInstallation.enabled = false
telemetry = false
}
""".trimIndent()
)
runner.appendArguments(":app:assembleRelease")
.appendArguments("--configuration-cache")

val output = runner.build().output
assertTrue { "Configuration cache entry stored." in output }

val outputWithConfigCache = runner.build().output
assertTrue { "Configuration cache entry reused." in outputWithConfigCache }
}
}
Loading