Java / Groovy API for generating Groovy source files

I am looking for a Java or Groovy library to generate Groovy class source files. I have CodeModel and this post , but they are for Java.

Basically, I would like to create a Groovy class, programmatically knowing the class name, class attributes and generating specific methods depending on the class attributes.

I know Groovy templates, but there may be other ways.

thanks

+6
java code-generation groovy
source share
1 answer

Good question! I don’t know if there is something like CodeModel for Groovy, but one thing you can do is generate pure Java classes that you intend to call from Groovy. Since this is generated code in any case, it does not matter if it is a Java or Groovy class. You can use all functions, such as closure, using your original Java classes. For example, this site shows how you can write Groovy closure in pure Java .

+1
source share

All Articles