|
1 | 1 | package io.sentry.kotlin.multiplatform.gradle
|
2 | 2 |
|
| 3 | +import io.sentry.kotlin.multiplatform.gradle.SentryPlugin.Companion.logger |
3 | 4 | import org.gradle.api.provider.Property
|
4 | 5 | import org.gradle.api.provider.ValueSource
|
5 | 6 | import org.gradle.api.provider.ValueSourceParameters
|
@@ -29,21 +30,36 @@ abstract class DerivedDataPathValueSource :
|
29 | 30 |
|
30 | 31 | override fun obtain(): String? {
|
31 | 32 | val buildDirOutput = ByteArrayOutputStream()
|
32 |
| - execOperations.exec { |
| 33 | + val errOutput = ByteArrayOutputStream() |
| 34 | + |
| 35 | + val execOperations = execOperations.exec { |
33 | 36 | it.commandLine = listOf(
|
34 | 37 | "xcodebuild",
|
35 | 38 | "-project",
|
36 | 39 | parameters.xcodeprojPath.get(),
|
37 | 40 | "-showBuildSettings"
|
38 | 41 | )
|
39 | 42 | it.standardOutput = buildDirOutput
|
| 43 | + it.errorOutput = errOutput |
40 | 44 | }
|
41 |
| - val buildSettings = buildDirOutput.toString("UTF-8") |
42 |
| - val buildDirMatch = buildDirRegex.find(buildSettings) |
43 |
| - val buildDir = buildDirMatch?.groupValues?.get(1) |
44 |
| - if (buildDir == null || buildDir.contains("DerivedData").not()) { |
| 45 | + |
| 46 | + if (execOperations.exitValue == 0) { |
| 47 | + val buildSettings = buildDirOutput.toString("UTF-8") |
| 48 | + val buildDirMatch = buildDirRegex.find(buildSettings) |
| 49 | + val buildDir = buildDirMatch?.groupValues?.get(1) |
| 50 | + if (buildDir == null || buildDir.contains("DerivedData").not()) { |
| 51 | + return null |
| 52 | + } |
| 53 | + return buildDir.replace("/Build/Products", "") |
| 54 | + } else { |
| 55 | + logger.warn( |
| 56 | + "Failed to retrieve derived data path. xcodebuild command failed. Error output: ${ |
| 57 | + errOutput.toString( |
| 58 | + Charsets.UTF_8 |
| 59 | + ) |
| 60 | + }" |
| 61 | + ) |
45 | 62 | return null
|
46 | 63 | }
|
47 |
| - return buildDir.replace("/Build/Products", "") |
48 | 64 | }
|
49 | 65 | }
|
0 commit comments