0
votes

I want to run some groovy scripts before gradle builds debug apk in Android.

task batchTask(type: JavaExec) {
    description 'running tasks'
    exec {
        commandLine './Batch.groovy'
    }

}

added this to build.gradle(app)

apply plugin: 'groovyx.grooid.groovy-android'

android{
        ...

        dependsOn {
            batchTask
        }
}

dependencies {
    ...
    compile 'org.codehaus.groovy:groovy:2.4.0:grooid'
}

added this to build.grade(android)

dependencies { ... classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6' }

I keep getting the error Error:Cause: error=13, Permission denied

stack trace

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

Update:

Running the task inside a Groovy shell did the trick.

task batchTask(type: JavaExec) {
    description 'batchTask in progress'

    new GroovyShell().run(file('Batch.groovy'))
}
1
You seem to be trying to run a command line Exec job with a JavaExec task?tim_yates
Can you upload screenshot of build.grade(android) and build.gradle(app)?tiny sunlight
gradlew assemleDebug --stacktracetiny sunlight
@tinysunlight A screenshot?!?!?!tim_yates
@tim_yates try@noisy ninja's.tiny sunlight

1 Answers

0
votes

Running the task inside a Groovy shell did the trick.

task batchTask(type: JavaExec) {
    description 'batchTask in progress'

    new GroovyShell().run(file('Batch.groovy'))
}