From ff14647bd88bf394156ea93733f2a58308f89b7b Mon Sep 17 00:00:00 2001 From: brios <127139797+balazs-szucs@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:38:59 +0100 Subject: [PATCH] chore(build): migrate Gradle build scripts from Groovy to Kotlin DSL (#100) * chore(build): migrate Gradle build scripts from Groovy to Kotlin DSL * chore(docker): update Gradle build files to Kotlin DSL in Dockerfile --- Dockerfile | 2 +- booklore-api/build.gradle | 172 ------------------------------ booklore-api/build.gradle.kts | 177 +++++++++++++++++++++++++++++++ booklore-api/settings.gradle | 1 - booklore-api/settings.gradle.kts | 1 + 5 files changed, 179 insertions(+), 174 deletions(-) delete mode 100644 booklore-api/build.gradle create mode 100644 booklore-api/build.gradle.kts delete mode 100644 booklore-api/settings.gradle create mode 100644 booklore-api/settings.gradle.kts diff --git a/Dockerfile b/Dockerfile index 2850beb27..84ae8c3b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ FROM --platform=$BUILDPLATFORM gradle:9.3.1-jdk25-alpine AS backend-build WORKDIR /workspace/booklore-api -COPY booklore-api/gradlew booklore-api/gradlew.bat booklore-api/build.gradle booklore-api/settings.gradle ./ +COPY booklore-api/gradlew booklore-api/gradlew.bat booklore-api/build.gradle.kts booklore-api/settings.gradle.kts ./ COPY booklore-api/gradle ./gradle RUN chmod +x ./gradlew diff --git a/booklore-api/build.gradle b/booklore-api/build.gradle deleted file mode 100644 index 0ec6c6471..000000000 --- a/booklore-api/build.gradle +++ /dev/null @@ -1,172 +0,0 @@ -plugins { - id 'java' - id 'org.springframework.boot' version '4.0.3' - id 'io.spring.dependency-management' version '1.1.7' - id 'org.hibernate.orm' version '7.2.6.Final' - id 'com.github.ben-manes.versions' version '0.53.0' - id 'jacoco' -} - -group = 'org.booklore' -version = '0.0.1-SNAPSHOT' - -def defaultFrontendDistDir = file("${rootDir}/../booklore-ui/dist/grimmory/browser") -def configuredFrontendDistDir = providers.gradleProperty('frontendDistDir') - .map { file(it) } - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(25) - } -} - -repositories { - mavenCentral() - maven { url 'https://jitpack.io' } -} - -configurations { - compileOnly { - extendsFrom annotationProcessor - } -} - -dependencies { - // --- Spring Boot --- - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-websocket' - implementation 'org.springframework.boot:spring-boot-starter-actuator' - implementation 'org.springframework.boot:spring-boot-configuration-processor' - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-mail' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - - // --- Reactive Streams --- - implementation 'io.projectreactor:reactor-core' - - // --- Database & Migration --- - implementation 'org.mariadb.jdbc:mariadb-java-client:3.5.7' - implementation 'org.springframework.boot:spring-boot-starter-flyway' - implementation 'org.flywaydb:flyway-mysql:12.0.3' - - // --- Security & Authentication --- - implementation 'io.jsonwebtoken:jjwt-api:0.13.0' - runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.13.0' - runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.13.0' - - // --- Lombok (For Clean Code) --- - compileOnly 'org.projectlombok:lombok:1.18.42' - annotationProcessor 'org.projectlombok:lombok:1.18.42' - - // --- Book & Image Processing --- - implementation 'org.apache.pdfbox:pdfbox:3.0.6' - implementation 'org.apache.pdfbox:pdfbox-io:3.0.6' - implementation 'org.apache.pdfbox:xmpbox:3.0.6' - implementation 'org.apache.pdfbox:jbig2-imageio:3.0.4' - // Required for JPEG2000 support in PDFBox (not covered by TwelveMonkeys) - implementation 'com.github.jai-imageio:jai-imageio-core:1.4.0' - implementation 'com.github.jai-imageio:jai-imageio-jpeg2000:1.4.0' - - // --- TwelveMonkeys ImageIO --- - implementation 'com.twelvemonkeys.imageio:imageio-jpeg:3.13.1' - implementation 'com.twelvemonkeys.imageio:imageio-tiff:3.13.1' - implementation 'com.twelvemonkeys.imageio:imageio-webp:3.13.1' - implementation 'com.twelvemonkeys.imageio:imageio-bmp:3.13.1' - - implementation 'io.documentnode:epub4j-core:4.2.3' - - // --- Audio Metadata (Audiobook Support) --- - implementation 'com.github.RouHim:jaudiotagger:2.0.16' - - // --- UNRAR Support --- - implementation 'com.github.junrar:junrar:7.5.8' - - // --- JSON & Web Scraping --- - implementation 'org.jsoup:jsoup:1.22.1' - - // --- Mapping (DTOs & Entities) --- - implementation 'org.mapstruct:mapstruct:1.6.3' - annotationProcessor 'org.mapstruct:mapstruct-processor:1.6.3' - - // --- API Documentation --- - implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.2' - implementation 'org.apache.commons:commons-compress:1.28.0' - implementation 'org.tukaani:xz:1.12' // Required by commons-compress for 7z support - implementation 'org.apache.commons:commons-text:1.15.0' - - // --- XML Support (JAXB) --- - implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.5' - runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:4.0.6' - - // --- Template Engine --- - implementation 'org.freemarker:freemarker:2.3.34' - - // --- Jackson 3 --- - implementation platform('tools.jackson:jackson-bom:3.1.0') - implementation 'tools.jackson.core:jackson-core' - implementation 'tools.jackson.core:jackson-databind' - implementation 'tools.jackson.module:jackson-module-blackbird' - - // --- Jackson 2 (Compatibility) --- - // jackson-annotations version is managed by Jackson 3 BOM (requires 2.20+) - implementation 'com.fasterxml.jackson.core:jackson-annotations' - - // --- Caching --- - implementation 'org.springframework.boot:spring-boot-starter-cache' - implementation 'com.github.ben-manes.caffeine:caffeine:3.2.3' - - // --- Test Dependencies --- - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.springframework.boot:spring-boot-test-autoconfigure' - testImplementation 'org.assertj:assertj-core:3.27.7' - testImplementation "org.mockito:mockito-inline:5.2.0" - testRuntimeOnly 'com.h2database:h2' -} - -hibernate { - enhancement { - enableAssociationManagement = true - } -} - -test { - useJUnitPlatform() - jvmArgs("-XX:+EnableDynamicAgentLoading") - finalizedBy jacocoTestReport -} - -jacocoTestReport { - dependsOn test - reports { - xml.required = true - html.required = true - } -} - -tasks.named('processResources') { - def frontendResourcesDir = configuredFrontendDistDir - .orElse(providers.provider { defaultFrontendDistDir }) - .get() - - inputs.property('frontendDistDir', frontendResourcesDir.absolutePath) - inputs.property('hasFrontendResources', frontendResourcesDir.exists()) - - if (frontendResourcesDir.exists()) { - from(frontendResourcesDir) { - into 'static' - } - } -} - -bootRun { - def debug = System.getenv('REMOTE_DEBUG_ENABLED') - if (debug.equals("true")) { - jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005") - } -} - -bootJar { - mainClass = 'org.booklore.BookloreApplication' -} diff --git a/booklore-api/build.gradle.kts b/booklore-api/build.gradle.kts new file mode 100644 index 000000000..8eb1ddc45 --- /dev/null +++ b/booklore-api/build.gradle.kts @@ -0,0 +1,177 @@ +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.testing.Test +import org.gradle.testing.jacoco.tasks.JacocoReport +import org.springframework.boot.gradle.tasks.bundling.BootJar +import org.springframework.boot.gradle.tasks.run.BootRun + +plugins { + java + id("org.springframework.boot") version "4.0.3" + id("io.spring.dependency-management") version "1.1.7" + id("org.hibernate.orm") version "7.2.6.Final" + id("com.github.ben-manes.versions") version "0.53.0" + jacoco +} + +group = "org.booklore" +version = "0.0.1-SNAPSHOT" + +val defaultFrontendDistDir = file("${rootDir}/../booklore-ui/dist/grimmory/browser") +val configuredFrontendDistDir = providers.gradleProperty("frontendDistDir") + .map { file(it) } + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(25) + } +} + +repositories { + mavenCentral() + maven(url = "https://jitpack.io") +} + +configurations { + compileOnly { + extendsFrom(configurations.annotationProcessor.get()) + } +} + +dependencies { + // --- Spring Boot --- + implementation("org.springframework.boot:spring-boot-starter-data-jpa") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-validation") + implementation("org.springframework.boot:spring-boot-starter-websocket") + implementation("org.springframework.boot:spring-boot-starter-actuator") + implementation("org.springframework.boot:spring-boot-configuration-processor") + implementation("org.springframework.boot:spring-boot-starter-security") + implementation("org.springframework.boot:spring-boot-starter-mail") + implementation("org.springframework.boot:spring-boot-starter-oauth2-client") + + // --- Reactive Streams --- + implementation("io.projectreactor:reactor-core") + + // --- Database & Migration --- + implementation("org.mariadb.jdbc:mariadb-java-client:3.5.7") + implementation("org.springframework.boot:spring-boot-starter-flyway") + implementation("org.flywaydb:flyway-mysql:12.0.3") + + // --- Security & Authentication --- + implementation("io.jsonwebtoken:jjwt-api:0.13.0") + runtimeOnly("io.jsonwebtoken:jjwt-impl:0.13.0") + runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.13.0") + + // --- Lombok (For Clean Code) --- + compileOnly("org.projectlombok:lombok:1.18.42") + annotationProcessor("org.projectlombok:lombok:1.18.42") + + // --- Book & Image Processing --- + implementation("org.apache.pdfbox:pdfbox:3.0.6") + implementation("org.apache.pdfbox:pdfbox-io:3.0.6") + implementation("org.apache.pdfbox:xmpbox:3.0.6") + implementation("org.apache.pdfbox:jbig2-imageio:3.0.4") + // Required for JPEG2000 support in PDFBox (not covered by TwelveMonkeys) + implementation("com.github.jai-imageio:jai-imageio-core:1.4.0") + implementation("com.github.jai-imageio:jai-imageio-jpeg2000:1.4.0") + + // --- TwelveMonkeys ImageIO --- + implementation("com.twelvemonkeys.imageio:imageio-jpeg:3.13.1") + implementation("com.twelvemonkeys.imageio:imageio-tiff:3.13.1") + implementation("com.twelvemonkeys.imageio:imageio-webp:3.13.1") + implementation("com.twelvemonkeys.imageio:imageio-bmp:3.13.1") + + implementation("io.documentnode:epub4j-core:4.2.3") + + // --- Audio Metadata (Audiobook Support) --- + implementation("com.github.RouHim:jaudiotagger:2.0.16") + + // --- UNRAR Support --- + implementation("com.github.junrar:junrar:7.5.8") + + // --- JSON & Web Scraping --- + implementation("org.jsoup:jsoup:1.22.1") + + // --- Mapping (DTOs & Entities) --- + implementation("org.mapstruct:mapstruct:1.6.3") + annotationProcessor("org.mapstruct:mapstruct-processor:1.6.3") + + // --- API Documentation --- + implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:3.0.2") + implementation("org.apache.commons:commons-compress:1.28.0") + implementation("org.tukaani:xz:1.12") // Required by commons-compress for 7z support + implementation("org.apache.commons:commons-text:1.15.0") + + // --- XML Support (JAXB) --- + implementation("jakarta.xml.bind:jakarta.xml.bind-api:4.0.5") + runtimeOnly("org.glassfish.jaxb:jaxb-runtime:4.0.6") + + // --- Template Engine --- + implementation("org.freemarker:freemarker:2.3.34") + + // --- Jackson 3 --- + implementation(platform("tools.jackson:jackson-bom:3.1.0")) + implementation("tools.jackson.core:jackson-core") + implementation("tools.jackson.core:jackson-databind") + implementation("tools.jackson.module:jackson-module-blackbird") + + // --- Jackson 2 (Compatibility) --- + // jackson-annotations version is managed by Jackson 3 BOM (requires 2.20+) + implementation("com.fasterxml.jackson.core:jackson-annotations") + + // --- Caching --- + implementation("org.springframework.boot:spring-boot-starter-cache") + implementation("com.github.ben-manes.caffeine:caffeine:3.2.3") + + // --- Test Dependencies --- + testImplementation("org.springframework.boot:spring-boot-starter-test") + testImplementation("org.springframework.boot:spring-boot-test-autoconfigure") + testImplementation("org.assertj:assertj-core:3.27.7") + testImplementation("org.mockito:mockito-inline:5.2.0") + testRuntimeOnly("com.h2database:h2") +} + +hibernate { + enhancement { + enableAssociationManagement = true + } +} + +tasks.named("test") { + useJUnitPlatform() + jvmArgs("-XX:+EnableDynamicAgentLoading") + finalizedBy(tasks.named("jacocoTestReport")) +} + +tasks.named("jacocoTestReport") { + dependsOn(tasks.named("test")) + reports { + xml.required.set(true) + html.required.set(true) + } +} + +tasks.named("processResources") { + val frontendResourcesDir = configuredFrontendDistDir + .orElse(providers.provider { defaultFrontendDistDir }) + .get() + + inputs.property("frontendDistDir", frontendResourcesDir.absolutePath) + inputs.property("hasFrontendResources", frontendResourcesDir.exists()) + + if (frontendResourcesDir.exists()) { + from(frontendResourcesDir) { + into("static") + } + } +} + +tasks.named("bootRun") { + if (System.getenv("REMOTE_DEBUG_ENABLED") == "true") { + jvmArgs("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005") + } +} + +tasks.named("bootJar") { + mainClass.set("org.booklore.BookloreApplication") +} diff --git a/booklore-api/settings.gradle b/booklore-api/settings.gradle deleted file mode 100644 index 43eefe4b2..000000000 --- a/booklore-api/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'booklore-api' diff --git a/booklore-api/settings.gradle.kts b/booklore-api/settings.gradle.kts new file mode 100644 index 000000000..f3c91ca7b --- /dev/null +++ b/booklore-api/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "booklore-api"