Skip to content

Commit

Permalink
Merge branch 'main' into renovate/spring-boot
Browse files Browse the repository at this point in the history
  • Loading branch information
ursjoss authored Jun 20, 2024
2 parents 896539a + 2cc62c0 commit ad7c9e5
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 193 deletions.
9 changes: 2 additions & 7 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
127 changes: 36 additions & 91 deletions core/core-persistence-jooq/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)

Expand All @@ -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 =
"""
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<jdbc>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:$dockerDbPort/${props.getProperty("db.name")}?loggerLevel=OFF</url>
<user>${props.getProperty("spring.datasource.hikari.username")}</user>
<password>${props.getProperty("spring.datasource.hikari.password")}</password>
</jdbc>
<generator>
<name>org.jooq.codegen.DefaultGenerator</name>
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<inputSchema>${props.getProperty("db.schema")}</inputSchema>
<recordVersionFields>version</recordVersionFields>
</database>
<generate>
<deprecated>false</deprecated>
<instanceFields>true</instanceFields>
<pojos>false</pojos>
<javaTimeTypes>false</javaTimeTypes>
<springAnnotations>true</springAnnotations>
</generate>
<target>
<packageName>$dbPackageName</packageName>
<directory>$moduleName/$generatedSourcesPath</directory>
</target>
</generator>
<basedir>$rootDir</basedir>
</configuration>
""".trimIndent()
doLast {
jooqConfigFile.writeText(fileContent)
}
}
withType<JooqModelatorTask> {
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
Expand Down
4 changes: 2 additions & 2 deletions core/core-sync/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,7 +34,7 @@ wicket = "10.1.0"
wicketBootstrap = "7.0.5"
wicketJqueryUi = "10.0.0-M1"
wicketSpringBootStarter = "4.0.0"
wicketstuff = "10.1.0"
wicketstuff = "10.1.1"

[libraries]
cacheApi = { module = "javax.cache:cache-api" }
Expand Down Expand Up @@ -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" }
Expand Down
124 changes: 34 additions & 90 deletions public/public-persistence-jooq/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand All @@ -57,76 +64,13 @@ dependencies {
implementation(project(Module.scipamatoPublic("entity")))
implementation(project(Module.scipamatoCommon("utils")))

jooqModelatorRuntime(libs.postgresql)
runtimeOnly(libs.postgresql)
api(libs.jooq)

testImplementation(project(Module.scipamatoCommon("persistence-jooq-test")))
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 =
"""
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<jdbc>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:$dockerDbPort/${props.getProperty("db.name")}?loggerLevel=OFF</url>
<user>${props.getProperty("spring.datasource.hikari.username")}</user>
<password>${props.getProperty("spring.datasource.hikari.password")}</password>
</jdbc>
<generator>
<name>org.jooq.codegen.DefaultGenerator</name>
<database>
<name>org.jooq.meta.postgres.PostgresDatabase</name>
<inputSchema>public</inputSchema>
<recordVersionFields>version</recordVersionFields>
</database>
<generate>
<deprecated>false</deprecated>
<instanceFields>true</instanceFields>
<pojos>true</pojos><!-- pojos required for sync only -->
<springAnnotations>true</springAnnotations>
<javaTimeTypes>false</javaTimeTypes>
</generate>
<target>
<packageName>$dbPackageName</packageName>
<directory>$moduleName/$generatedSourcesPath</directory>
</target>
</generator>
<basedir>$rootDir</basedir>
</configuration>
""".trimIndent()
doLast {
jooqConfigFile.writeText(fileContent)
}
}

withType<JooqModelatorTask> {
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
Expand Down

0 comments on commit ad7c9e5

Please sign in to comment.