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/

3 comments:


  1. Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it, hopefully

    I can add you and follow.




    CMMI Consulting in Chennai

    ReplyDelete
  2. 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