Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
ant wrapper to jgit
Java
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
src
.classpath
.gitignore
.project
CHANGELOG
README
build.sample.xml
build.xml

README

Minimalistic ant tasks wrapping jGit (http://www.eclipse.org/jgit/)

REASON

I am setting up a CI build for RestFixture. As I don't have access to the hosted CI server I am using and not being able to 
install git, i need a fully self contained java implementation of git for the sake of supporting my CI build.

CHANGELOG:

version 0.0.1
- first version
- support for cloning public remote repository

DOCUMENTATION

See build.sample.xml

<project name="sample.jgit-ant.project" default="update-remote">

    <path id="git.classpath">
        <pathelement location="build/jgit-ant.jar" />
        <pathelement location="lib/jsch-0.1.44.jar" />
        <pathelement location="lib/org.eclipse.jgit-0.12.1.jar" />
    </path>

    <taskdef resource="jgit-ant.properties" classpathref="git.classpath" />

    <!--
        the git task is useful to group git commands on a single local repository.
        
        note: localDirectory is mandatory and the directory must exist.
     -->

    <target name="ci">
        <delete dir="build/restfixture-git-ro" />
        <mkdir dir="build/restfixture-git-ro" />
        <git localDirectory="build/restfixture-git-ro" verbose="true">
            <!-- clones the repository specified in uri attribute to local directory specified in the git parent task -->
            <clone uri="git://github.com/smartrics/RestFixture.git" />
        </git>
    </target>

    <target name="update-remote">
        <git localDirectory="build/restfixture-git-ro" verbose="true">
            <!-- pulls from remote, the local repository in git parent task. 
                 The pullFailedProperty property indicates failure and its optional
                 in this case pull.failed is set if either merge fails 
                 modificationExistProperty is set if after pull modification exist.
                 -->
            <pull modificationExistProperty="is.not.uptodate" pullFailedProperty="pull.failed" />
        </git>

        <echo message="Repository is not uptodate: ${is.not.uptodate}" />
        <echo message="Pull failed: ${pull.failed}" />
        <fail if="pull.failed"
              message="Pull failed: ${pull.failed}. Details:\n  merge result: ${merge.failed}\n  rebase result: ${rebase.failed}" />
    </target>

    <!-- commands can also be written on their own (not as children of git task) -->

    <target name="simple-task-execution">
        <delete dir="build/restfixture-git-ro" />
        <mkdir dir="build/restfixture-git-ro" />
        <clone localDirectory="build/restfixture-git-ro" verbose="true" uri="git://github.com/smartrics/RestFixture.git" />
    </target>

</project>
Something went wrong with that request. Please try again.