Gradle: How to perform git pull through gradle?

前端 未结 2 2040
渐次进展
渐次进展 2021-02-15 01:45

I want to pull changes from git repo before compilation begins. I found this Gradle: how to clone a git repo in a task?, but it clones the repo instead of fetching just the cha

2条回答
  •  萌比男神i
    2021-02-15 02:19

    The following gradle script should be helpful:

    import org.ajoberstar.grgit.*
    
    buildscript {
       repositories { 
          mavenCentral() 
       }
       dependencies { 
          classpath 'org.ajoberstar:gradle-git:1.1.0' 
       }
    }
    
    task pull << {
       def grgit = Grgit.open(dir: project.file('.'))
       grgit.pull(rebase: false)
    }
    

提交回复
热议问题