Permalink
Browse files

getBuildVersion() calls fixed; safeGetFile() fn introduced

  • Loading branch information...
meeDamian committed Apr 3, 2015
1 parent c50aad0 commit f0c5ddf2efa7e4c6b5c16aa7d5ae91feed3e03d2
Showing with 8 additions and 3 deletions.
  1. +8 −3 _posts/gradle-revisited.md
@@ -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.
@@ -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"
}
```
@@ -234,7 +239,7 @@ String fileName = [
defaultConfig.applicationId,
project.name,
defaultConfig.versionName,
getBuildVersion(increment: true)
getBuildVersion(android.defaultConfig.versionCode, true)
].join('-')
```

0 comments on commit f0c5ddf

Please sign in to comment.