title: How to implement a Groovy global AST transformation in a Grails plugin?
body: <p><strong>I'd like to modify some of my Grails domain classes at compilation time.</strong> I initially thought this was a job for Groovy's global ASTTransformation since I don't want to annotate my domain classes (which local transformers require). What's the best way to do this?</p>
  
  <p>I also tried mimicking <strong>DefaultGrailsDomainClassInjector.java</strong> by creating my own class in the same package, implementing the same interfaces, but I probably just didn't know how to package it up in the right place because I never saw my methods get invoked.</p>
  
  <p>On the other hand I was able to manually create a JAR which contained a compiled AST transformation class, along with the META-INF/services artifacts that plain Groovy global transformations require. I threw that JAR into my project's "lib" dir and visit() was successfully invoked. Obviously this was a sloppy job because I am hoping to have the source code of my AST transformation in a Grails plugin and not require a separate JAR artifact if I don't have to, plus I couldn't get this approach to work by having the JAR in my Grails plugin's "lib" but had to put it into the Grails app's "lib" instead.</p>
  
  <p>This post helped a bit too: <a href="https://stackoverflow.com/questions/13829189/grails-2-1-1-how-to-develop-a-plugin-with-an-asttransformer">Grails 2.1.1 - How to develop a plugin with an AstTransformer?</a></p>