import nu.studer.gradle.jooq.JooqEdition

plugins {
    id 'org.springframework.boot' version '2.7.18'
    id 'io.spring.dependency-management' version '1.0.15.RELEASE'
    id 'nu.studer.jooq' version '10.1.1'
    id 'java'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-jooq'
    runtimeOnly 'com.h2database:h2'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    jooqGenerator 'com.h2database:h2'
}

test {
    useJUnitPlatform()
}

jooq {
    // use jOOQ version defined by the Spring Boot Dependency Management plugin
    version = ""
    edition = JooqEdition.OSS

    configurations {
        main {
            generationTool {
                logging = org.jooq.meta.jaxb.Logging.WARN
                jdbc {
                    driver = 'org.h2.Driver'
                    url = 'jdbc:h2:~/test;AUTO_SERVER=TRUE'
                    user = 'sa'
                    password = ''
                    properties {
                        property {
                            key = 'PAGE_SIZE'
                            value = 2048
                        }
                    }
                }
                generator {
                    name = 'org.jooq.codegen.DefaultGenerator'
                    database {
                        name = 'org.jooq.meta.h2.H2Database'
                        includes = '.*'
                        excludes = ''
                    }
                    target {
                        packageName = 'nu.studer.sample'
                    }
                    strategy.name = "org.jooq.codegen.DefaultGeneratorStrategy"
                }
            }
        }
    }
}
