Karyo
Documentation/ Decision records

ADR 0003: The build is Gradle with the Kotlin DSL, a version catalog and convention plugins

Karyo 2.1.1rendered at build time
On this page

Status: Accepted

Context

The build is 53 Gradle subprojects - six libraries, twenty-one -api modules, twenty-three -core modules (the engine modules and the flow model included), the demo module, an extension example and the application. All of it is Kotlin (ADR 0002) assembled by the Quarkus Gradle plugin. Versions have to agree across every module, every module needs the same compiler and test setup, and the build is the natural home for the checks that must never be skipped: legal files in every jar, security floors on transitive dependencies, static analysis and test integrity.

Decision

  • Gradle, always run through the checked-in wrapper (gradle/wrapper/gradle-wrapper.properties, distributionUrl), with every build script in the Kotlin DSL.
  • One root project, karyo-wms. settings.gradle.kts is the module graph; at the Karyo 2.0.0 release it includes every module unconditionally, the engine modules with the rest (ADR 0029).
  • Versions live in the version catalog, gradle/libs.versions.toml. buildSrc is a build of its own, so it imports the same catalog (buildSrc/settings.gradle.kts) and takes the versions of the Gradle plugins it applies from it (buildSrc/build.gradle.kts, dependencies).
  • Two precompiled convention plugins in buildSrc carry what every module shares: karyo.kotlin-conventions (Kotlin JVM, allopen, jpa, the Java 21 toolchain, compiler flags) and karyo.quarkus-service (the Quarkus plugin, JaCoCo, the JUnit Platform). A module's own build file lists only its dependencies.
  • The root build.gradle.kts holds what applies to the whole build: one version for everything (build.gradle.kts, allprojects.version); jar legal-file verification wired into check (build.gradle.kts, verifyJarLegalFiles, check); security floors for transitive dependencies (build.gradle.kts, securityFloor and the securityFloor calls that follow); Detekt (build.gradle.kts, DetektExtension); OWASP dependency-check (build.gradle.kts, DependencyCheckExtension); and a test-integrity gate that fails the build when a project with test sources has no deterministic test task, or when that task is disabled, skipped, a dry run or set to ignore failures (build.gradle.kts, gradle.projectsEvaluated, build.gradle.kts, gradle.taskGraph.whenReady).
  • Parallel execution and the build cache are on (gradle.properties, org.gradle.parallel, org.gradle.caching).
  • Optional modules are selected by properties, not by editing build files. The extension example is built as a module but enters the application only with -PkaryoInventoryExample=true (services/karyo-app/build.gradle.kts, providers.gradleProperty("karyoInventoryExample")).

Consequences

  • Build scripts are type-checked and completed by the IDE; a mistake fails at configuration time.
  • Versions and module conventions are written once and apply everywhere.
  • The gates that must hold - legal files in jars, security floors, test integrity - run inside ./gradlew check and ./gradlew test, not in a separate script someone can forget.
  • The Quarkus and Kotlin plugin versions are written once, in the catalog. buildSrc/settings.gradle.kts imports the catalog and buildSrc/build.gradle.kts reads the versions from it, so the two cannot drift.
  • The Quarkus BOM is an enforced platform, so a plain dependency constraint cannot raise a version it manages; those floors must go through securityFloor (build.gradle.kts, securityFloor).
  • The Kotlin DSL configures more slowly than the Groovy DSL, and Gradle upgrades can break plugins.
  • The static-analysis gate runs a prerelease of Detekt (gradle/libs.versions.toml, versions.detekt). Why a prerelease was chosen is not recorded.
  • The engine modules are ordinary subprojects, named in settings.gradle.kts and services/karyo-app/build.gradle.kts like every other module (ADR 0029).

Alternatives considered

  • Maven. Rejected: verbose XML, weaker incremental builds, parent-POM inheritance that is less flexible than convention plugins, and no type-checked build scripts.
  • Bazel. Rejected: a steep learning curve, little ready-made Kotlin and Quarkus support, and a setup cost out of proportion at this scale.
  • Gradle with the Groovy DSL. Not taken: the Kotlin DSL keeps build scripts in the same language as the application and type-checks them, at the cost of slower configuration.

Evidence

  • gradle/wrapper/gradle-wrapper.properties, distributionUrl - the pinned Gradle distribution
  • gradle/libs.versions.toml - the version catalog
  • buildSrc/src/main/kotlin/karyo.kotlin-conventions.gradle.kts, plugins, kotlin.jvmToolchain, allOpen, KotlinCompile.compilerOptions - the Kotlin convention plugin
  • buildSrc/src/main/kotlin/karyo.quarkus-service.gradle.kts, plugins, jacocoTestReport, tasks.withType<Test> - the Quarkus convention plugin
  • buildSrc/settings.gradle.kts - the catalog import
  • buildSrc/build.gradle.kts, dependencies - the plugin versions, read from the catalog
  • build.gradle.kts, allprojects.version, build.gradle.kts, verifyJarLegalFiles, check, build.gradle.kts, securityFloor, build.gradle.kts, DetektExtension, DependencyCheckExtension, build.gradle.kts, gradle.projectsEvaluated, gradle.taskGraph.whenReady - the build-wide version and gates
  • gradle.properties, org.gradle.parallel, org.gradle.caching - parallel execution and caching
  • Building
  • ADR 0002 - the language and framework the build compiles
  • ADR 0029 - one Apache-2.0 product
  • ADR 0023 - what happens to the build's output
  • ADR 0024 - how the one version moves