In my Java application I have a class Foo
class Foo {
String field1;
String field2;
}
I would like to have some generated code which uses reflection on the fields in this class (Imaginary template language)
#for each Field $f in Foo.class.getDeclaredFields()
#writeFile $f.java
public @interface $f {
}
The end goal is to have Field1.java and Field2.java with just a simple @interface definition inside each.
Is there a templating language available which could do this generation as part of a Maven build process?
The closest I have been able to find is JET, but this project seems more geared towards generating Java source to be available at runtime, not at compile time. In theory I could probably make this work using AntRun along with several Javac and Java tasks, but it would be cumbersome.
The actual use case which I need this for is generating BindingAnnotations for Google Guice (which will be used in GWT source, so they must exist as .java files at compile time).