Hi guys,
I'm very stuck trying to create a custom generator. Have been investigating a lot regarding this and found this post on SO that is a similar problem to mine:
This post answer by Lukas, give a good idea of what I should do, however I'd need better details of implementation since I have no clue how to continue. I've created this SO question describing what I need in details
https://stackoverflow.com/questions/52171377/how-build-a-jooq-custom-generator. Basically, I have a postgres schema named "enums" where all the tables are like TYPES("name", "description"), and I have to create all groovy (or java) enums like below:
enum Types {
OPEN("open status"), CLOSE("close status");
private final String id;
Types(String id) { this.id = id; }
public String getValue() { return id; }
}
According the post answer I have to create a class extending from JavaGenerator, however I was even unable to trigger my custom generator from the maven plugin. So, by using `mvn -e jooq-codegen:generate` I found this error:
Caused by: java.lang.ClassNotFoundException: com.ctgengine.customer.jooq.EnumGenerator
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.jooq.codegen.GenerationTool.loadClass(GenerationTool.java:819)
In the maven plugin I have this snippet:
<generator>
<!--<name>org.jooq.codegen.JavaGenerator</name>-->
<name>com.ctgengine.customer.jooq.EnumGenerator</name>
...
And in my class I have:
class EnumGenerator extends JavaGenerator {
@Override
void generateTables(SchemaDefinition schema) {
....
Anyway, if I uncomment the JavaGenerator everything works fine.
So, I have two big gaps of knowledge where I need your help:
- Why my code isn't being picked by the maven plugin?
- Once I could link the plugin to my code, how can I do to generate groovy (or java) enums?
Thanks a lot in advance.