title: gradle: Execute task "type:Exec" with many arguments with spaces
body: <p>I have the gradle task that should create Websphere profile on Windows OS</p>
  
  <pre><code>task createProfile(type:Exec) {
  
      def commandToExecute = new StringBuffer()
      def profile = 'AppSrv02'
      def wasHome = 'C:/IBM new/WebSphere/AppServer'
  
      def str = new LinkedList &lt;String&gt; ();
      str.add('cmd')
      str.add('/c')
      str.add(wasHome + '/bin/manageprofiles.bat')
      str.add('-create')
      str.add('-profileName')
      str.add(profile)
      //str.add('-templatePath')
      //str.add(wasHome + '/profileTemplates/default')
  
      println (str)
      commandLine str.toArray()
  
  }
  </code></pre>
  
  <p>And the problem appears if I uncomment commented lines, after it task fails and say me that: "C:/IBM" is not valid batch file. If I put profileTemplates not in the folder that contains spaces, everything works fine again. But templates should lies int wasHome( And sometimes wasHome has spaces( </p>
  
  <p>I have, now ideas why adding templates key with value with spaces influence in such way that Gradle tries to start "C:/IBM" instead specified 'C:/IBM new/WebSphere/AppServer/bin/manageprofiles.bat'. It seems that, possibly, problem inside java.lang.ProcessBuilder.</p>
  
  <p>I tries to quote paths, by adding  <code> "/"" </code> but nothing works(((( what isn't surprise, because ProcessBuilder implies quoting by itself if it is needed.</p>
  
  <p>So, I am asking if anybody had the similar problem and could recommend how to work around this issue? Thanks in advance. </p>