Hi,
I'm desperately trying to parse the svn revision number into the versionName/versionCode by using a mixture of gradle and ant build scripts (since there's no svn plugin for gradle yet). I'm a complete newbie to gradle and even groovy, but have managed to accomplish the desired functionality by overwriting the needed fields in the source AndroidManifest.xml file and just revert the fields back to their original content after build. This really is an overkill since we have the versionName/versionCode property in defaultConfig, which is supposed to override the values provided by the manifest file. However I cannot accomplish this by defining a function as mentioned in the user guide. Even a simple return value will not work:
classpath 'com.android.tools.build:gradle:0.5.+'
apply plugin: 'android'
ant.importBuild 'build.xml'
buildToolsVersion "18.0.1"
versionName getVersionName()
versionCode getVersionCode()
...
I really have no idea how to get this to work. Also, how to execute the ant task and have its property set as the versionCode? Would this work?
def getVersionCode() {
tasks.getSvnRev.execute() // run the ant task to get the local svn revision
return tasks.getSvnRev.revisionVersion // revisionVersion is the ant property containing the revision number
}
Thanks in advance,
Kloon