Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@breenie
Created April 8, 2014 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save breenie/10108443 to your computer and use it in GitHub Desktop.
Save breenie/10108443 to your computer and use it in GitHub Desktop.
git ant tasks
<?xml version="1.0" encoding="UTF-8"?>
<project>
<!-- Copied almost verbatim from: http://stackoverflow.com/questions/2974106/how-to-lookup-the-latest-git-commit-hash-from-an-ant-build-scripto-->
<available file=".git" type="dir" property="git.present"/>
<target name="git.revision" description="Store git revision in ${repository.version}" if="git.present">
<exec executable="git" outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg value="describe"/>
<arg value="--tags"/>
<arg value="--always"/>
<arg value="HEAD"/>
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
</target>
<target name="replace-tokens">
<copy file="index.html.template" tofile="index.html" overwrite="yes">
<filterchain>
<replacetokens>
<token key="repository.version" value="${repository.version}" />
</replacetokens>
</filterchain>
</copy>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment