import com.github.gradle.node.npm.task.NpmTask import org.gradle.jvm.tasks.Jar import org.gradle.language.jvm.tasks.ProcessResources import org.springframework.boot.buildpack.platform.build.PullPolicy import org.springframework.boot.gradle.tasks.bundling.BootBuildImage import org.springframework.boot.gradle.tasks.bundling.BootJar import org.springframework.boot.gradle.tasks.run.BootRun plugins { id("org.springframework.boot") version "4.1.1" id("io.spring.dependency-management") version "1.1.7" id("com.github.node-gradle.node") version "7.1.0" kotlin("jvm") version "2.4.21" kotlin("plugin.spring") version "2.4.21" application java } group = "com.redinterglobal" version = "1.3.4-SNAPSHOT" repositories { mavenCentral() maven { url = uri("https://git.redinterglobal.com/api/packages/scastro/maven") } } dependencies { implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springframework.boot:spring-boot-starter-webmvc") implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("org.springframework.boot:spring-boot-starter-jackson") implementation("org.springframework.boot:spring-boot-starter-cache") implementation("org.springframework.boot:spring-boot-starter-oauth2-client") implementation("org.springframework.boot:spring-boot-starter-data-redis") implementation("org.springframework.boot:spring-boot-mail") implementation("com.digitalsanctuary:ds-spring-cf-turnstile:2.1.0") implementation("com.github.ben-manes.caffeine:caffeine") implementation("io.github.oshai:kotlin-logging-jvm:8.0.4") implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity6") implementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:4.0.1") implementation("io.github.wimdeblauwe:htmx-spring-boot-thymeleaf:6.0.1") { exclude(group = "org.springframework.boot") } implementation("com.redinterglobal:thymepack:1.52-SNAPSHOT") implementation("com.redinterglobal:sdolib:1.6.6-SNAPSHOT") implementation(platform("org.zalando:logbook-bom:4.2.0")) implementation("org.zalando:logbook-spring-boot-starter") implementation("org.zalando:logbook-core") implementation("org.zalando:logbook-spring") implementation("org.zalando:logbook-json") implementation(kotlin("reflect")) implementation("tools.jackson.module:jackson-module-kotlin") developmentOnly("org.springframework.boot:spring-boot-devtools") testImplementation(kotlin("test")) testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.security:spring-security-test") testImplementation("org.springframework:spring-test") testImplementation("org.mockito:mockito-core") } kotlin { jvmToolchain(25) } tasks.named("test") { useJUnitPlatform() dependsOn(processPageResources) classpath += files(generatedResourcesDir) } node { download = true version = "24.21.0" } val npmRunBuild = tasks.register("npmRunBuild") { description = "Build webpack" args = listOf("run", "build") dependsOn("npmInstall") inputs.files(fileTree("node_modules")) inputs.files(fileTree("src/main/resources/js")) inputs.files(fileTree("src/main/resources/styles")) inputs.files(fileTree("src/main/resources/templates")) inputs.file("package.json") inputs.file("webpack.config.js") outputs.dir(layout.buildDirectory.dir("resources/main/static/dist")) } val generatedResourcesDir = layout.buildDirectory.dir("generated-resources/main") val processPageResources = tasks.register("processPageResources") { from("src/main/resources/templates") { into("templates") } from("src/main/resources/static") { into("static") } into(generatedResourcesDir) } tasks.named("processResources") { exclude("templates/**", "js/**", "styles/**", "static/**") } npmRunBuild.configure { mustRunAfter(tasks.named("processResources")) } tasks.named("bootJar") { dependsOn(npmRunBuild, processPageResources) from(generatedResourcesDir) { into("BOOT-INF/classes") } } tasks.named("jar") { dependsOn(npmRunBuild, processPageResources) from(generatedResourcesDir) } tasks.named("resolveMainClassName") { dependsOn(npmRunBuild) } tasks.named("bootRun") { dependsOn(npmRunBuild, processPageResources) classpath += files(generatedResourcesDir) } tasks.named("bootBuildImage") { imagePlatform = "linux/amd64" builder = "paketobuildpacks/builder-noble-java-tiny:0.0.199" pullPolicy = PullPolicy.ALWAYS environment.put("BP_JVM_VERSION", "25") val repo = "git.redinterglobal.com/scastro/${project.name}" imageName = "$repo:${project.version}" tags = listOf("$repo:latest") publish = true docker { publishRegistry { url = "https://git.redinterglobal.com" username = providers.gradleProperty("owner") password = providers.gradleProperty("access_token") } } }