At present, there is a lot of weirdness with how bare code and embedded classes are handled in Groovy files. A recent example from Jim Menard on the user mailing list:
This code won't compile. Groovy attempts to generate SmallApp.class for the embedded class, and another SmallApp.class for the script itself. This is rather counter-intuitive.
I think the rules have to be more subtle. If there is only one class in the script, then that should be the only class generated. Bare code should go into static main() or, more intuitively (I think), into static initializers for the class. If there is more than one class in the script, the script gets its name, and the declared classes become inner classes.
I think static initializers are more intuitive for bare code than static main() because you can have many of them, so there is no conflict with user code (ie. other static initializers or an explicit static main()). My feeling is that we should check, and if there is no static main() declared, we supply an empty one so that Java doesn't complain.
I think these policies will most closely match expectations, while providing the fewest conflicts to be resolved.
– Chris Poirier