我有一个gradle任务,我可以在其中添加标签到我的Bitbucket存储库,如下所示:
task createTag <<{
def grgit = clone(dir: 'C:\\Repo1', uri: 'https://bitbucket.org/..')
grgit.tag.add(name: 'tag-name', message: 'Some Message!')
grgit.push(tags: true)
}
现在,我想将其移至我的自定义插件项目。我写的是 CreateTagPluginTask.groovy:
class CreateTagPlugin extends DefaultTask{
@TaskAction
def AddTag(){
def grgit = clone(dir: 'C:\\Repo2', uri: 'https://bitbucket.org/smunjal12589/grgit_task')
grgit.tag.add(name: 'tag-name', message: 'Some Message!')
grgit.push(tags: true)
}
}
Plugin.groovy:
project.tasks.create("CreateTag",CreateTagPlugin.class)
当我执行此操作时,我在Android studio项目中出错:找不到方法clone()
这不起作用,也不识别克隆功能。任何指针如何得到这个。
答案 0 :(得分:0)
我可以解决这个问题:
class CreateTagTask extends DefaultTask{
@TaskAction
def showLog(){
println("Adding tag in the repo")
def credentials = new Credentials("user","pass")
def grgit = org.ajoberstar.grgit.Grgit.open(dir: project.parent.projectDir,credentials)
grgit.tag.add(name: "tagName", message: "tagMessage")
grgit.push(tags: true)
}}