Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vertx Gradle Kotlin DSL #176

Open
zhengchalei opened this issue Jan 14, 2021 · 5 comments
Open

Vertx Gradle Kotlin DSL #176

zhengchalei opened this issue Jan 14, 2021 · 5 comments

Comments

@zhengchalei
Copy link

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

@jklingsporn
Copy link
Owner

Unfortunately, vertx-jooq does not yet support kotlin generated classes.

@cdekok
Copy link
Contributor

cdekok commented Jan 31, 2021

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)
    }
}

@Dudeplayz
Copy link

@jklingsporn I think he only means to use the Kotlin DSL for the Gradle task in the readme. So not the actual Kotlin support.

@cdekok
Copy link
Contributor

cdekok commented Mar 31, 2021

@zhangruiyu what error do you get? it should work, you do need to replace some of the parameters for your own project.

@zhangruiyu
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants