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
}