title: Gradle Exec task and process output
body: <p>I have a python script which prints some strings and updates it's execution progress in console:</p>
  
  <pre><code>if __name__ == '__main__':
      ...
  
      print 'Hello, world!'
  
      while page &lt;= pages:
          ...
  
          done = float(page) / pages
          sys.stdout.write('\r[{0:50s}] {1:.2f}%'.format('#' * int(done * 50), done * 100))
  
          page += 1
  
      print ''
  </code></pre>
  
  <p>When I run it from console like <code>python script.py</code> everything is ok and I can see output and progressbar. I need to run this script as a part of Gradle build, so, I've created a task:</p>
  
  <pre><code>task process(type: Exec) {
      workingDir file('src/main/python')
      commandLine 'python', 'process.py', ...
  }
  </code></pre>
  
  <p>Now, when I use <code>gradle process</code> to execute the script I see no output in console, the last line that is printed is <code>&gt; Building 0% &gt; :process</code></p>
  
  <p>I've tried to use Java 7's <code>ProcessBuilder</code> with no luck too:</p>
  
  <pre><code>task process &lt;&lt; {
      def processBuilder = new ProcessBuilder([
              'python',
              'process.py',
              ...
      ]).directory(file('src/main/python'))
              .redirectInput(ProcessBuilder.Redirect.INHERIT)
              .redirectOutput(ProcessBuilder.Redirect.INHERIT)
              .redirectError(ProcessBuilder.Redirect.INHERIT).start().waitFor()
  }
  </code></pre>
  
  <p>I'm stuck. I really want to see python's output in the same console. How can I achieve it?</p>
  
  <p>UPD: sometimes it somehow prints gibberish: <img src="https://i.stack.imgur.com/0raBC.png" alt="enter image description here"></p>