I am trying to run git clone from ANT. But seems like ANT is not able to find git executable. I have tried following options.
<exec executable="/opt/freeware/bin/git">
<exec executable="/usr/bin/git">
<exec executable="git">
I am trying to run git clone from ANT. But seems like ANT is not able to find git executable. I have tried following options.
<exec executable="/opt/freeware/bin/git">
<exec executable="/usr/bin/git">
<exec executable="git">
A more robust option is to use the jgit ANT task:
<project name="demo" default="clone">
<target name="bootstrap">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/jgit.jar" src="http://search.maven.org/remotecontent?filepath=org/eclipse/jgit/org.eclipse.jgit/3.1.0.201310021548-r/org.eclipse.jgit-3.1.0.201310021548-r.jar"/>
<get dest="${user.home}/.ant/lib/jgit.ant.jar" src="http://search.maven.org/remotecontent?filepath=org/eclipse/jgit/org.eclipse.jgit.ant/3.1.0.201310021548-r/org.eclipse.jgit.ant-3.1.0.201310021548-r.jar"/>
<get dest="${user.home}/.ant/lib/jsch.jar" src="http://search.maven.org/remotecontent?filepath=com/jcraft/jsch/0.1.50/jsch-0.1.50.jar"/>
</target>
<target name="clone">
<taskdef resource="org/eclipse/jgit/ant/ant-tasks.properties"/>
<git-clone uri="https://github.com/myproject/myrepo.git" dest="build/myrepo" branch="master"/>
</target>
<target name="clean">
<delete dir="build"/>
</target>
</project>
Notes:
you want to abstract the location into a property.
<property name="git.executable" value="/usr/bin/git" />
and then in your exec
you specify that property
<exec executable="${git.executable}">
This will allow others to specify a different location from the commandline:
ant -Dgit.executable=/usr/local/bin/git
Or better yet in a user.properties
file that is ignored by source control but imported into your build.xml
That answers your question, but I want to mention that it's like crossing the streams to put references to your source control system in your build. You want those concerns to be separate. The build should be source control agnostic.