<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".">

    <macrodef name="gitversion">
        <attribute name="target"/>
        <attribute name="outputproperty"/>
        <attribute name="gitdir" default=".git"/>

        <sequential>
            <local name="lastcommit"/>

            <exec executable="git" outputproperty="lastcommit">
                <arg value="--git-dir"/>
                <arg value="@{gitdir}"/>
                <arg value="rev-list"/>
                <arg value="--max-count=1"/>
                <arg value="HEAD"/>
                <arg value="--"/>
                <arg value="@{target}"/>
            </exec>

            <exec executable="git" outputproperty="@{outputproperty}">
                <arg value="--git-dir"/>
                <arg value="@{gitdir}"/>
                <arg value="describe"/>
                <arg value="--tags"/>
                <arg value="--always"/>
                <arg value="${lastcommit}"/>
            </exec>
        </sequential>
    </macrodef>

</project>
