Gradle: How to perform git pull through gradle?

前端 未结 2 1985
渐次进展
渐次进展 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条回答
  •  眼角桃花
    2021-02-15 02:22

    You can create Exec task and run any shell/cmd command. No extra plugin dependency required for simple tasks.

    task gitPull(type: Exec) {
        description 'Pulls git.'
        commandLine "git", "pull"
    }
    

    Usage: gradlew gitPull

    You should see smth like this:

    gradlew gitPull 
    Parallel execution is an incubating feature.
    :app:gitPull 
    Already up-to-date.
    
    BUILD SUCCESSFUL
    
    Total time: 9.232 secs
    

    Where Already up-to-date. is the output from git pull command.

提交回复
热议问题