@@ -29,7 +29,7 @@ buildscript {
2929 }
3030
3131 dependencies {
32- classpath " com.android.tools.build:gradle:1.3.0 "
32+ classpath " com.android.tools.build:gradle:1.3.1 "
3333 }
3434}
3535
@@ -62,6 +62,23 @@ def computeBuildToolsVersion() {
6262 }
6363}
6464
65+ def renameResultApks (variant ) {
66+ def name
67+ variant. outputs. each { output ->
68+
69+ def apkDirectory = output. packageApplication. outputFile. parentFile
70+ def apkNamePrefix = rootProject. name + " -" + variant. buildType. name
71+
72+ if (output. zipAlign) {
73+ name = apkNamePrefix + " .apk"
74+ output. outputFile = new File (apkDirectory, name);
75+ }
76+
77+ name = apkNamePrefix + " -unaligned.apk"
78+ output. packageApplication. outputFile = new File (apkDirectory, name);
79+ }
80+ }
81+
6582android {
6683 compileSdkVersion compiteCompileSdkVersion()
6784 buildToolsVersion computeBuildToolsVersion()
@@ -98,6 +115,8 @@ android {
98115 }
99116
100117 applicationVariants. all { variant ->
118+ renameResultApks(variant)
119+
101120 def tsk = variant. mergeAssets
102121 if (project. hasProperty(" runSBGenerator" )) {
103122 runBindingGenerator. dependsOn(copyMetadata)
@@ -140,6 +159,39 @@ dependencies {
140159 // }
141160}
142161
162+
163+ def createIncludeFile (filePath , fileName ) {
164+ def defaultIncludeFile = new File (filePath, " include.gradle" )
165+ defaultIncludeFile. write " "
166+ defaultIncludeFile << " android { \n "
167+ defaultIncludeFile << " \t productFlavors {\n "
168+ defaultIncludeFile << ' \t\t "' + fileName + ' " {\n '
169+ defaultIncludeFile << ' \t\t\t dimension "' + fileName + ' "\n '
170+ defaultIncludeFile << " \t\t }\n "
171+ defaultIncludeFile << " \t }\n "
172+ defaultIncludeFile << " }"
173+ }
174+
175+ task createDefaultIncludeFiles {
176+ def ft = file(configurationsDir)
177+
178+ ft. listFiles(). each { fl ->
179+ if (fl. isDirectory()) {
180+ def foundIncludeFile = false
181+ fl. listFiles(). each { subFile ->
182+ if (subFile. name == " include.gradle" ) {
183+ foundIncludeFile = true
184+ }
185+ }
186+
187+ if (! foundIncludeFile) {
188+ println " +creating include.gradle file for: " + fl. getAbsolutePath()
189+ createIncludeFile(fl. getAbsolutePath() ,fl. name)
190+ }
191+ }
192+ }
193+ }
194+
143195task deletePrevConfig (type : Delete ) {
144196 delete " $configurationsDir /include.gradle"
145197}
@@ -152,7 +204,7 @@ task setFlavorsBeforePluginExtend {
152204 List<String > pluginNames = new ArrayList<String > ()
153205 dirTree. each { f ->
154206 if (f. isDirectory()) {
155- println " adding plugin: " + f. getName()
207+ println " + adding plugin: " + f. getName()
156208 pluginNames. add(' "' + f. getName() + ' "' )
157209 }
158210 }
@@ -205,7 +257,7 @@ task collectAllJars {
205257
206258 doFirst {
207259
208- configurations. compile. each { File dependencyFile ->
260+ configurations. compile. each { File dependencyFile ->
209261 allJarPaths. add(dependencyFile. getAbsolutePath())
210262 }
211263
0 commit comments