JGit libraryを使用して、ローカルにレポをクローンし、archive
コマンドを使用してレポからファイルをコピーすることができます。例として、sbt-hacklingプラグインがこれを実装する方法を参照してください。
プラットフォーム独立性が必要ない場合は、コマンドラインgitコマンドを呼び出して、clone
/fetch
と依存関係を更新し、archive
を抽出してファイルを抽出します。
コードの一部をコピー、ローカルリポジトリのうち一部のパス:ローカルリポジトリのクローンをコードする
// needed for installSource
// maybe implement some archiver to go directly to files?
org.eclipse.jgit.archive.ArchiveFormats.registerAll()
def installSource(cachedRepo: Git, paths: Seq[String], revision: ObjectId, target: File): Set[File] =
IO.withTemporaryFile(target.getName, ".zip") { tmp =>
val out = new BufferedOutputStream(new FileOutputStream(tmp))
cachedRepo
.archive()
.setFormat("zip")
.setTree(revision)
.setPaths(paths :_*)
.setOutputStream(out)
.call()
IO.unzip(tmp, target)
}
パート:
def downloadGitRepo(local: File)(repo: URI): File = {
val clone = Git
.cloneRepository()
.setURI(repo.toString)
.setDirectory(local)
.setBare(true)
.call()
assert(local.exists())
local
}
おかげで答えをたくさん!私は今日これを試してみましょう。 –