This project is a personal endeavor and is not affiliated with my employer.
I maintain it independently in my spare time, using my personal equipment.
Manually managing ephemeral databases, Flyway migrations, and jOOQ code generation slows down local development and CI
builds.
jOOQ Java Class Generator automates all of it — spin up containers, run migrations, and generate type-safe SQL
classes in a single Gradle task.
- Spins up temporary Testcontainers databases during the build
- Runs Flyway migrations using the Flyway API
- Triggers jOOQ code generation — all in one step
- Provides a dedicated Gradle DSL (
jooqCodegen) for configuration - Tasks are cacheable — Gradle marks them
UP-TO-DATEwhen inputs remain unchanged - Compatible with both Groovy and Kotlin DSLs
| Tool | Minimum version | Notes |
|---|---|---|
| Java | 21+ | Required by gradle-jooq-plugin 10.0 |
| jOOQ | 3.20.3+ | Matches gradle-jooq-plugin 10.1 |
| Gradle | 8.6+ | Same as gradle-jooq 10.0 |
| PostgreSQL | 17+ | As per jOOQ OSS support matrix |
Note for
spring-boot-starter-jooqusers - please, look which jOOQ dependency is used by this dependency and set the same version injooq { version = 'XXX' }
Groovy DSL
plugins {
id 'io.github.suppierk.jooq-java-class-generator' version '3.0.1'
}buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'io.github.suppierk:plugin:3.0.1'
}
}
apply plugin: 'io.github.suppierk.jooq-java-class-generator'See example-project for:
- Flyway migration for PostgreSQL
- Groovy DSL usage
Declare temporary databases and schemas under the jooqCodegen extension. Configure the schema in
at least one place (generator.database.inputSchema via jOOQ or flyway { defaultSchema = ... }
in the DSL) so the plugin knows which schema to migrate and introspect. Setting both keeps Flyway
and jOOQ in sync.
Groovy DSL
jooqCodegen {
database("analyticsDb") {
driver = "org.postgresql.Driver" // required
container {
image = "postgres:17-alpine" // optional override
}
schema("public") {
flyway {
locations = "classpath:db/migration/public"
defaultSchema = "public"
cleanDisabled = true
placeholder "foo", "bar"
}
jooqConfigurations = ['pgPublic']
}
schema("audit") {
flyway {
locations = "classpath:db/migration/audit"
defaultSchema = "audit"
}
jooqConfigurations = ['pgAudit']
}
}
}Kotlin DSL
jooqCodegen {
database("analyticsDb") {
driver = "org.postgresql.Driver"
container {
image().set("postgres:17-alpine")
}
schemas.create("public") {
flyway {
locations = listOf("classpath:db/migration/public")
defaultSchema = "public"
cleanDisabled = true
placeholders = mapOf("foo" to "bar")
}
jooqConfigurations = listOf("pgPublic")
}
schemas.create("audit") {
flyway {
locations = listOf("classpath:db/migration/audit")
defaultSchema = "audit"
}
jooqConfigurations = listOf("pgAudit")
}
}
}| Scope | Property | Description |
|---|---|---|
database |
driver (required) |
JDBC driver class used to determine the Testcontainers implementation |
database |
container.image |
Optional Docker image override (defaults: PostgreSQL postgres:17-alpine, MySQL mysql:8.4) |
schema |
flyway { ... } |
Full Flyway configuration for that schema; overrides built-in defaults provided by the plugin |
schema |
jooqConfigurations |
Names of pre-existing jOOQ configurations to execute against the temporary DB |
Each schema registers its own Gradle task, and an aggregate task coordinates them all.
| Task | Description |
|---|---|
generate<ConfigurationName>DatabaseClasses |
Runs Flyway and jOOQ for that schema |
generateDatabaseClasses |
Runs all schema tasks |
These tasks depend on processResources, run before compileJava, and are included in sourcesJar.
Tasks are annotated with @CacheableTask. Gradle considers them UP-TO-DATE when the following remain unchanged:
- Effective Flyway configuration (schemas, locations, placeholders, etc.)
- Selected Testcontainers image
- Normalized jOOQ configuration hash
- Resolved migration directories
Any DSL or migration change invalidates the cache. This makes the plugin CI-friendly and highly incremental.
The plugin:
- Applies
nu.studer.gradle-jooq - Reuses Flyway’s configuration model without applying the official Flyway Gradle plugin
For deeper tuning, see:
- Ensure your
jooqConfigurationsmatch the names declared underjooq.configurations. - You can inspect Flyway configurations with
--info. - To debug migrations or container startup, run Gradle with
--stacktrace --debug.
Licensed under MIT License.
Dependency licenses managed
via FOSSA.