Skip to content

Commit

Permalink
DOKY-190 Extract persistence logic to separate submodule (#129)
Browse files Browse the repository at this point in the history
Add submodule `persistence` to hold interaction with database. Make other submodules depend on it.

Important! Extracting persistence layer leads to align dependency version to be aligned and make dependency management more centralized.

Refactor dependencies and remove unused files

Reorganized dependency management with a `libs.versions.toml` file and streamlined Gradle configurations across modules. Removed obsolete files, including unused tests, entities, properties, and services, to clean up the codebase. This improves maintainability and aligns with best practices for modular development.

Centralized Flyway migration scripts into the `persistence` module. Adjusted Flyway configuration paths in application properties files and unified plugin application in the root Gradle file to streamline build configurations, removed unnecessary Gradle wrapper files.
  • Loading branch information
hanna-eismant authored Dec 12, 2024
1 parent 6a80c04 commit 1a89b82
Show file tree
Hide file tree
Showing 51 changed files with 281 additions and 1,283 deletions.
216 changes: 62 additions & 154 deletions app-server/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,188 +1,110 @@
import com.github.gradle.node.npm.task.NpmTask
import kotlinx.kover.gradle.plugin.dsl.AggregationType
import kotlinx.kover.gradle.plugin.dsl.MetricType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val springBootVersion = "3.1.2"
val springAzureVersion = "5.3.0"

val flywayVersion = "9.21.0"
val mysqlConnectorVersion = "8.3.0"
val sqlserverConnectorVersion = "12.6.1.jre11"

val kotlinLoggingVersion = "6.0.9"

val junitSuiteApi = "1.10.2"
val greenmailVersion = "2.0.1"
var awaitilityVersion = "4.2.1"

plugins {
java
id("jvm-test-suite")
id("org.jetbrains.kotlin.jvm") version "1.8.22"
id("org.jetbrains.kotlin.plugin.spring") version "1.8.22"
id("org.springframework.boot") version "3.1.2"
id("io.spring.dependency-management") version "1.1.2"
id("com.microsoft.azure.azurewebapp") version "1.7.1"
id("org.jetbrains.kotlinx.kover") version "0.7.6"
id("org.jetbrains.dokka") version "1.9.20"
id("com.github.gmazzo.buildconfig") version "5.3.5"
id("com.github.node-gradle.node") version "7.0.2"
}

dependencyManagement {
imports {
mavenBom("com.azure.spring:spring-cloud-azure-dependencies:$springAzureVersion")
mavenBom("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
mavenBom(libs.spring.boot.bom.get().toString())
mavenBom(libs.azure.spring.bom.get().toString())
}
}

java {
sourceCompatibility = JavaVersion.VERSION_17
}

val deployVersion = if (project.hasProperty("deployVersion")) {
project.property("deployVersion") as String
} else {
"Aardvark-v0.1"
}

buildConfig {
packageName("org.hkurh.doky")
documentation.set("Generated by BuildConfig plugin")
buildConfigField("DEPLOY_VERSION", provider { deployVersion })
}

tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "17"
}
}

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")

implementation("org.jetbrains.kotlin:kotlin-reflect")

implementation("jakarta.validation:jakarta.validation-api:3.0.2")

implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-configuration-processor")
implementation("org.springframework.boot:spring-boot-starter-actuator")

implementation("com.azure.spring:spring-cloud-azure-appconfiguration-config-web")
implementation("com.azure.spring:spring-cloud-azure-starter-keyvault")
implementation(project(":persistence"))

implementation("org.flywaydb:flyway-core:$flywayVersion")
implementation("org.flywaydb:flyway-sqlserver:$flywayVersion")
implementation("org.flywaydb:flyway-mysql:$flywayVersion")
implementation("com.microsoft.sqlserver:mssql-jdbc:$sqlserverConnectorVersion")
implementation("com.mysql:mysql-connector-j:$mysqlConnectorVersion")
implementation(libs.bundles.spring.starter.web)
implementation(libs.spring.boot.starter.data.jpa)
implementation(libs.spring.boot.starter.security)
implementation(libs.bundles.jwt)
implementation(libs.kotlin.reflect)
implementation(libs.bundles.validation)
implementation(libs.bundles.azure.keyvault)
implementation(libs.openapi.starter)
implementation(libs.bundles.json)
implementation(libs.commons.io)
implementation(libs.azure.blob)
implementation(libs.bundles.kafka)

developmentOnly(libs.spring.boot.devtools)

implementation("io.jsonwebtoken:jjwt-api:0.11.2")
implementation("io.jsonwebtoken:jjwt-impl:0.11.2")
implementation("io.jsonwebtoken:jjwt-jackson:0.11.2")
annotationProcessor(libs.spring.boot.config.processor)

implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0")
testImplementation(libs.bundles.testing.integration)
testImplementation(libs.bundles.testing.web)
testImplementation(libs.spring.kafka.test)

implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.13.1")
implementation("commons-io:commons-io:2.11.0")
implementation("io.github.oshai:kotlin-logging:$kotlinLoggingVersion")

implementation("com.azure:azure-storage-blob:12.25.3")

implementation("org.apache.kafka:kafka-clients")
implementation("org.springframework.kafka:spring-kafka")

implementation("net.logstash.logback:logstash-logback-encoder:7.4")

runtimeOnly("org.springframework.boot:spring-boot-devtools")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.apache.httpcomponents:httpclient:4.5.13")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
testImplementation("org.junit.platform:junit-platform-suite-api:$junitSuiteApi")
testImplementation("org.mockito:mockito-junit-jupiter:4.0.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0")

testImplementation("org.awaitility:awaitility:$awaitilityVersion")
testImplementation("org.springframework.kafka:spring-kafka-test")
testImplementation("io.rest-assured:rest-assured:5.3.0")
testRuntimeOnly(libs.junit.platform.launcher)
}

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}

testing {
suites {
val test by getting(JvmTestSuite::class) {
useJUnitJupiter()
dependencies {
implementation(project(":persistence"))
implementation(libs.spring.boot.starter.data.jpa.get().toString())
}
}
register<JvmTestSuite>("integrationTest") {
testType = TestSuiteType.INTEGRATION_TEST
dependencies {
implementation(project())
implementation(project(":persistence"))

implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-test")
implementation(libs.spring.boot.starter.test.get().toString())
implementation(libs.awaitility.get().toString())

implementation("org.springframework.boot:spring-boot-starter-security")
implementation("io.github.oshai:kotlin-logging:$kotlinLoggingVersion")
implementation(libs.httpclient.get().toString())
implementation(libs.rest.assured.get().toString())

implementation("org.junit.platform:junit-platform-suite-api:$junitSuiteApi")
implementation(libs.spring.kafka.test.get().toString())
implementation(libs.spring.kafka.production.get().toString())
implementation(libs.kafka.clients.get().toString())

implementation("com.icegreen:greenmail:$greenmailVersion")
implementation("org.awaitility:awaitility:$awaitilityVersion")
implementation(libs.greenmail.get().toString())

implementation("org.springframework.kafka:spring-kafka-test")
implementation("org.apache.kafka:kafka-clients")
implementation("org.springframework.kafka:spring-kafka")
implementation(libs.spring.boot.starter.jdbc.get().toString())
implementation(libs.spring.boot.starter.security.get().toString())

implementation(libs.kotlin.logging.get().toString())
}
}
register<JvmTestSuite>("apiTest") {
testType = TestSuiteType.FUNCTIONAL_TEST
dependencies {
implementation(project())
implementation(project(":persistence"))

implementation(libs.spring.boot.starter.test.get().toString())
implementation(libs.junit4.get().toString())

implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-test")
implementation(libs.httpclient.get().toString())
implementation(libs.rest.assured.get().toString())

implementation("org.springframework:spring-mock:2.0.8")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
implementation("org.junit.jupiter:junit-jupiter:5.8.2")
implementation("org.junit.platform:junit-platform-suite-api:$junitSuiteApi")
implementation("org.mockito:mockito-junit-jupiter:4.0.0")
implementation("org.mockito.kotlin:mockito-kotlin:5.0.0")
implementation("io.rest-assured:rest-assured:5.3.0")
implementation(libs.spring.kafka.test.get().toString())
implementation(libs.spring.kafka.production.get().toString())
implementation(libs.kafka.clients.get().toString())

implementation("org.springframework.kafka:spring-kafka-test")
implementation("org.apache.kafka:kafka-clients")
implementation("org.springframework.kafka:spring-kafka")
implementation(libs.spring.boot.starter.data.jpa.get().toString())
implementation(libs.spring.boot.starter.web.get().toString())
}
}
}
}

tasks.test {
useJUnitPlatform()
maxHeapSize = "1G"
testLogging {
showStandardStreams = true
events("PASSED", "SKIPPED", "FAILED")
Expand All @@ -203,30 +125,16 @@ tasks.named<Test>("integrationTest") {
}
}

kover {
excludeSourceSets {
names("integrationTest")
names("apiTest")
}
val deployVersion = if (project.hasProperty("deployVersion")) {
project.property("deployVersion") as String
} else {
"Aardvark-v0.1"
}

koverReport {
defaults {
filters {
includes {
classes("org.hkurh.*")
}
}
verify {
rule {
bound {
minValue = 33
metric = MetricType.LINE
aggregation = AggregationType.COVERED_PERCENTAGE
}
}
}
}
buildConfig {
packageName("org.hkurh.doky")
documentation.set("Generated by BuildConfig plugin")
buildConfigField("DEPLOY_VERSION", provider { deployVersion })
}

node {
Expand Down
Binary file removed app-server/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 0 additions & 7 deletions app-server/gradle/wrapper/gradle-wrapper.properties

This file was deleted.

Loading

0 comments on commit 1a89b82

Please sign in to comment.