GRECLIPSE
  1. GRECLIPSE
  2. GRECLIPSE-1020

"Run as Groovy" options not available in Groovy project on STS 2.6

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: None
    • Fix Version/s: 2.5.0Release
    • Component/s: None
    • Labels:
      None
    • Environment:
      STS 2.6.0.2 on Fedora 13, Vaio F12
    • Number of attachments :
      0

      Description

      In a new Groovy project when right-clicking a Groovy file, there is no Run as Groovy Script option (only Aspect/Java application). I have tried changing to all available perspectives (spring,java,javaEE,grails) to no avail.

      In Grails projects right-clicking a groovy file gives Aspect/Java = 3 Grails specific run as options.

      I seem to recall run as Groovy options existing pre-STS 2.5, what has changed, am I the only one affected here? My fingers are dearly sore testing in groovyConsole, no autocomplete, backspace in spaces instead of tabs (arggghh), etc.

      How can I get run as Groovy options back in place for Groovy projects?? Everything else works fine in STS with Groovy, great autocomplete, syntax checking, etc.

      Please save my aching fingers!!

        Activity

        Hide
        Andrew Eisenberg added a comment -

        What is the file that you are trying to run? Is the file a groovy script?

        The Run As Groovy Script option only appears when the file is a true script (ie- no explicit main method and statements are defined outside of a class definition).

        Show
        Andrew Eisenberg added a comment - What is the file that you are trying to run? Is the file a groovy script? The Run As Groovy Script option only appears when the file is a true script (ie- no explicit main method and statements are defined outside of a class definition).
        Hide
        Andrew Eisenberg added a comment -

        Can you please attach a file where you would expect a Run as Groovy Script option, but do not see it?

        Show
        Andrew Eisenberg added a comment - Can you please attach a file where you would expect a Run as Groovy Script option, but do not see it?
        Hide
        James Lang added a comment -

        Andrew,

        yes, I have been attempting to run groovy test classes vs. plain scripts.

        Interestingly, if you do add a main method to a class then the run as groovy options DO appear; however, in order to combine class definition with statements outside of the class (i.e. actually get output from "run as" groovy), the class name must be different than the file name.

        // Foo.groovy
        class Foo {}
        println "hey"

        error: duplicate class definition (class and script same name); also no "run as" groovy unless add main method.

        // Foo.groovy
        class Bar {}
        println "hey"

        works fine, "run as" groovy options appear and can define statements outside class scope.

        Not sure if this is a bug, or just Groovy.lang restrictions (with class/script name issue) which STS has no control over.

        Show
        James Lang added a comment - Andrew, yes, I have been attempting to run groovy test classes vs. plain scripts. Interestingly, if you do add a main method to a class then the run as groovy options DO appear; however, in order to combine class definition with statements outside of the class (i.e. actually get output from "run as" groovy), the class name must be different than the file name. // Foo.groovy class Foo {} println "hey" error: duplicate class definition (class and script same name); also no "run as" groovy unless add main method. // Foo.groovy class Bar {} println "hey" works fine, "run as" groovy options appear and can define statements outside class scope. Not sure if this is a bug, or just Groovy.lang restrictions (with class/script name issue) which STS has no control over.
        Hide
        Andrew Eisenberg added a comment -

        Your first example is indeed a groovy issue and this is expected. When you create a script, it implicitly defines a class that has the same name as the file name. So, what you did was define a second class named Foo and this causes a compile problem.

        Do you have another example of a script that you would like to run, but can't?

        I do see that this code cannot be run as a groovy script, but it can be run as a JUnit test case:

        class A extends GroovyTestCase {
        	public void testYYY() throws Exception {
        		
        	}
        }
        

        Is this a problem for you?

        Show
        Andrew Eisenberg added a comment - Your first example is indeed a groovy issue and this is expected. When you create a script, it implicitly defines a class that has the same name as the file name. So, what you did was define a second class named Foo and this causes a compile problem. Do you have another example of a script that you would like to run, but can't? I do see that this code cannot be run as a groovy script, but it can be run as a JUnit test case: class A extends GroovyTestCase { public void testYYY() throws Exception { } } Is this a problem for you?
        Hide
        James Lang added a comment -

        Andrew, for testing I can create a plain script that imports tests to run, so not a deal breaker.

        The huge win here is that I can code in STS and run via groovy console, thus saving my fingers from working in groovy console itself, which, while nice to have, is terribly inefficient (no code completion, no backspace in tabs, and other madness)

        BTW, STS is a wonderful Java/Groovy/Grails IDE on Linux, worlds better than IntelliJ, for example, where the GUI is just plain gruesome, could not tolerate spending my days looking at IJ, made me sick ;--(

        I'll post back if I encounter any other issues with "run as" groovy, but for now consider it solved, user error ;--)

        p.s. looking forward to Groovy 1.8 support, just starting to play around with RC3...

        Thanks for the great work!

        Show
        James Lang added a comment - Andrew, for testing I can create a plain script that imports tests to run, so not a deal breaker. The huge win here is that I can code in STS and run via groovy console, thus saving my fingers from working in groovy console itself, which, while nice to have, is terribly inefficient (no code completion, no backspace in tabs, and other madness) BTW, STS is a wonderful Java/Groovy/Grails IDE on Linux, worlds better than IntelliJ, for example, where the GUI is just plain gruesome, could not tolerate spending my days looking at IJ, made me sick ;--( I'll post back if I encounter any other issues with "run as" groovy, but for now consider it solved, user error ;--) p.s. looking forward to Groovy 1.8 support, just starting to play around with RC3... Thanks for the great work!
        Hide
        Andrew Eisenberg added a comment -

        Thanks for getting back to me. Expect 1.8 support momentarily.

        Show
        Andrew Eisenberg added a comment - Thanks for getting back to me. Expect 1.8 support momentarily.

          People

          • Assignee:
            Andrew Eisenberg
            Reporter:
            James Lang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: