Groovy
  1. Groovy
  2. GROOVY-1430

Invalid Package declaration: abc.groovy is not in a source folder matching the package declaration

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      GroovyPlugin 1.0.0.20060711

      Description

      Copied from: http://www.nabble.com/Eclipse-and-%27Invalid-Package-Declaration%27-error.-tf1897916.html#a5449140

      I created a app with grails0.2, imported it into eclipse3.2, have all subfolders marked as src-folders (default), but still get errors like this in eclipse:

      "Invalid Package declaration in script: C:\dev\grails\inventory\grails-app\conf\ApplicationBootStrap.groovy is not in a source folder matching the package declaration: "

      (Of course) my ApplicationBootStrap.groovy doesn't have a package declaration, like all other generated groovy-files it is starting with "class xyz" instantly.

      My .classpath file:
      <classpathentry kind="src" path="grails-app/conf"/>

      Is this a bug of the groovy plugin?

        Activity

        Hide
        Scott Hickey added a comment -

        There were some emails that I exchanged with someone using Grails with Eclipse and they were focused around not being able to create compile a class without a package declaration. I am able to do this.

        I think to get to the root of the problem, I will create a sample Grails application and try to bring it into Eclipse so I have a common frame of reference for understanding the errors.

        Show
        Scott Hickey added a comment - There were some emails that I exchanged with someone using Grails with Eclipse and they were focused around not being able to create compile a class without a package declaration. I am able to do this. I think to get to the root of the problem, I will create a sample Grails application and try to bring it into Eclipse so I have a common frame of reference for understanding the errors.
        Hide
        James E. Ervin added a comment -

        I just did the grails install of version 0.2 and started following the instructions of the quick start to create a grails app. I imported the project into my eclipse ( version 3.2 ) workspace and it was not seamless. I first had to set the GRAILS_HOME variable in eclipse and then had to tell it not to use grails-0.2-SNAPSHOT.jar and instead use grails-0.2.jar. I also had to add a JAVA_HOME variable and reedit the class path entry to point at %JAVA_HOME%/lib/tools.jar. After I did this I am not getting the same problems with the building of groovy scripts....

        Show
        James E. Ervin added a comment - I just did the grails install of version 0.2 and started following the instructions of the quick start to create a grails app. I imported the project into my eclipse ( version 3.2 ) workspace and it was not seamless. I first had to set the GRAILS_HOME variable in eclipse and then had to tell it not to use grails-0.2-SNAPSHOT.jar and instead use grails-0.2.jar. I also had to add a JAVA_HOME variable and reedit the class path entry to point at %JAVA_HOME%/lib/tools.jar. After I did this I am not getting the same problems with the building of groovy scripts....
        Hide
        James E. Ervin added a comment -

        In fact I noticed that the groovy scripts are being copied into bin instead of the .class files. Is this a recent fix or something?

        Show
        James E. Ervin added a comment - In fact I noticed that the groovy scripts are being copied into bin instead of the .class files. Is this a recent fix or something?
        Hide
        Scott Hickey added a comment -

        I don't recall having a problem with the .groovy files being copied into the bin directory. In the past, those have always been excluded. It happens the groovy nature gets added to a project. The Java builder gets configured to exclude *.groovy files.

        Show
        Scott Hickey added a comment - I don't recall having a problem with the .groovy files being copied into the bin directory. In the past, those have always been excluded. It happens the groovy nature gets added to a project. The Java builder gets configured to exclude *.groovy files.
        Hide
        Scott Hickey added a comment -

        The problem is in GroovyProject.java , the test for if( path.toOSString().equals( packageLocation ) ) fails when the project is imported from an external file location. The IPath is point to the logical location relative to the workspace and the packageLocation is referring to physical location of the file outside the workspace.

        Show
        Scott Hickey added a comment - The problem is in GroovyProject.java , the test for if( path.toOSString().equals( packageLocation ) ) fails when the project is imported from an external file location. The IPath is point to the logical location relative to the workspace and the packageLocation is referring to physical location of the file outside the workspace.
        Hide
        James E. Ervin added a comment -

        Zoinks!! Scott unless you have a solution on hand I will investigate fixing this.

        Show
        James E. Ervin added a comment - Zoinks!! Scott unless you have a solution on hand I will investigate fixing this.
        Hide
        Scott Hickey added a comment -

        I don't have a quick solution at hand - thanks.

        Show
        Scott Hickey added a comment - I don't have a quick solution at hand - thanks.
        Hide
        James E. Ervin added a comment -

        Try out this patch. I changed the code that acquires the source directories from the classpath to goto the project, get the IResource object that corresponds, check that that IResource object exists, and then query it for its raw location.

        I was able to reproduce the problem and this seems to have made it go away.

        Show
        James E. Ervin added a comment - Try out this patch. I changed the code that acquires the source directories from the classpath to goto the project, get the IResource object that corresponds, check that that IResource object exists, and then query it for its raw location. I was able to reproduce the problem and this seems to have made it go away.
        Hide
        Scott Hickey added a comment -

        James - thanks for the quick turn around. I also was able to duplicate the error and watch it go away.
        Thomas - I committed the patch to CVS. You pull down the latest plugin from CVS and try it out, thanks.

        Show
        Scott Hickey added a comment - James - thanks for the quick turn around. I also was able to duplicate the error and watch it go away. Thomas - I committed the patch to CVS. You pull down the latest plugin from CVS and try it out, thanks.
        Hide
        Scott Hickey added a comment -

        appears to be fixed with no further comment

        Show
        Scott Hickey added a comment - appears to be fixed with no further comment

          People

          • Assignee:
            Scott Hickey
            Reporter:
            Thomas Latka
          • Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development