views:

40

answers:

1

I have an application that I am working on modifying and I am having a problem and not sure where to look.

When I first started trying to compile the problem, some of the groovy files had imports that were not resolving correctly. After some tracking down, I see that the package was not defined the way the groovy files were expecting. So I change the package to match what the .groovy files were expecting, and when I run grails test run-app, it compiles, using groovyc, and gives no errors. The problem is, it seems to be infinitely recompiling my java source files. I am only guessing at this, because I only have 12 java files, and that is how many it says it is compiling. Here is the output

 Running script C:\Program Files\grails\grails-1.1.2\scripts\RunApp.groovy
 Environment set to test
[mkdir] Created dir: C:\Users\dcole\SKillsDB\trunk\web-app\plugins\help-balloons-1.1
 [copy] Copying 7 files to C:\Users\dcole\SKillsDB\trunk\web-app\plugins\help-balloons-1.1
 [copy] Copied 3 empty directories to 1 empty directory under C:\Users\dcole\.grails\1.1.2\projects\trunk\resources
[mkdir] Created dir: C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 72 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[mkdir] Created dir: C:\Users\dcole\.grails\1.1.2\projects\trunk\resources\grails-app\i18n
 [native2ascii] Converting 12 files from C:\Users\dcole\SKillsDB\trunk\grails-app\i18n to C:\Users\dcole\.grails\1.1.2\projects\trunk\resources\grails-app\i18n
 [copy] Copying 1 file to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
 [copy] Copying 1 file to C:\Users\dcole\.grails\1.1.2\projects\trunk\resources
 [copy] Copied 2 empty directories to 2 empty directories under C:\Users\dcole\.grails\1.1.2\projects\trunk\resources
 [copy] Copied 7 empty directories to 5 empty directories under C:\Users\dcole\.grails\1.1.2\projects\trunk\resources
 [copy] Copying 1 file to C:\Users\dcole\.grails\1.1.2\projects\trunk
Running Grails application..
Server running. Browse to http://localhost:8080/SkillsDB
[groovyc] Compiling 11 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
Running Grails application..
Server running. Browse to http://localhost:8080/SkillsDB
[groovyc] Compiling 11 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
Running Grails application..
Server running. Browse to http://localhost:8080/SkillsDB
[groovyc] Compiling 11 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
Running Grails application..
Server running. Browse to http://localhost:8080/SkillsDB
[groovyc] Compiling 11 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
Running Grails application..
Server running. Browse to http://localhost:8080/SkillsDB
[groovyc] Compiling 11 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
Running Grails application..
Server running. Browse to http://localhost:8080/SkillsDB
[groovyc] Compiling 11 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes
[groovyc] Compiling 12 source files to C:\Users\dcole\.grails\1.1.2\projects\trunk\classes

What should I start tracking down to solve this problem? It almost seems like a circular dependency? I am new to grails, so this is all new to me.

+2  A: 

This will happen when the class name doesn't match the file name, or the package doesn't match the folder structure. So you must still need some changes in package <-> folder structure. e.g. com.foo.bar.StringUtils must be in src/java/com/foo/bar/StringUtils.java or src/groovy/com/foo/bar/StringUtils.groovy

When it's less obvious which files are getting recompiled you can sort the classes in the compile dir by last edited or created date. The newest files will be first and will be the one(s) that are the culprits.

Burt Beckwith
for your StringUtils.java example, would the package be com.foo.bar? The reason I am asking, is because I checked, and sure enough, the .java files were under src/groovy instead of src/java. When I moved them on disk, eclipse wanted to refactor them with package name java.com.foo.bar instead of com.foo.bar and then in my Controller.groovy file the import java.com.foo.bar; statement gave me a compiler error for using a restricted package name
Derek
I changed the package manually for my java files to come.foo.bar and then in the controller I changed it to import com.foo.bar.StringUtil, and I got an error that groovyc was unable to resolve the class com.foo.bar.StringUtil
Derek
If your IDE is getting in the way, it might be better to do everything from the command line or a file manager. Also try running 'grails clean' (and also clean the Eclipse classes by using the Project|Clean menu item) to force a full recompile.
Burt Beckwith