jpegasus jpegasus - 2 months ago 17
Java Question

Exclude a particular schema from code generation in JOOQ

I've currently trying to generate classes based on my existing Postgres DB using JOOQ. In my JOOQ .xml config I have left out any inputSchema tags so that JOOQ generates all the schemas it finds:

<schemata>
<schema>
</schema>
</schemata>


However, I would like to exclude the information schema from the content that gets generated. Is there a way to do this in black list way? Or do I have to add input schemas for all the schemas except information schema?

Answer

You can use the <excludes> configuration as documented here:

http://www.jooq.org/doc/latest/manual/code-generation/codegen-configuration

<includes>.*</includes>
<excludes>
  (?i:information_schema\..*) # I'm using (?i: ... ) for case-insensitivity here...
</excludes>

Both <includes> and <excludes> take Java regular expressions as arguments, which make matching unwanted schemas relatively easy.