Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. //You can specify JVM arguments to Gradle daemon by entering a line in ~/.gradle/gradle.properties as shown below.
  2. org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
  3. android.enableBuildCache=true
  4. android.builder.sdkDownload=true
  5.  
  6.  
  7.  
  8. ######################################################################3
  9. Use alfi to find the gradle dependency statement for a library
  10.  
  11. Its basically the command line version of Gradle, Please which is a web hosted.
  12. Run
  13.  
  14. alfi name_of_library
  15.  
  16.  
  17. ##################################
  18. Calculate the version code and version name in your build.gradle automatically, based on git information*
  19.  
  20. Note: These functions go specifically inside the app's build.gradle and cannot be used with ext.
  21. In your app's build.gradle
  22.  
  23. // Version code is calculated as the number of commits from last commit on master
  24. def getVersionCode = { ->
  25. try {
  26. def code = new ByteArrayOutputStream()
  27. exec {
  28. commandLine 'git', 'rev-list', 'HEAD', '--count'
  29. standardOutput = code
  30. }
  31. return Integer.parseInt(code.toString().trim())
  32. } catch (exception) {
  33. return "1";
  34. }
  35. }
  36.  
  37. // Version name is Last Tag Name + No. of commits form last Tag + short git sha
  38. def getVersionName = { ->
  39. try {
  40. def stdout = new ByteArrayOutputStream()
  41. exec {
  42. commandLine 'git', 'describe', '--tags', '--dirty'
  43. standardOutput = stdout
  44. }
  45. return stdout.toString().trim()
  46. } catch (exception) {
  47. return "0.0.0.1";
  48. }
  49. }
  50.  
  51. // Use
  52. android{
  53. defaultConfig {
  54. ...
  55. versionCode getVersionCode()
  56. versionName getVersionName()
  57. ...
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement