create version.txt file in project dir via build.gradle task : <p>Apologies in advance for my ignorance. I'm very new to gradle.</p>

<p>My is goal is to have some task in my build.gradle file, wherein a file 'version.txt' is created in my project directory whenever I run the <code>gradle</code> terminal command in my project root. This 'version.txt' file needs to contain version metadata of the build, such as:</p>

<p><code>Version: 1.0
Revision: 1z7g30jFHYjl42L9fh0pqzmsQkF
Buildtime: 2016-06-14 07:16:37 EST
Application-name: foobarbaz app</code></p>

<p>(^Revision would be the git commit hash of the HEAD)</p>

<p>I've tried to reuse snippets from the following resources, but to no avail, possibly because these resources are out of date:
<a href="http://mrhaki.blogspot.com/2015/04/gradle-goodness-use-git-commit-id-in.html" rel="noreferrer">http://mrhaki.blogspot.com/2015/04/gradle-goodness-use-git-commit-id-in.html</a>
<a href="http://mrhaki.blogspot.com/2010/10/gradle-goodness-add-incremental-build.html" rel="noreferrer">http://mrhaki.blogspot.com/2010/10/gradle-goodness-add-incremental-build.html</a></p>

<p>I'm using gradle version 2.14 (which is the latest version).</p>

<p>Any help and/or insight would be very much appreciated. Thanks!</p>
