In order to run jooqs codegen, it needs an appropriate database (with the correct schema) to be running. This often leads to checking in jooq generated code into your applications repository to ease the build process.
jooq provides an option to run the code generator based on flyway
migrations without the need for a specific database to be running. The feature is described here as codegen from DDL.
Internally jooqs codegen spawns a H2 in-memory database and applies the migrations against this database. After the schema is build, the codegen is run based in the freshly created database. The major drawback of this approach is, that vendor specific db extensions are not supported. For example Postgres json(b) will not work, because H2 cannot deal with it.
The following snippet is jooqs an extract of the relevant elements of jooqs plugin section of an applications pom.xml
.
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq-codegen-maven.version}</version>
<configuration>
<generator>
<database>
<name>org.jooq.meta.extensions.ddl.DDLDatabase</name>
<properties>
<property>
<key>scripts</key>
<value>src/main/resources/db/migration/*.sql</value>
</property>
<property>
<key>sort</key>
<value>semantic</value>
</property>
</properties>
</database>
</generator>
</configuration>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
</plugin>