Open zhengchalei opened 3 years ago
Unfortunately, vertx-jooq does not yet support kotlin generated classes.
You can use something like.
import org.jooq.codegen.GenerationTool
import org.jooq.meta.jaxb.*
import org.jooq.meta.jaxb.Target as JooqTarget
import io.github.jklingsporn.vertx.jooq.shared.postgres.JSONBToJsonObjectConverter
import io.vertx.core.json.JsonObject;
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath("io.github.jklingsporn:vertx-jooq-generate:6.0.0")
classpath("org.postgresql:postgresql:42.2.16")
classpath("io.vertx:vertx-core:4.0.0")
}
}
val jooqGenerateTask = task("jooqGenerate") {
doLast {
val config = Configuration()
.withJdbc(
Jdbc()
.withDriver("org.postgresql.Driver")
.withUrl("jdbc:postgresql://localhost:5432/db")
.withUser("username")
.withPassword("password")
)
.withGenerator(
Generator()
.withName("io.github.jklingsporn.vertx.jooq.generate.classic.ClassicReactiveVertxGenerator")
.withDatabase(
Database()
.withName("org.jooq.meta.postgres.PostgresDatabase")
.withIncludes(".*")
.withExcludes("schema_version")
.withInputSchema("public")
.withIncludeTables(true)
.withIncludeRoutines(false)
.withIncludePackages(false)
.withIncludeUDTs(false)
.withIncludeSequences(false)
.withForcedTypes(
ForcedType()
.withUserType(JsonObject::class.java.name)
.withConverter(JSONBToJsonObjectConverter::class.java.name)
.withIncludeTypes("jsonb")
)
)
.withGenerate(
Generate()
.withDeprecated(false)
.withRecords(true)
.withInterfaces(false)
.withFluentSetters(true)
.withPojos(false)
.withDaos(true)
)
.withTarget(
JooqTarget()
.withPackageName("my.package")
.withDirectory("$projectDir/src")
)
.withStrategy(
Strategy()
.withName("io.github.jklingsporn.vertx.jooq.generate.VertxGeneratorStrategy")
)
)
GenerationTool.generate(config)
}
}
@jklingsporn I think he only means to use the Kotlin DSL for the Gradle task in the readme. So not the actual Kotlin support.
@zhangruiyu what error do you get? it should work, you do need to replace some of the parameters for your own project.
@zhangruiyu what error do you get? it should work, you do need to replace some of the parameters for your own project.
Sorry, restart idea is ready
In Vertx4.0 , Use Gradle Kotlin DSL replaced Groovy,
Can you update this to add a Gradle Kotlin DSL instance to generate the script?
Please, My Language is not English, If the meaning is not correct, please bear with me