Skip to content

Commit 269866a

Browse files
authored
Merge pull request #450 from Iterable/evan/MOB-5316-fix-gradle-config-to-inherit-values-from-parent
[MOB-5316] adds safeExtGet method to build.gradle
2 parents 982bce5 + 678402f commit 269866a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

android/build.gradle

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ apply plugin: 'com.android.library'
33
import groovy.json.JsonSlurper
44

55
android {
6-
compileSdkVersion 28
6+
compileSdkVersion safeExtGet('compileSdkVersion', 28)
77

88
defaultConfig {
9-
minSdkVersion 16
10-
targetSdkVersion 28
9+
minSdkVersion safeExtGet('minSdkVersion', 16)
10+
targetSdkVersion safeExtGet('compileSdkVersion', 28)
1111

1212
buildConfigField("String", "MODULE_VERSION", "\"${getModuleVersion()}\"")
1313
}
1414
}
1515

16+
def safeExtGet(prop, fallback) {
17+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
18+
}
19+
1620
def getModuleVersion() {
1721
def jsonFile = file('../package.json')
1822
def parsedJson = new JsonSlurper().parseText(jsonFile.text)

0 commit comments

Comments
 (0)