Uploaded image for project: 'Grails'
  1. Grails
  2. GRAILS-8776

Reloading doesn't work when script/_Events.groovy exists

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Debian unstable amd64
    • Testcase included:
      yes

      Description

      Following my goal of reporting a new bug every single day, here is the example application:

      https://github.com/rosenfeld/grails_bug_reloadingWithEvents

      Instructions:

      https://github.com/rosenfeld/grails_bug_reloadingWithEvents/commit/604541948273b74a3a07811a00e351efa6484b9e

      _Events.groovy was extracted from this suggestion by Graeme:

      http://grails.1312388.n4.nabble.com/Where-should-I-put-my-test-helpers-files-to-be-shared-among-unit-and-integration-tests-td4345583.html

      This is the content:

      https://github.com/rosenfeld/grails_bug_reloadingWithEvents/commit/90a3a91646deeee54d4ef9dff21229b29e1ffaa0

      I've reported this issue in the thread but it didn't get any attention, so I'm reporting it here.

        Activity

        Hide
        Bobby Warner added a comment -

        I did some testing and the issue only happens in interactive mode not with the regular grails run-app. Also, the issue goes away if you comment out the first event (eventCompileStart) and reloading works fine if eventAllTestsStart is the only closure in _Events.groovy. So, it's something specific to eventCompileStart in interactive mode. Hope that helps narrow it down. Thanks, Bobby

        Show
        Bobby Warner added a comment - I did some testing and the issue only happens in interactive mode not with the regular grails run-app. Also, the issue goes away if you comment out the first event (eventCompileStart) and reloading works fine if eventAllTestsStart is the only closure in _Events.groovy. So, it's something specific to eventCompileStart in interactive mode. Hope that helps narrow it down. Thanks, Bobby
        Hide
        Rodrigo Rosenfeld Rosas added a comment -

        I didn't test in interactive mode here. It just happens with "grails run-app" in my computer. Maybe this is also related to Vim swapfiles, as I've enabled them again after Grails 2.0.1 release.

        But you're right about your observations. Only eventCompileStart seems to be the cause of the issue. I'll update the example app in GitHub.

        Show
        Rodrigo Rosenfeld Rosas added a comment - I didn't test in interactive mode here. It just happens with "grails run-app" in my computer. Maybe this is also related to Vim swapfiles, as I've enabled them again after Grails 2.0.1 release. But you're right about your observations. Only eventCompileStart seems to be the cause of the issue. I'll update the example app in GitHub.
        Hide
        Bobby Warner added a comment -

        In fact, I think you are using the wrong event. You should use TestCompileStart instead of CompileStart, right? I tested reloading in interactive mode with your sample app by changing eventCompileStart to eventTestCompileStart and reloading works great. Please confirm it works for your real app. Thanks, Bobby

        Show
        Bobby Warner added a comment - In fact, I think you are using the wrong event. You should use TestCompileStart instead of CompileStart, right? I tested reloading in interactive mode with your sample app by changing eventCompileStart to eventTestCompileStart and reloading works great. Please confirm it works for your real app. Thanks, Bobby
        Hide
        Rodrigo Rosenfeld Rosas added a comment -

        The application was updated in GitHub. And Vim swapfiles doesn't affect the issue here. It still doesn't work even when not in the interactive console.

        Show
        Rodrigo Rosenfeld Rosas added a comment - The application was updated in GitHub. And Vim swapfiles doesn't affect the issue here. It still doesn't work even when not in the interactive console.
        Hide
        Bobby Warner added a comment -

        I don't use VIM (OSX + TextMate), so I won't be able to test that for you. Reloading works for me (interactive and non-interactive) after I made the change in my previous comment (eventCompileStart to eventTestCompileStart). Please confirm whether or not eventTestCompileStart works for you in your app. Thanks, Bobby

        Show
        Bobby Warner added a comment - I don't use VIM (OSX + TextMate), so I won't be able to test that for you. Reloading works for me (interactive and non-interactive) after I made the change in my previous comment (eventCompileStart to eventTestCompileStart). Please confirm whether or not eventTestCompileStart works for you in your app. Thanks, Bobby
        Hide
        Rodrigo Rosenfeld Rosas added a comment -

        Changing eventCompileStart with eventTestCompileStart won't make any difference in this example application as I didn't write any test using this feature for the example.

        But it I change as you suggested my common test classes won't get compiled. This _Events.groovy was actually suggested by Graeme in some thread in the mailing list. See the related JIRA here:

        http://jira.grails.org/browse/GRAILS-8777

        I've never really read anything in the documentation about those events, so I know nothing about them.

        Show
        Rodrigo Rosenfeld Rosas added a comment - Changing eventCompileStart with eventTestCompileStart won't make any difference in this example application as I didn't write any test using this feature for the example. But it I change as you suggested my common test classes won't get compiled. This _Events.groovy was actually suggested by Graeme in some thread in the mailing list. See the related JIRA here: http://jira.grails.org/browse/GRAILS-8777 I've never really read anything in the documentation about those events, so I know nothing about them.
        Hide
        Lyle Hanson added a comment - - edited

        This is causing reloading to fail for me also. If I comment out my eventCompileStart block, I suddenly get back the reloading that I've been missing for so long!

        I'm on OS X 10.8.3, Grails 2.2.1.

        Show
        Lyle Hanson added a comment - - edited This is causing reloading to fail for me also. If I comment out my eventCompileStart block, I suddenly get back the reloading that I've been missing for so long! I'm on OS X 10.8.3, Grails 2.2.1.
        Hide
        Lyle Hanson added a comment - - edited

        Further experimentation reveals that reloading works for me even if I have code in eventCompileStart as long as I don't touch projectCompiler.srcDirectories:

        extraSrcDirs = [ "$basedir/src/java/generated-sources" ]
        
        eventCompileStart = {
            // Uncommenting this line breaks auto-reloading:
            //extraSrcDirs.each { projectCompiler.srcDirectories << it }
        
            //...other stuff...
        }
        
        Show
        Lyle Hanson added a comment - - edited Further experimentation reveals that reloading works for me even if I have code in eventCompileStart as long as I don't touch projectCompiler.srcDirectories : extraSrcDirs = [ "$basedir/src/java/generated-sources" ] eventCompileStart = { // Uncommenting this line breaks auto-reloading: //extraSrcDirs.each { projectCompiler.srcDirectories << it } //...other stuff... }
        Hide
        Lyle Hanson added a comment -

        Well, this is frustrating. It seems that now reloading works for me even if I uncomment the `srcDirectories` bit. Hopefully others can determine if this is related to their problem at all so we can narrow it down further?

        Show
        Lyle Hanson added a comment - Well, this is frustrating. It seems that now reloading works for me even if I uncomment the `srcDirectories` bit. Hopefully others can determine if this is related to their problem at all so we can narrow it down further?

          People

          • Assignee:
            Unassigned
            Reporter:
            Rodrigo Rosenfeld Rosas
          • Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:

              Development