android - Add build machine signature to gradle generated variable -
i'd stamp variable generated gradle (in case it's user agent used later http requests) later able distinguish developer build app (for example if developer made mistake , app ddosing server).
so can distinguish release
debug
with:
buildtypes { debug { buildconfigfield "string", "user_agent", "\"android-debug\"" } release { buildconfigfield "string", "user_agent", "\"android-release\"" } }
but debug
i'd add know built app instance, may git login, machine name, or else.
a gradle build file groovy code, , you're free put whatever want in it. have make sure code runs before used in dsl describes build. if want grab system, write groovy code that. groovy lot java, , have full jdk work @ runtime, should easy started.
if want access things build machine , environment, might have shell out different commands in order gather data. populate variables data. use buildconfigfield drop values buildconfig.java.
bear in mind might want provide some value in both debug , release both generate same buildconfig symbols. otherwise app might not compile in 1 config or other.
btw. can tell difference between debug , release properties added buildconfig, don't need add more tell difference. lines these appear (look in generated buildconfig.java see yourself):
public static final boolean debug = boolean.parseboolean("true"); public static final string build_type = "debug";
Comments
Post a Comment