|
|
@ -49,12 +49,14 @@ import org.apache.tools.ant.Project; |
|
|
|
import org.apache.tools.ant.Task; |
|
|
|
import org.apache.tools.ant.Task; |
|
|
|
import org.eclipse.jgit.api.CloneCommand; |
|
|
|
import org.eclipse.jgit.api.CloneCommand; |
|
|
|
import org.eclipse.jgit.api.Git; |
|
|
|
import org.eclipse.jgit.api.Git; |
|
|
|
|
|
|
|
import org.eclipse.jgit.api.errors.GitAPIException; |
|
|
|
|
|
|
|
import org.eclipse.jgit.api.errors.JGitInternalException; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.lib.Constants; |
|
|
|
import org.eclipse.jgit.transport.URIish; |
|
|
|
import org.eclipse.jgit.transport.URIish; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Clone a repository into a new directory. |
|
|
|
* Clone a repository into a new directory. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html" |
|
|
|
* @see <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clone.html" |
|
|
|
* >git-clone(1)</a> |
|
|
|
* >git-clone(1)</a> |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -76,9 +78,9 @@ public class GitCloneTask extends Task { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* The optional directory associated with the clone operation. If the |
|
|
|
* The optional directory associated with the clone operation. If the |
|
|
|
* directory isn't set, a name associated with the source uri will be used. |
|
|
|
* directory isn't set, a name associated with the source uri will be used. |
|
|
|
* |
|
|
|
* |
|
|
|
* @see URIish#getHumanishName() |
|
|
|
* @see URIish#getHumanishName() |
|
|
|
* |
|
|
|
* |
|
|
|
* @param destination |
|
|
|
* @param destination |
|
|
|
* the directory to clone to |
|
|
|
* the directory to clone to |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -105,12 +107,12 @@ public class GitCloneTask extends Task { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void execute() throws BuildException { |
|
|
|
public void execute() throws BuildException { |
|
|
|
log("Cloning repository " + uri); |
|
|
|
log("Cloning repository " + uri); |
|
|
|
|
|
|
|
|
|
|
|
CloneCommand clone = Git.cloneRepository(); |
|
|
|
CloneCommand clone = Git.cloneRepository(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
clone.setURI(uri).setDirectory(destination).setBranch(branch).setBare(bare); |
|
|
|
clone.setURI(uri).setDirectory(destination).setBranch(branch).setBare(bare); |
|
|
|
clone.call().getRepository().close(); |
|
|
|
clone.call().getRepository().close(); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (GitAPIException | JGitInternalException e) { |
|
|
|
log("Could not clone repository: " + e, e, Project.MSG_ERR); |
|
|
|
log("Could not clone repository: " + e, e, Project.MSG_ERR); |
|
|
|
throw new BuildException("Could not clone repository: " + e.getMessage(), e); |
|
|
|
throw new BuildException("Could not clone repository: " + e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|