So, duplicate functionality is only way :-(
I wanted only to rename output APK name with gradle produce by default.
But keep all attributes like release/debug, flavour name, density/abi
split, etc.

Maybe best way how to do it is this:

android.applicationVariants.all { variant ->
   variant.outputs.each { output ->

    File file = output.outputFile
    String gitHash = getGitHash()

    *def *name =
output.outputFile.name.replace(*"-"*,*","*).replace(project.name+*","*,
           project.parent.name + *"-" *+ project.name + *"-" *+
    project.version + *"-" *+ variant.mergedFlavor.versionCode + *"-"
*+            gitHash + *"-"*)    output.outputFile = *new
*File(file.parent, name)  }}

It generate name like

scanner-app-1.0.0-29-eb2cf30-release.apk


All build type flags are at the end separated by ",", so it can be


scanner-app-1.0.0-29-eb2cf30-flavour1,xhdpi,release.apk



-- 
Ing. Tomáš Procházka

2014-10-02 20:09 GMT+02:00 Xavier Ducrohet <[email protected]>:

> Yes you can access the outputs from the script. Look at the densitySplit
> sample we upload. It has a section which does this:
>
> // map for the version code
> ext.versionCodes = [all:1, mdpi:2, hdpi:3, xhdpi:4, xxhdpi:5]
>
> android.applicationVariants.all { variant ->
>   // assign different version code for each output
>   variant.outputs.each { output ->
>     def key = output.densityFilter == null ? "all" : output.densityFilter
>     output.versionCodeOverride = project.ext.versionCodes.get(key) * 100 +
> android.defaultConfig.versionCode
>   }
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to