title: Use Gradle to run Yarn in every folder
body: <p>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 </p>
  
  <pre><code> yarn build 
  </code></pre>
  
  <p>in them. </p>
  
  <p>I have tried two approaches (and started several different things), but alas no luck. </p>
  
  <pre><code>task build (description: "Loops through folders and builds"){
      FileTree tree = fileTree(dir: 'admin', include: '*/package.json')
  
      tree.each {File file -&gt; println file}
  
  }
  
  task yarnBuild (type: Exec){
      executable "bash"
      args "find . -type d -exec ls {} \\;"
  }
  </code></pre>
  
  <p>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"</p>
  
  <p>With the task yarnBuild I wanted to just do it with a unix command. But I couldn't get it to work either. </p>
  
  <p>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". </p>
  
  <p>Thanks! </p>