我正在开发一个涉及将git存储库克隆到本地目录的项目。
我通读the tutorial,我的代码如下:
/*
* Clones a github project to the designated directory and checks it out. (Both prefix and postfix)
* <p>
* @param buildPath - String, the path where the directories will be created and the projects built.
* @param bugID - String, the bug's id.
* @param projectURL - String, the github URL used to clone the project.
*/
public void DownloadAndSetup(String buildPath, String bugID, String projectURL, String prefixHash, String postfixHash) throws InvalidRemoteException, TransportException, GitAPIException {
String generalPath = buildPath+File.separator+bugID;
String prefixPath = generalPath+File.separator+"prefix";
String postfixPath = generalPath+File.separator+"postfix";
// Cloning & checking out to prefix
Git gitPrefix = Git.cloneRepository().setURI(projectURL).setDirectory(new File(prefixPath)).call();
gitPrefix.checkout().setCreateBranch(true).setName("new-branch").setStartPoint(prefixHash).call();
// Cloning & checking out to postfix
Git gitPostfix = Git.cloneRepository().setURI(projectURL).setDirectory(new File(postfixPath)).call();
gitPostfix.checkout().setCreateBranch(true).setName("new-branch").setStartPoint(postfixHash).call();
}
但是当我跑步时:
public static void main(String[] args) throws InvalidRemoteException, TransportException, GitAPIException {
GitDownloader gd = new GitDownloader();
String buildPath = "C:\\Users\\dario_000\\Dropbox\\SheffInternship\\wsp\\AutoEv\\src\\tests";
gd.DownloadAndSetup(buildPath, "download", "https://github.com/jhy/jsoup.git", "1e9ae842ca94f326215358917c620ac407323c81", "04e256ce9571e4239403b657126ce8eb30ad6776");
}
我收到以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jsch/JSchException
at org.eclipse.jgit.transport.Transport.<clinit>(Transport.java:114)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:120)
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:178)
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:125)
at autoEvoSuite.GitDownloader.DownloadAndSetup(GitDownloader.java:26)
at tests.GITProjectDownloader.main(GITProjectDownloader.java:19)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jsch.JSchException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
有人有任何建议吗?