diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7d5a275f0..42f0b2d42 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -71,18 +71,13 @@ NOTE: References to user stories are in the form Iteration/Story-Number. .Added -//// .Changed +- {url-issues}712[#712] Use Optravis jooq-plugin instead of jooqModelator .Deprecated .Removed - -.Fixed - -.Security - -//// +- {url-issues}712[#712] Remove usage of jooqModelator gradle plugin [[v2.0.2]] diff --git a/core/core-persistence-jooq/build.gradle.kts b/core/core-persistence-jooq/build.gradle.kts index c003c129b..2e0480d00 100644 --- a/core/core-persistence-jooq/build.gradle.kts +++ b/core/core-persistence-jooq/build.gradle.kts @@ -1,23 +1,51 @@ @file:Suppress("SpellCheckingInspection") -import ch.ayedo.jooqmodelator.gradle.JooqModelatorTask +import com.optravis.jooq.gradle.ContainerConfig +import com.optravis.jooq.gradle.DbConnectionConfig +import com.optravis.jooq.gradle.ExperimentalJooqGeneratorConfig +import com.optravis.jooq.gradle.GeneratorType +import com.optravis.jooq.gradle.JooqDatabaseConfig +import com.optravis.jooq.gradle.JooqGeneratorConfig @Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.jooqModelator) + alias(libs.plugins.jooqPlugin) id("scipamato-integration-test") } description = "SciPaMaTo-Core :: Persistence jOOQ Project" -val moduleName = "core/core-persistence-jooq" -val dbPackageName = "ch.difty.scipamato.core.db" -val dbPackagePath get() = dbPackageName.replace('.', '/') -val generatedSourcesPath = "build/generated-src/jooq" -val jooqConfigFile = layout.buildDirectory.get().asFile.resolve("jooqConfig.xml") -val dockerDbPort = 15432 val props = file("src/integration-test/resources/application.properties").asProperties() +@OptIn(ExperimentalJooqGeneratorConfig::class) +jooqGenerator { + val dbUserName = props.getProperty("spring.datasource.hikari.username") + val dbPassword = props.getProperty("spring.datasource.hikari.password") + containerConfig = ContainerConfig( + image = "postgres:15.4", + port = 5432, + environment = mapOf( + "POSTGRES_DB" to props.getProperty("db.name"), + "POSTGRES_USER" to dbUserName, + "POSTGRES_PASSWORD" to dbPassword, + ), + ) + jooqDbConfig = JooqDatabaseConfig.postgres(recordVersionFields = listOf("version")) + generatorConfig = JooqGeneratorConfig( + generatorType = GeneratorType.Java, + deprecateUnknownTypes = true, + javaTimeTypes = false, + daos = false, + pojos = false, + ) + connectionConfig = DbConnectionConfig( + user = dbUserName, + password = dbPassword, + urlTemplate = "jdbc:postgresql://localhost:{{port}}/${props.getProperty("db.name")}", + ) + packageName = "ch.difty.scipamato.core.db" +} + testing { suites { @Suppress("unused") @@ -31,34 +59,12 @@ testing { } } -jooqModelator { - jooqVersion = dependencyManagement.managedVersions["org.jooq:jooq"] - jooqEdition = "OSS" - - jooqConfigPath = jooqConfigFile.absolutePath - jooqOutputPath = "$generatedSourcesPath/$dbPackagePath" - - migrationEngine = "FLYWAY" - migrationsPaths = listOf("$rootDir/$moduleName/src/main/resources/db/migration/") - - dockerTag = "postgres:15.4" - - dockerEnv = listOf( - "POSTGRES_DB=${props.getProperty("db.name")}", - "POSTGRES_USER=${props.getProperty("spring.datasource.hikari.username")}", - "POSTGRES_PASSWORD=${props.getProperty("spring.datasource.hikari.password")}" - ) - dockerHostPort = dockerDbPort - dockerContainerPort = props.getProperty("db.port").toInt() -} - dependencies { api(project(Module.scipamatoCore("persistence-api"))) api(project(Module.scipamatoCommon("persistence-jooq"))) implementation(project(Module.scipamatoCore("entity"))) implementation(project(Module.scipamatoCommon("utils"))) - jooqModelatorRuntime(libs.postgresql) runtimeOnly(libs.postgresql) api(libs.jooq) @@ -72,67 +78,6 @@ dependencies { testAnnotationProcessor(libs.lombok) } -sourceSets { - main { - java { - srcDir(setOf(generatedSourcesPath, "src/main/java")) - } - } -} - -tasks { - val jooqGroup = "jOOQ" - val jooqMetamodelTaskName = "generateJooqMetamodel" - val generateJooqConfig by creating { - group = jooqGroup - description = "Generates the jooqConfig.xml file to be consumed by the $jooqMetamodelTaskName task." - val resourcesDir = sourceSets.main.get().output.resourcesDir - resourcesDir?.mkdirs() - val fileContent = - """ - - - - org.postgresql.Driver - jdbc:postgresql://localhost:$dockerDbPort/${props.getProperty("db.name")}?loggerLevel=OFF - ${props.getProperty("spring.datasource.hikari.username")} - ${props.getProperty("spring.datasource.hikari.password")} - - - org.jooq.codegen.DefaultGenerator - - org.jooq.meta.postgres.PostgresDatabase - ${props.getProperty("db.schema")} - version - - - false - true - false - false - true - - - $dbPackageName - $moduleName/$generatedSourcesPath - - - $rootDir - - """.trimIndent() - doLast { - jooqConfigFile.writeText(fileContent) - } - } - withType { - group = jooqGroup - // prevent parallel run of this task between core and public - outputs.dir(rootProject.layout.buildDirectory.get().asFile.resolve(jooqMetamodelTaskName)) - dependsOn(generateJooqConfig) - } - getByName("compileKotlin").dependsOn += jooqMetamodelTaskName -} - idea { module { inheritOutputDirs = true diff --git a/core/core-sync/build.gradle.kts b/core/core-sync/build.gradle.kts index ef401073b..7099bc082 100644 --- a/core/core-sync/build.gradle.kts +++ b/core/core-sync/build.gradle.kts @@ -41,13 +41,13 @@ tasks { val copyCoreFiles by registering(Copy::class) { from("$rootDir/core/core-persistence-jooq/build/generated-src/jooq/ch/difty/scipamato/core") destinationDir = File("$rootDir/core/core-sync/build/generated-src/jooq/ch/difty/scipamato/core") - dependsOn(":core-persistence-jooq:generateJooqMetamodel") + dependsOn(":core-persistence-jooq:generateJooq") } val copyPublicFiles by registering(Copy::class) { from("$rootDir/public/public-persistence-jooq/build/generated-src/jooq/ch/difty/scipamato/publ") destinationDir = File("$rootDir/core/core-sync/build/generated-src/jooq/ch/difty/scipamato/publ") - dependsOn(":public-persistence-jooq:generateJooqMetamodel") + dependsOn(":public-persistence-jooq:generateJooq") } getByName("compileKotlin").dependsOn += copyCoreFiles diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 90b3ecd14..b8eae9dbc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ jasperreports = "6.21.3" java = "21" jakartaElApi = "6.0.0" jaxbPlugin = "7.0.0" -jooqModelatorPlugin = "3.9.0" +jooqPlugin = "1.2.1" jsr305 = "3.0.2" junitJupiter = "5.10.2" kluent = "1.73" @@ -123,7 +123,7 @@ dbTest = ["testcontainers-testcontainers", "testcontainers-junitJupiter", "testc [plugins] detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detektPlugin" } jaxb = { id = "com.intershop.gradle.jaxb", version.ref = "jaxbPlugin" } -jooqModelator = { id = "ch.ayedo.jooqmodelator", version.ref = "jooqModelatorPlugin" } +jooqPlugin = { id = "com.optravis.jooq", version.ref = "jooqPlugin" } licenseReport = { id = "com.github.hierynomus.license-report", version.ref = "licensePlugin" } lombok = { id = "io.freefair.lombok", version.ref = "lombokPlugin" } sonarqube = { id = "org.sonarqube", version.ref = "sonarqubePlugin" } diff --git a/public/public-persistence-jooq/build.gradle.kts b/public/public-persistence-jooq/build.gradle.kts index 43d74b254..79b16e3dc 100644 --- a/public/public-persistence-jooq/build.gradle.kts +++ b/public/public-persistence-jooq/build.gradle.kts @@ -1,21 +1,19 @@ @file:Suppress("SpellCheckingInspection") -import ch.ayedo.jooqmodelator.gradle.JooqModelatorTask +import com.optravis.jooq.gradle.ContainerConfig +import com.optravis.jooq.gradle.DbConnectionConfig +import com.optravis.jooq.gradle.ExperimentalJooqGeneratorConfig +import com.optravis.jooq.gradle.GeneratorType +import com.optravis.jooq.gradle.JooqDatabaseConfig +import com.optravis.jooq.gradle.JooqGeneratorConfig @Suppress("DSL_SCOPE_VIOLATION") plugins { - alias(libs.plugins.jooqModelator) + alias(libs.plugins.jooqPlugin) id("scipamato-integration-test") } - description = "SciPaMaTo-Public:: Persistence jOOQ Project" -val moduleName = "public/public-persistence-jooq" -val dbPackageName = "ch.difty.scipamato.publ.db" -val dbPackagePath get() = dbPackageName.replace('.', '/') -val generatedSourcesPath = "build/generated-src/jooq" -val jooqConfigFile = layout.buildDirectory.get().asFile.resolve("jooqConfig.xml") -val dockerDbPort = 15432 val props = file("src/integration-test/resources/application.properties").asProperties() testing { @@ -30,25 +28,34 @@ testing { } } -jooqModelator { - jooqVersion = dependencyManagement.managedVersions["org.jooq:jooq"] - jooqEdition = "OSS" - - jooqConfigPath = jooqConfigFile.absolutePath - jooqOutputPath = "$generatedSourcesPath/$dbPackagePath" - - migrationEngine = "FLYWAY" - migrationsPaths = listOf("$rootDir/$moduleName/src/main/resources/db/migration/") - - dockerTag = "postgres:15.4" - - dockerEnv = listOf( - "POSTGRES_DB=${props.getProperty("db.name")}", - "POSTGRES_USER=${props.getProperty("spring.datasource.hikari.username")}", - "POSTGRES_PASSWORD=${props.getProperty("spring.datasource.hikari.password")}" +@OptIn(ExperimentalJooqGeneratorConfig::class) +jooqGenerator { + val dbUserName = props.getProperty("spring.datasource.hikari.username") + val dbPassword = props.getProperty("spring.datasource.hikari.password") + containerConfig = ContainerConfig( + image = "postgres:15.4", + port = 5432, + environment = mapOf( + "POSTGRES_DB" to props.getProperty("db.name"), + "POSTGRES_USER" to dbUserName, + "POSTGRES_PASSWORD" to dbPassword, + ), ) - dockerHostPort = dockerDbPort - dockerContainerPort = props.getProperty("db.port").toInt() + jooqDbConfig = JooqDatabaseConfig.postgres(recordVersionFields = listOf("version")) + generatorConfig = JooqGeneratorConfig( + generatorType = GeneratorType.Java, + deprecateUnknownTypes = true, + javaTimeTypes = false, + daos = false, + // pojos are required for core/core-sync only + pojos = true, + ) + connectionConfig = DbConnectionConfig( + user = dbUserName, + password = dbPassword, + urlTemplate = "jdbc:postgresql://localhost:{{port}}/${props.getProperty("db.name")}", + ) + packageName = "ch.difty.scipamato.publ.db" } dependencies { @@ -57,7 +64,6 @@ dependencies { implementation(project(Module.scipamatoPublic("entity"))) implementation(project(Module.scipamatoCommon("utils"))) - jooqModelatorRuntime(libs.postgresql) runtimeOnly(libs.postgresql) api(libs.jooq) @@ -65,68 +71,6 @@ dependencies { testImplementation(project(Module.scipamatoCommon("test"))) } -sourceSets { - main { - java { - setSrcDirs(setOf(generatedSourcesPath, "src/main/kotlin")) - } - } -} - -tasks { - val jooqGroup = "jOOQ" - val jooqMetamodelTaskName = "generateJooqMetamodel" - val generateJooqConfig by creating { - group = jooqGroup - description = "Generates the jooqConfig.xml file to be consumed by the $jooqMetamodelTaskName task." - val resourcesDir = sourceSets.main.get().output.resourcesDir - resourcesDir?.mkdirs() - val fileContent = - """ - - - - org.postgresql.Driver - jdbc:postgresql://localhost:$dockerDbPort/${props.getProperty("db.name")}?loggerLevel=OFF - ${props.getProperty("spring.datasource.hikari.username")} - ${props.getProperty("spring.datasource.hikari.password")} - - - org.jooq.codegen.DefaultGenerator - - org.jooq.meta.postgres.PostgresDatabase - public - version - - - false - true - true - true - false - - - $dbPackageName - $moduleName/$generatedSourcesPath - - - $rootDir - - """.trimIndent() - doLast { - jooqConfigFile.writeText(fileContent) - } - } - - withType { - group = jooqGroup - // prevent parallel run of this task between core and public - outputs.dir(rootProject.layout.buildDirectory.get().asFile.resolve(jooqMetamodelTaskName)) - dependsOn(generateJooqConfig) - } - getByName("compileKotlin").dependsOn += jooqMetamodelTaskName -} - idea { module { inheritOutputDirs = true