Groovy interactive shell

  • tomstrummer

    tomstrummer - 2006-11-14


    Does Groovy Monkey have an interactive shell? 

    Really, what I'm looking for is a Groovy shell that I can load with the classpath of a given project within eclipse.  That is, I want to point to a project, click "Run shell" and then have a Groovy shell from which I can instanciate and use my classes (including any dependencies, of course). 

    I think I could do something like this w/ an ant script but then I would have to create a script with the correct classpath for every project.  Is there an eclipse variable to get the classpath for the current project (similar to how "project_loc" gets me the path of the selected project)?  The only other idea I have would be to parse the .classpath file for a project, which isn't particularly appealing.

    Thanks for your help!!

    • James E. Ervin

      James E. Ervin - 2006-11-15

      I have thought of doing what you are suggesting as an enhancement to Groovy Monkey.  There is a project called Eclipse Shell that does things of this sort that you may want to look into.  As far as what you would like to do in running a shell using the classpath of a project, you run directly into the issue of the fact that the workspace is not the workbench instance.  I assume you know about self hosting in Eclipse and want something more lightweight, right?  Self hosting is the Eclipse approved method of running code in your workspace. 

      I am thinking of adding this as an enhancement.  I am thinking of using the header metadata to resolve the classpath, etc... and then using the Groovy Shell ( also Beanshell/JRuby ) interpreters.  Using a shell to explore is not a method I tend to use much, but if more ppl would like it I would definitely raise its priority.


    • tomstrummer

      tomstrummer - 2006-11-20

      I'm not familiar with "self hosting."  I'll look into that.

      I'll also take a look at Eclipse Shell to see if that can cover what I'm looking for.  I suspect this may be something better suited for the Groovy-Eclipse plugin so I'm looking at going that route. 

      Thanks for your help!

      • James E. Ervin

        James E. Ervin - 2006-11-20

        Not a problem.  Good luck.  I guess one of the advantages of Open Source is that I am not trying to get you to use my product at all costs. ;)

        Self hosting is where you launch another instance of eclipse from within eclipse using projects in your workspace.  It is pretty cool especially in debug mode.


    • Joe

      Joe - 2006-12-01

      How do you get the equivalent of the absolute path of the current selected project root ?


      • James E. Ervin

        James E. Ervin - 2006-12-01

        Try the DOM object project.  It should be set to allow you to get the IProject instance of the selected project.
        Copy and paste this quick script:
        --- Came wiffling through the eclipsey wood ---
        * Menu: Test Project
        * Script-Path: /GroovyMonkeyScripts/monkey/
        * Kudos: ERVIN
        * License: EPL 1.0
        * DOM:
        out.println "project: ${project}"
        out.println "project: ${project.dump()}"
        out.println "project.eclipseObject: ${project.eclipseObject}"
        out.println "project.location: ${project.eclipseObject.location}"

        --- And burbled as it ran! ---

        The location attribute of the IProject object is an IPath instance that will display the full path as a string with its toString() method or you can do the toFile() method and get back a instance.

        Hope it helps,


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks