使用 Grgit 在我的 gradle 上克隆 git 存储库
clone git repository on my gradle using Grgit
我有一个运行脚本的 gradle 项目,在其中某处,我需要克隆一个 git 存储库。
我以前用 svn 有它 运行,但我将我们公司的 SCM 更改为 gitlab,我需要更改代码以便它现在从 git.[= 克隆 repo 16=]
我需要一些类似于此 SVN 代码的东西:
task exportLibs(type: SvnExport) {
svnUrl = "http://<svn-url>"
targetDir = "<target-dir-to-download-files>"
}
所以我阅读了有关 Grgit 的内容,但是网上没有一个例子,如何做一个简单的 git 克隆(只有这个 link http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/operation/CloneOp.html) .如果有人可以帮助我解决这个问题,或者可以让我参与他的 grgit 项目,那么我会从中学习,那就太棒了!
--编辑--
当我尝试如下使用 grgit 时:
group 'test'
version '1.0-SNAPSHOT'
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.ajoberstar:gradle-git:1.7.2"
}
}
apply plugin: 'java'
apply plugin: 'org.ajoberstar.grgit'
org.ajoberstar.grgit.auth.hardcoded.allow=true
task pullFromGit{
doLast {
//grgit.pull()
}
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
我已使用此属性对其进行初始化,但出现以下错误:
A problem occurred evaluating root project 'grgit'.
Could not get unknown property 'org' for root project 'grgit' of type org.gradle.api.Project.
some examples and the API documentation项目的github页上有一个link。以下代码片段可以解决您的问题(在本例中,它将 grgit 项目克隆到 grgit
目录)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar:grgit:1.7.2'
}
}
task hello {
doLast {
org.ajoberstar.grgit.Grgit.clone(dir: 'grgit', uri: 'https://github.com/ajoberstar/grgit.git')
}
}
已编辑问题的答案
documentation states that org.ajoberstar.grgit.auth.hardcoded.allow
is a system property. Your assignment is not a valid way to set system properties, see the answer to 中有关设置系统属性的示例 groovy。
我的代码中可能有一些特殊的导入,导致最后我唯一可以做的克隆是 shell exec。
问题已解决,但不是我遇到的错误...
我有一个运行脚本的 gradle 项目,在其中某处,我需要克隆一个 git 存储库。 我以前用 svn 有它 运行,但我将我们公司的 SCM 更改为 gitlab,我需要更改代码以便它现在从 git.[= 克隆 repo 16=]
我需要一些类似于此 SVN 代码的东西:
task exportLibs(type: SvnExport) {
svnUrl = "http://<svn-url>"
targetDir = "<target-dir-to-download-files>"
}
所以我阅读了有关 Grgit 的内容,但是网上没有一个例子,如何做一个简单的 git 克隆(只有这个 link http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/operation/CloneOp.html) .如果有人可以帮助我解决这个问题,或者可以让我参与他的 grgit 项目,那么我会从中学习,那就太棒了!
--编辑--
当我尝试如下使用 grgit 时:
group 'test'
version '1.0-SNAPSHOT'
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.ajoberstar:gradle-git:1.7.2"
}
}
apply plugin: 'java'
apply plugin: 'org.ajoberstar.grgit'
org.ajoberstar.grgit.auth.hardcoded.allow=true
task pullFromGit{
doLast {
//grgit.pull()
}
}
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
我已使用此属性对其进行初始化,但出现以下错误:
A problem occurred evaluating root project 'grgit'.
Could not get unknown property 'org' for root project 'grgit' of type org.gradle.api.Project.
some examples and the API documentation项目的github页上有一个link。以下代码片段可以解决您的问题(在本例中,它将 grgit 项目克隆到 grgit
目录)
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.ajoberstar:grgit:1.7.2'
}
}
task hello {
doLast {
org.ajoberstar.grgit.Grgit.clone(dir: 'grgit', uri: 'https://github.com/ajoberstar/grgit.git')
}
}
已编辑问题的答案
documentation states that org.ajoberstar.grgit.auth.hardcoded.allow
is a system property. Your assignment is not a valid way to set system properties, see the answer to
我的代码中可能有一些特殊的导入,导致最后我唯一可以做的克隆是 shell exec。 问题已解决,但不是我遇到的错误...