Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
getBuildVersion() calls fixed; safeGetFile() fn introduced
  • Loading branch information
meeDamian committed Apr 3, 2015
1 parent c50aad0 commit f0c5ddf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions _posts/gradle-revisited.md
Expand Up @@ -23,9 +23,14 @@ Previously `gradle.properties` contained sensitive info (passwords, duh), so it
String safeGet(String name, String defaultValue = '') {
hasProperty(name) ? project[name] : defaultValue
}
// returns file from a path provided in properties file
File safeGetFile(String name) {
String fileName = safeGet(name, null)
fileName != null ? file(fileName) : null
}
```

And replacing all `project.VARIABLE` occurunces with `safeGet('VARIABLE')`.
And replacing all `project.VARIABLE` occurunces with `safeGet('VARIABLE')`. Use `safeGetFile('VARIABLE')` to get files.

**NOTE:** Variable name is **quoted** in a function call.

Expand Down Expand Up @@ -222,7 +227,7 @@ defaultConfig {
applicationId "com.yourPackage.someMore"
minSdkVersion 15 // because #minSDK15
targetSdkVersion 22
versionCode getBuildVersion(defaultValue: 1)
versionCode getBuildVersion(1)
versionName "0.0.1"
}
```
Expand All @@ -234,7 +239,7 @@ String fileName = [
defaultConfig.applicationId,
project.name,
defaultConfig.versionName,
getBuildVersion(increment: true)
getBuildVersion(android.defaultConfig.versionCode, true)
].join('-')
```

Expand Down

0 comments on commit f0c5ddf

Please sign in to comment.