build.gradle.kts 2.89 KB
// distribution — assembles the runnable vibe_erp fat-jar.
//
// This module is the only one that pulls every PBC and platform module
// together into a bootable Spring Boot application. It is referenced by
// the Dockerfile (stage 1) which produces the shipping image documented
// in the architecture spec, sections 10 and 11.

plugins {
    alias(libs.plugins.kotlin.jvm)
    alias(libs.plugins.kotlin.spring)
    alias(libs.plugins.spring.boot)
    alias(libs.plugins.spring.dependency.management)
}

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(21))
    }
}

dependencies {
    implementation(project(":platform:platform-bootstrap"))
    implementation(project(":platform:platform-persistence"))
    implementation(project(":platform:platform-plugins"))
    implementation(project(":platform:platform-security"))
    implementation(project(":platform:platform-events"))
    implementation(project(":platform:platform-metadata"))
    implementation(project(":pbc:pbc-identity"))
    implementation(project(":pbc:pbc-catalog"))

    implementation(libs.spring.boot.starter)
    implementation(libs.spring.boot.starter.web)
    implementation(libs.spring.boot.starter.data.jpa)
    implementation(libs.spring.boot.starter.actuator)
    implementation(libs.kotlin.stdlib)
    implementation(libs.kotlin.reflect)
    implementation(libs.jackson.module.kotlin)
    runtimeOnly(libs.postgres)
    runtimeOnly(libs.liquibase.core)

    testImplementation(libs.spring.boot.starter.test)
}

// Configure Spring Boot's main class once, on the `springBoot` extension.
// This is the only place that drives BOTH bootJar and bootRun — setting
// mainClass on `tasks.bootJar` alone leaves `bootRun` unable to resolve
// the entry point because :distribution has no Kotlin sources of its own.
springBoot {
    mainClass.set("org.vibeerp.platform.bootstrap.VibeErpApplicationKt")
}

// The fat-jar produced here is what the Dockerfile copies into the
// runtime image as /app/vibe-erp.jar.
tasks.bootJar {
    archiveFileName.set("vibe-erp.jar")
}

// `./gradlew :distribution:bootRun` — used by `make run` for local dev.
// Activates the dev profile so application-dev.yaml on the classpath is
// layered on top of application.yaml. Also depends on the reference
// plug-in's `installToDev` task so the JAR is staged in `plugins-dev/`
// before the app boots — that's where application-dev.yaml's
// `vibeerp.plugins.directory: ./plugins-dev` setting points.
tasks.bootRun {
    systemProperty("spring.profiles.active", "dev")
    // Run with the repo root as the working directory so the relative
    // paths in application-dev.yaml (./plugins-dev, ./files-dev) resolve
    // to the right place — the plug-in JAR is staged at
    // <repo>/plugins-dev/, not <repo>/distribution/plugins-dev/.
    workingDir = rootProject.layout.projectDirectory.asFile
    dependsOn(":reference-customer:plugin-printing-shop:installToDev")
}