diff --git a/README.md b/README.md index 9ea9a99..3378f06 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ An opinionated gradle plugin to generate jOOQ Kotlin code from Flyway migrations. -The goal is to be as easy as possible to set up jOOQ generation for projects that are using Kotlin, Flyway, and Postgres. +The goal is to be as easy as possible to set up jOOQ generation for projects that are using Kotlin, Flyway, and +Postgres. The minimal setup for those project is: @@ -16,9 +17,9 @@ plugins { ## What does the plugin do? * Add `generateJooq` task: - * start a PostgreSQL docker container - * apply flyway migrations from `src/main/resources/db/migration` - * run jOOQ code generator with a configuration tailored for Kotlin Projects + * start a PostgreSQL docker container + * apply flyway migrations from `src/main/resources/db/migration` + * run jOOQ code generator with a configuration tailored for Kotlin Projects * Make the `compileKotlin` task depend on `generateJooq` * Add the generated jooq code to the main source set @@ -26,6 +27,37 @@ plugins { > > This plugin requires a `docker` installation +## Configuration + +In general, this gradle plugin aims to require as little configuration as possible. + +However, one may configure the jOOQ generation as follows: + +*build.gradle.kts* + +```kotlin +import com.optravis.jooq.gradle.ContainerConfig +import com.optravis.jooq.gradle.ExperimentalJooqGeneratorConfig +import com.optravis.jooq.gradle.JooqGeneratorConfig + +@OptIn(ExperimentalJooqGeneratorConfig::class) +jooqGenerator { + containerConfig.set(ContainerConfig.postgres(version = "16")) + generatorConfig.set( + JooqGeneratorConfig( + deprecateUnknownTypes = true, + kotlinPojos = true, + javaTimeTypes = true, + ) + ) +} +``` + +> [!WARNING] +> +> The configuration API is experimental (hence the requirement to `@OptIn`) +> +> Breaking changes to that API may be introduced in minor releases of the plugin! ## MIT License diff --git a/example/build.gradle.kts b/example/build.gradle.kts index 50bd851..5fd0d95 100644 --- a/example/build.gradle.kts +++ b/example/build.gradle.kts @@ -1,3 +1,7 @@ +import com.optravis.jooq.gradle.ContainerConfig +import com.optravis.jooq.gradle.ExperimentalJooqGeneratorConfig +import com.optravis.jooq.gradle.JooqGeneratorConfig + plugins { alias(libs.plugins.kotlin.jvm) id("com.optravis.jooq") @@ -10,6 +14,19 @@ repositories { mavenCentral() } +// ATTENTION: If you change the config bellow, please update the README.md! +@OptIn(ExperimentalJooqGeneratorConfig::class) +jooqGenerator { + containerConfig.set(ContainerConfig.postgres(version = "16")) + generatorConfig.set( + JooqGeneratorConfig( + deprecateUnknownTypes = true, + kotlinPojos = true, + javaTimeTypes = true, + ) + ) +} + dependencies { implementation(libs.flyway.core) runtimeOnly(libs.flyway.postgres)