Ant has tasks for CVS and Subversion, but none that I could find for Git. I threw together these simple Ant macros to get started:

name = "git" >
  name = "command" />
  name = "dir" default = "" />
  name = "args" optional = "true" />


 

      message = "git @{command}" />
      executable = "git" dir = "@{dir}" >
        value = "@{command}" />
       
     

 


name = "git-clone-pull">
  name = "repository" />
  name = "dest" />
 
     command = "clone">
       
           value = "@{repository}" />
           value = "@{dest}" />
       
     

     command = "pull"dir = "@{dest}" />
 

The first one, “git” just runs git with whatever command you provide to it (clone, pull, etc) along with any arguments you pass to it. Clone:

command = "clone" >
 
      value = "git://github.com/280north/ojunit.git" />
  value = "ojunit" />
 

And pull:

command = "pull" dir = "repository_path" />

(Other git command will likely work, these are just the ones I needed)

  The second one, “git-clone-pull” uses the first one to clone a repository then pull from it.This effectively clones the

repository if it hasn’t already been cloned,otherwise it pulls.

  However,since ant is fairly limited in what sorts of conditional execution you can perform, it just does both (clone will

fail if it’s already been cloned, and pull will always be executed, even immediately after a the initial clone).

Obviously not ideal, but it works, and I couldn’t figure out a better way without writing actual code.

repository = "git://github.com/280north/ojunit.git" dest = "ojunit" />

There is plenty of room for improvement, but I suspect a proper Ant task written in Java is the right way to go.