Run shell command in gradle but NOT inside a task

前端 未结 1 1759
被撕碎了的回忆
被撕碎了的回忆 2021-01-03 22:56

What I currently have is:

task myTask (type : Exec) {
   executable \"something.sh\"
   ... (a lot of other things)
   args \"-t\"
   args ext.target
}

task         


        
1条回答
  •  囚心锁ツ
    2021-01-03 23:15

    You can do something like the following:

    def doMyThing(String target) {
        exec {
            executable "something.sh"
            args "-t", target
        }
    }
    
    task doIt {
        doLast {
            doMyThing("/tmp/foo")
            doMyThing("/tmp/gee")
        }
    }
    

    The exec here is not a task, it's the Project.exec() method.

    0 讨论(0)
提交回复
热议问题