title: Executing bash script in gradle
body: <p>I am doing functional testing with geb.</p>
  
  <p>My application is deployed using virgo and uses HSQLDB to store data. I would like to perform tests on this working version of application, but I would like to start with empty database, every time I run webtests.</p>
  
  <p>I wrote a simple bash script</p>
  
  <pre><code>#!/bin/sh
  rm -rf $VIRGO_HOME/aresdb*
  $VIRGO_HOME/bin/shutdown.sh &amp;
  sleep 10
  $VIRGO_HOME/bin/startup.sh &amp;
  </code></pre>
  
  <p>which removes the database and restarts virgo.</p>
  
  <p>However, when I add it to my build.gradle task executing command never ends.</p>
  
  <pre><code>task cleanDB(type: Exec) {
      commandLine './clean.sh' 
  }
  </code></pre>
  
  <p>Why is it this way? When I run this script in console it returns quickly (but virgo still writes to the console).</p>
  
  <p>I have tried to run it in separate thread, but I encountered following error:</p>
  
  <pre><code>task cleanDBThread()&lt;&lt;{
      def cleanDBThread1 = Thread.start {
           cleanDB.execute()
      }
      sleep 10000
      println "wake up!"
  }
  
  Exception in thread "Thread-32" java.lang.IllegalStateException:
  Cannot start long running operation, as the task artifact state cache
  (/home/tomasz/ares/.gradle/1.0-milestone-9/taskArtifacts) has not been locked.
  </code></pre>
  
  <p>I also tried setting 'create-drop' in hibernate configuration, but it also requires restarting virgo. Even redeploying the application does not help.</p>
  
  <p>What should I do to run webtests with empty database?</p>