Skip to content

Instantly share code, notes, and snippets.

@MavoCz
Created November 17, 2022 21:07
Show Gist options
  • Save MavoCz/b8ec3fe052d3ad7f44d4fa300bf3da2d to your computer and use it in GitHub Desktop.
Save MavoCz/b8ec3fe052d3ad7f44d4fa300bf3da2d to your computer and use it in GitHub Desktop.
Jooq code generation gradle task
jooq {
version.set("3.16.7")
edition.set(JooqEdition.OSS)
configurations {
create("main") {
jooqConfiguration.apply {
logging = Logging.WARN
jdbc.apply {
driver = "org.postgresql.Driver"
url = "jdbc:postgresql://localhost:5432/postgres"
user = "postgres"
password = ""
properties = listOf(
Property().apply {
key = "PAGE_SIZE"
value = "2048"
}
)
}
generator.apply {
name = "org.jooq.codegen.KotlinGenerator"
database.apply {
name = "org.jooq.meta.postgres.PostgresDatabase"
inputSchema = "public"
forcedTypes = listOf(
ForcedType().apply {
name = "varchar"
includeExpression = ".*"
includeTypes = "JSONB?"
},
ForcedType().apply {
isEnumConverter = true
userType = "net.voldrich.myhome.server.api.ItemState"
includeExpression = ".*item.state"
includeTypes = ".*"
}
)
}
generate.apply {
isDeprecated = false
isRecords = true
isImmutablePojos = false
isFluentSetters = true
//withPojos(true)
//withDaos(true)
//withSerializablePojos(false)
withSequences(true)
}
target.apply {
packageName = "net.voldrich.myhome.jooq"
directory = "src/generated/jooq"
}
strategy.name = "org.jooq.codegen.DefaultGeneratorStrategy"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment