Wednesday, February 8, 2012

Gradle Groovy Console

Say you have a gradle groovy project, and you're really wishing you had something like "grails console" so you could just run a few quick things. Well, you can! Add this to your build.gradle:

task(console, dependsOn: 'classes', type: JavaExec) {
main = 'groovy.ui.Console'
classpath = sourceSets.main.runtimeClasspath
}

Then type gradle console at command prompt and TADA! Groovy Console pops up with access to all the classes in your gradle project. Hat Tip to Bob: http://jadn.com/~bob/

2 comments:

  1. Hi, Mike

    Thanks a lot for this tip. I have created a Gradle plugin based on it, which works for Groovy and Java. Check it out:

    https://github.com/carlosgsouza/gradle-console

    ReplyDelete