jGit
用于在Java中从BitBucket检出代码的库。
添加了以下maven依赖项。
<dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>4.8.0.201706111038-r</version>
</dependency>
下面的代码行可以用来编码,可以用来创建克隆。
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.CloneCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
import java.io.File;
class Test {
public static void main(String[] args){
CloneCommand clone = Git.cloneRepository().setURI(uri).setDirectory(new File(checkoutDir));
try {
clone.call();
}
catch (GitAPIException e) {
System.err.println(e.getMessage());
e.printStackTrace(System.err);
}
}
}