Is there a way to add `@formatter:off` block to sources generated by JOOQ?

9 views
Skip to first unread message

egm...@gmail.com

unread,
Nov 7, 2017, 6:28:19 AM11/7/17
to jOOQ User Group

Hi,
We use JOOQ in my work place. Generated sources _are_ checked in, but need not be formatted.

One way to do this when using an IDE  is to use special markers (e.g. `@formatter:off`/`@formatter:on`)
Since JOOQ sources are generated, what is the best way to go about this?

I can always `sed` after the fact, but is it possible to do this as part of code generation?

Regards,
Manoj

Lukas Eder

unread,
Nov 7, 2017, 7:06:44 AM11/7/17
to jOOQ User Group
Thank for your enquiry and for illustrating your use-case

You could override the JavaGenerator.newJavaWriter() method and return a JavaWriter that is initialised with @formatter:off. Then override also JavaWriter.beforeClose() and generate @formatter:on in that method. This way, you can add these markers to all generated jOOQ classes.

Of course, post processing might be easier (e.g. when using Maven to generate code) and more forwards compatible, so I'd recommend that if possible.

I hope this helps,
Lukas
Reply all
Reply to author
Forward
0 new messages