Running groovy shell from gradle task

I’m trying to run a groovy shell ( with my project’s classpath. I created the following task:

task(shell, dependsOn: ':core:compileJava', type: JavaExec) {
                                                                                                                                              main = ''
                                                                                                                                                            classpath + project(':core').sourceSets.main.runtimeClasspath
                                                                                                                       standardInput =

which works, but due to some sort of buffering issue, if I hit backspace in the console the cursor doesn’t move back and the text still appears, but it is apparently removed. Is there a workaround for this? I couldn’t find much aside from

I almost got it to run with the following:

apply plugin:‘application’

mainClassName = ‘’

run.standardInput =

dependencies {

compile ‘org.codehaus.groovy:groovy-all:2.2.2’

compile ‘org.fusesource.jansi:jansi:1.11’

compile ‘commons-cli:commons-cli:1.2’

compile ‘jline:jline:2.11’

compile project(‘:my-module’)


And then from the command line

gradle run

However it gets stuck on:

Groovy Shell (2.2.2, JVM: 1.6.0_45)

Type ‘help’ or ‘\h’ for help.


Building 87% > :console:run

and if I type nothing shows up. I feel like Gradle is sucking all the input from ‘’ not allowing me to type anything. I also have an SO for this.


This seems to work:

configurations {
  dependencies {
 shell 'commons-cli:commons-cli:1.2'
 shell('jline:jline:2.11') {
  exclude(group: 'junit', module: 'junit')
 shell 'org.codehaus.groovy:groovy-groovysh:2.2.+'
  task(shell, dependsOn: 'classes') << {
 def classpath = sourceSets.main.runtimeClasspath +
   def command = [
  '-cp', classpath.collect().join(':'),
  '--terminal', 'unix']
   def proc = new ProcessBuilder(command)

Then, execute it via

gradle shell

Uhm, getting:

  • What went wrong:

Execution failed for task ‘:console:shell’.

No such property: Redirect for class: java.lang.ProcessBuilder

Do you have any includes defined?

Oh wait, I am using Java 6, ‘Redirect’ is not there.