When I build a war file for my Grails application via grails war
it still contains some groovy files.
After the war-filed is deployed on an application server, when and how are this files compiled to java bytecode?
The templates are there for dynamic scaffolding. For example if you have a controller like this
class PersonController {
static scaffold = Person
}
then it'll use the template to create a controller at runtime. This isn't very often used in real apps - it's more for demos and getting started - but it's an option. The dynamically generated controller and GSPs are created based on the templates and compiled in-memory.
The groovy-all jar does have code that can compile Groovy source, but that's because it's the "-all" jar. Just because it's there doesn't mean it's necessarily used. In general all compilation is done when building the war, including precompiling GSPs. This is for performance - you want the app to be as fast as possible in production.