Ser*_*iss 23
克隆可以使用Gradle-git插件完成.要使用该插件,您应该先下载它:
buildscript {
repositories { mavenCentral() }
dependencies { classpath 'org.ajoberstar:gradle-git:0.2.3' }
}
Run Code Online (Sandbox Code Playgroud)
然后写一个像这样的任务:
import org.ajoberstar.gradle.git.tasks.*
task cloneGitRepo(type: GitClone) {
def destination = file("destination_folder")
uri = "your_git_repo_uri"
destinationPath = destination
bare = false
enabled = !destination.exists() //to clone only once
}
Run Code Online (Sandbox Code Playgroud)
小智 16
使用较新版本的gradle-git(0.7.0及更高版本),您可以创建如下任务:
import org.ajoberstar.grgit.*
task clone << {
Grgit.clone(dir: file('build/repo'), uri: 'git@github.com:user/repo.git')
}
Run Code Online (Sandbox Code Playgroud)
有一个Git插件 - 这里的文档:Gradle-git.该插件有一个克隆方法:GitClone
可能有以下几点:
GitClone clone = new GitClone();
clone.setUri("http://remote.repository/");
clone.setDestinationPath("//local/path");
clone.setBare(false);
clone.cloneRepo();
Run Code Online (Sandbox Code Playgroud)
小智 5
前面提到的Gradle-git插件似乎已经从提供简单的"克隆这个repo到该目录"功能转移,所以我写了一个简单的任务,就是这样:
https://github.com/palominolabs/gradle-git-clone-task
| 归档时间: |
|
| 查看次数: |
24011 次 |
| 最近记录: |