Gradle:如何在任务中克隆git仓库? [英] Gradle: how to clone a git repo in a task?

查看:212
本文介绍了Gradle:如何在任务中克隆git仓库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个gradle构建脚本,并且希望编写一个任务来克隆远程git存储库。我该怎么做?

解决方案

克隆可以使用 Gradle-git插件。要使用插件,您应该先下载它:

  buildscript {
repositories {mavenCentral()}
依赖{classpath'org.ajoberstar:gradle-git:0.2.3'}
}

然后编写一个像这样的任务:

pre $ import $ or $ $ $ $ $
任务cloneGitRepo(类型:GitClone){
def destination = file(destination_folder)
uri =your_git_repo_uri
destinationPath =目标
bare = false
enabled =!destination.exists()//仅克隆一次
}


Suppose I have a gradle build script and want to write a task to clone a remote git repository. How do I do that?

解决方案

The cloning can be done using the Gradle-git plugin. To use the plugin you should download it first:

buildscript {
  repositories { mavenCentral() }
  dependencies { classpath 'org.ajoberstar:gradle-git:0.2.3' }
}

Then write a task like this one:

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
}

这篇关于Gradle:如何在任务中克隆git仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆