Skip to content

Commit

Permalink
docs(readme): Document how to configure the plugin (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz authored Jun 19, 2024
1 parent 964dffb commit def1ad5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -16,16 +17,47 @@ 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

> [!NOTE]
>
> 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

Expand Down
17 changes: 17 additions & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit def1ad5

Please # to comment.