title: Executing commands with Gradle?
body: <p>I am trying to execute a command with gradle with the below task:</p>
  
  <pre><code>task stopServer(dependsOn: war, type: Exec) &lt;&lt; {
      commandLine 'pkill -9 tomcat'
  }
  </code></pre>
  
  <p>When I run it I get the following error:</p>
  
  <pre><code>* What went wrong:
  Execution failed for task ':stopServer'.
  &gt; execCommand == null!
  </code></pre>
  
  <p>And when my task is like this:</p>
  
  <pre><code>task stopServer(dependsOn: war) &lt;&lt; {
      exec {
          commandLine 'pkill -9 tomcat'
      }
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>* What went wrong:
  Execution failed for task ':stopServer'.
  &gt; A problem occurred starting process 'command 'pkill -9 tomcat''
  </code></pre>
  
  <p>Can you tell me where I am going wrong in each of these approaches? </p>
  
  <p>If neither of above are right way of executing then please specify the way of doing it probably with an example.</p>