在project的build.gradle加上:
dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath group: 'org.tmatesoft.svnkit', name: 'svnkit', version: '1.8.11' }
module的build.gradle加上:
def getSvnRevision() {
ISVNOptions options = SVNWCUtil.createDefaultOptions(true);
SVNClientManager clientManager = SVNClientManager.newInstance(options);
SVNStatusClient statusClient = clientManager.getStatusClient();
SVNStatus status = statusClient.doStatus(projectDir, false);
SVNRevision revision = status.getCommittedRevision();
return revision.getNumber();
buildTypes { release { minifyEnabled true zipAlignEnabled true // 移除无用的resource文件 shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' applicationVariants.all { variant -> variant.outputs.each { output -> def outputFile = output.outputFile //这里修改文件名 def fileName = ${getSvnRevision()}+outputFile.name output.outputFile = new File(outputFile.parent, fileName) } } }
csonezp@gmail.com