Currently, groovyc loads AST transformations with the same class loader that is also responsible for loading compile dependencies. This can lead to problems for compiler clients that provide a custom class loader for loading compile dependencies, as such a class loader might not be able to meet the requirements for loading AST transformations. The most prominent example is GMaven, which uses a custom class loader to prevent classpath pollution without having to fork groovyc. Unfortunately this also means that GMaven cannot compile any programs that make use of AST transformations.
This patch allows for compiler clients to optionally provide a separate class loader for loading AST transformations, thereby decoupling the class loading of AST transformations from that of compile dependencies. This makes it possible for compiler clients such as GMaven (and possibly Gradle) to support AST transformations, and paves the way for further class loading improvements in future versions of groovyc.
The patch is fairly small and tries to keep changes to the existing codebase to an absolute minimum. Apart from applying moderate changes to two transform-related classes, it only adds a few lines of code to class CompilationUnit. Existing compiler clients will see no change in behavior. Please consider this patch for inclusion in Groovy 1.6, or a 1.6 maintenance release. Also attached is the corresponding GMaven patch. Any feedback is welcome.