[Android] Process output filename at build time

Geoffrey Métais git at videolan.org
Tue Mar 21 14:11:44 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 21 14:10:42 2017 +0100| [f0c05a2830c85287f2102840750218aae5c71de0] | committer: Geoffrey Métais

Process output filename at build time

It was executed at configuration time

> https://code.videolan.org/videolan/vlc-android/commit/f0c05a2830c85287f2102840750218aae5c71de0
---

 vlc-android/build.gradle | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/vlc-android/build.gradle b/vlc-android/build.gradle
index 6edb789..f541311 100644
--- a/vlc-android/build.gradle
+++ b/vlc-android/build.gradle
@@ -138,19 +138,21 @@ android {
 
     // make per-variant version code
     applicationVariants.all { variant ->
-        def manifestParser = new DefaultManifestParser(android.sourceSets.main.manifest.srcFile)
-        // get the version code of each flavor
-        def vlcVersion = manifestParser.getVersionName()
-        def abiVersion = variant.productFlavors.get(0).versionCode
-
-        // set the composite code
-        variant.mergedFlavor.versionCode = 10000000 + manifestParser.versionCode + abiVersion
-        variant.mergedFlavor.versionName = vlcVersion
-
-        //Custom APK name
-        variant.outputs.each { output ->
-            def outputName = "VLC-Android-" + vlcVersion + "-" + variant.productFlavors.get(0).name + ".apk"
-            output.outputFile = new File(output.outputFile.parentFile, outputName);
+        variant.getGenerateBuildConfig().doLast {
+            def manifestParser = new DefaultManifestParser(android.sourceSets.main.manifest.srcFile)
+            // get the version code of each flavor
+            def vlcVersion = manifestParser.getVersionName()
+            def abiVersion = variant.productFlavors.get(0).versionCode
+
+            // set the composite code
+            variant.mergedFlavor.versionCode = 10000000 + manifestParser.versionCode + abiVersion
+            variant.mergedFlavor.versionName = vlcVersion
+
+            //Custom APK name
+            variant.outputs.each { output ->
+                def outputName = "VLC-Android-" + vlcVersion + "-" + variant.productFlavors.get(0).name + ".apk"
+                output.outputFile = new File(output.outputFile.parentFile, outputName);
+            }
         }
     }
 



More information about the Android mailing list