Skip to content

Commit a07b90a

Browse files
authored
fix: Look for sentry.properties on flavor folder (#737)
* fix: Look for sentry.properties on flavor folder * ref: Check build types before flavor name
1 parent 5ffab36 commit a07b90a

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

sentry-android-gradle-plugin/src/main/groovy/io/sentry/android/gradle/SentryPlugin.groovy

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,38 @@ class SentryPlugin implements Plugin<Project> {
202202
description "Write references to proguard UUIDs to the android assets."
203203
workingDir project.rootDir
204204

205-
def variantName = variant.buildType.name
205+
def buildTypeName = variant.buildType.name
206206
def flavorName = variant.flavorName
207+
// When flavor is used in combination with dimensions, variant.flavorName will be a concatenation
208+
// of flavors of different dimensions
207209
def propName = "sentry.properties"
208-
def possibleProps = [
209-
"${project.projectDir}/src/${variantName}/${propName}",
210+
// current flavor name takes priority
211+
def possibleProps = []
212+
variant.productFlavors.each {
213+
// flavors used with dimension come in second
214+
possibleProps.push("${project.projectDir}/src/${it.name}/${propName}")
215+
}
216+
217+
possibleProps = [
218+
"${project.projectDir}/src/${buildTypeName}/${propName}",
219+
"${project.projectDir}/src/${buildTypeName}/${flavorName}/${propName}",
220+
"${project.projectDir}/src/${flavorName}/${buildTypeName}/${propName}",
210221
"${project.projectDir}/src/${flavorName}/${propName}",
211-
"${project.projectDir}/src/${variantName}/${flavorName}/${propName}",
212-
"${project.projectDir}/src/${flavorName}/${variantName}/${propName}",
213-
"${project.rootDir.toPath()}/src/${variantName}/${propName}",
214222
"${project.rootDir.toPath()}/src/${flavorName}/${propName}",
215-
"${project.rootDir.toPath()}/src/${variantName}/${flavorName}/${propName}",
216-
"${project.rootDir.toPath()}/src/${flavorName}/${variantName}/${propName}",
223+
] + possibleProps + [
224+
"${project.rootDir.toPath()}/src/${buildTypeName}/${propName}",
225+
"${project.rootDir.toPath()}/src/${buildTypeName}/${flavorName}/${propName}",
226+
"${project.rootDir.toPath()}/src/${flavorName}/${buildTypeName}/${propName}",
227+
// Root sentry.properties is the last to be looked up
217228
"${project.rootDir.toPath()}/${propName}"
218229
]
219230

220231
def propsFile = null
221232
possibleProps.each {
233+
project.logger.info("Looking for Sentry properties at: $it")
222234
if (propsFile == null && new File(it).isFile()) {
223235
propsFile = it
236+
project.logger.info("Found Sentry properties in: $it")
224237
}
225238
}
226239

0 commit comments

Comments
 (0)