title: Add groovy script to run through gradle android
body: <p>I want to run some groovy scripts before gradle builds debug apk in Android.</p>
  
  <pre><code>task batchTask(type: JavaExec) {
      description 'running tasks'
      exec {
          commandLine './Batch.groovy'
      }
  
  }
  </code></pre>
  
  <p>added this to build.gradle(app)</p>
  
  <pre><code>apply plugin: 'groovyx.grooid.groovy-android'
  
  android{
          ...
  
          dependsOn {
              batchTask
          }
  }
  
  dependencies {
      ...
      compile 'org.codehaus.groovy:groovy:2.4.0:grooid'
  }
  </code></pre>
  
  <p>added this to build.grade(android)</p>
  
  <p>dependencies {
    ...
      classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
  }</p>
  
  <p>I keep getting the error Error:Cause: error=13, Permission denied</p>
  
  <p>stack trace</p>
  
  <blockquote>
    <p>15:24:22.688 [DEBUG] [org.gradle.process.internal.DefaultExecHandle]
    Changing state to: STARTING 15:24:22.689 [DEBUG]
    [org.gradle.process.internal.DefaultExecHandle] Waiting until process
    started: command './Batch.groovy'. 15:24:22.693 [DEBUG]
    [org.gradle.process.internal.DefaultExecHandle] Changing state to:
    FAILED 15:24:22.693 [DEBUG]
    [org.gradle.process.internal.DefaultExecHandle] Process 'command
    './Batch.groovy'' finished with exit value -1 (state: FAILED)
    15:24:22.695 [DEBUG]
    [org.gradle.configuration.project.BuildScriptProcessor] Timing:
    Running the build script took 1.866 secs 15:24:22.798 [ERROR]
    [org.gradle.BuildExceptionReporter]  15:24:22.799 [ERROR]
    [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an
    exception. 15:24:22.799 [ERROR] [org.gradle.BuildExceptionReporter] 
    15:24:22.800 [ERROR] [org.gradle.BuildExceptionReporter] * What went
    wrong: 15:24:22.800 [ERROR] [org.gradle.BuildExceptionReporter] A
    problem occurred evaluating project ':app'. 15:24:22.800 [ERROR]
    [org.gradle.BuildExceptionReporter] > A problem occurred starting
    process 'command './Batch.groovy'' 15:24:22.801 [ERROR]
    [org.gradle.BuildExceptionReporter]  15:24:22.801 [ERROR]
    [org.gradle.BuildExceptionReporter] * Try: 15:24:22.801 [ERROR]
    [org.gradle.BuildExceptionReporter] Run with --stacktrace option to
    get the stack trace.  15:24:22.802 [LIFECYCLE]
    [org.gradle.BuildResultLogger]  15:24:22.802 [LIFECYCLE]
    [org.gradle.BuildResultLogger] BUILD FAILED</p>
  </blockquote>
  
  <p>Update:</p>
  
  <p>Running the task inside a Groovy shell did the trick.</p>
  
  <pre><code>task batchTask(type: JavaExec) {
      description 'batchTask in progress'
  
      new GroovyShell().run(file('Batch.groovy'))
  }
  </code></pre>