use of org.tmatesoft.svn.core.wc2.SvnExport in project scheduling by ow2-proactive.
the class PackageDownloader method downloadPackageFromGithub.
/**
* This method downloads an entire github repository or only a sub-directory within a repository.<br>
* It can also download and extract an archive version of a github repository.
* It relies on svn export command.<br>
*
* @param githubURL
* @return
*/
private String downloadPackageFromGithub(String githubURL) throws SVNException {
// Convert the githubRL to an svn format
String svnURL = transformGithubURLToSvnURL(githubURL);
// Save files in a system temporary directory
String tDir = System.getProperty("java.io.tmpdir");
String packagePath = tDir + "pkg_tmp" + System.nanoTime();
File outputDir = new File(packagePath);
// Perform an "svn export" command to download an entire repository or a subdirectory
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
try {
final SvnExport export = svnOperationFactory.createExport();
export.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(svnURL)));
export.setSingleTarget(SvnTarget.fromFile(outputDir));
// overwrite an existing file
export.setForce(true);
export.run();
} finally {
// close connection pool associted with this object
svnOperationFactory.dispose();
}
return packagePath;
}
Aggregations