{"id":413,"date":"2016-08-18T09:05:28","date_gmt":"2016-08-18T08:05:28","guid":{"rendered":"https:\/\/mokrzycki.eu\/blog\/?p=413"},"modified":"2018-12-04T10:21:12","modified_gmt":"2018-12-04T09:21:12","slug":"example-gradle-with-incrementing-version-based-on-commits-count","status":"publish","type":"post","link":"https:\/\/mokrzycki.eu\/blog\/2016\/08\/18\/example-gradle-with-incrementing-version-based-on-commits-count\/","title":{"rendered":"Example gradle with incrementing version (based on commits count)"},"content":{"rendered":"<p>Just an example how use commits count value as a build number of app.<\/p>\n<pre>buildscript {\r\n    \/\/...\r\n}\r\n\r\nrepositories {\r\n    \/\/...\r\n}\r\n\r\n<\/pre>\n<p><strong>def cmd = &#8216;git rev-list &#8211;all &#8211;count&#8217; def gitVersion = cmd.execute().text.trim().toInteger() println &#8220;=== Building version &#8221; + gitVersion.toString()<\/strong><\/p>\n<pre>\r\nandroid {\r\n    compileSdkVersion 23\r\n    buildToolsVersion '23.0.3'\r\n\r\n    defaultConfig {\r\n        \/\/...\r\n<\/pre>\n<p><strong>versionCode gitVersion versionName &#8220;1.0.&#8221; + gitVersion<\/strong><\/p>\n<pre>    }\r\n\r\n    lintOptions {\r\n        abortOnError false\r\n    }\r\n\r\n    buildTypes {\r\n        release {\r\n            minifyEnabled false\r\n        }\r\n    }\r\n\r\n    signingConfigs {\r\n        release {\r\n            \/\/...\r\n        }\r\n    }\r\n\r\n    productFlavors {\r\n        play {\r\n            \/\/...\r\n        }\r\n    }\r\n}\r\n\r\ndependencies {\r\n    \/\/...\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Just an example how use commits count value as a build number of app. buildscript&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[500],"tags":[225,296,298,297],"_links":{"self":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/413"}],"collection":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/comments?post=413"}],"version-history":[{"count":5,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/413\/revisions"}],"predecessor-version":[{"id":710,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/posts\/413\/revisions\/710"}],"wp:attachment":[{"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/media?parent=413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/categories?post=413"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mokrzycki.eu\/blog\/wp-json\/wp\/v2\/tags?post=413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}