I have a folder with a lot of directories inside. I want to have a gradle script that will loop through them (not recursively) and run
yarn build
in them.
I have tried two approaches (and started several different things), but alas no luck.
task build (description: "Loops through folders and builds"){
FileTree tree = fileTree(dir: 'admin', include: '*/package.json')
tree.each {File file -> println file}
}
task yarnBuild (type: Exec){
executable "bash"
args "find . -type d -exec ls {} \;"
}
With the task build I wanted to find the directories that had the package.json (all of them, really), but then I don't know how to change to that directory to do a "yarn build"
With the task yarnBuild I wanted to just do it with a unix command. But I couldn't get it to work either.
I would be more interested in finding a solution more in line with the "build" task, using actual Gradle. Can anybody give me some pointers? How can I change into those directories? I'm guessing once I'm in the right folder I can just use Exec to run "yarn build".
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…