Building Karyo
What a build of Karyo produces, which files hold which version, how vulnerable transitive dependencies are answered, and what makes a distributed jar state its own licence.
Derived from settings.gradle.kts, build.gradle.kts, buildSrc/, gradle/,
services/karyo-app/build.gradle.kts, config/, .github/workflows/ci.yml, .github/workflows/nightly.yml and .github/workflows/release.yml.
One deployable, fifty-one subprojects
settings.gradle.kts includes fifty-one Gradle subprojects - six shared libraries, the domain
-api and -core modules (the engine modules included), the demo-data engine and the extension
example - and exactly one of
them is a deployable: :services:karyo-app, the aggregator that assembles every core into one
Quarkus image. Every other module is a library that ends up on its
classpath (ADR 0001).
The whole product is built by one task:
./gradlew :services:karyo-app:quarkusBuild -Dquarkus.profile=prod
which is the command scripts/deploy-server.sh, Stage 2: Build backend runs, the command
.github/workflows/ci.yml, jobs.package.steps: Build karyo-app (Quarkus fast-jar) runs, and the command scripts/scan-image.sh, Gradle quarkusBuild command runs. It
produces a Quarkus fast-jar layout under services/karyo-app/build/quarkus-app/ -
quarkus-run.jar, lib/, app/ and quarkus/ - and that directory is what
infrastructure/docker/Dockerfile.service, COPY of the Quarkus fast-jar layout copies into the image.
Nothing publishes a jar. The module jars exist only as inputs to that layout, which is why a release is a source tree and the images built from it rather than Maven coordinates.
A JDK 21 is required, not a JRE: javac must be available. The build uses the checked-in
wrapper, so no separate Gradle installation is needed.
karyo-app's build file also carries the one build-time augmentation switch:
karyoInventoryExample, a Gradle property that adds the extension example module to the image
and is "off in ordinary images" (services/karyo-app/build.gradle.kts, providers.gradleProperty("karyoInventoryExample")). It is the mechanism
an augmented build uses; see extension SPIs and installation.
Building the one distribution
The ten engine capabilities, in nine modules, are part of this repository
(ADR 0029). settings.gradle.kts
includes their modules unconditionally, services/karyo-app/build.gradle.kts adds each one to the
application's dependencies, and their test suites live in the app's own test source set
(services/karyo-app/build.gradle.kts, dependencies (engine modules)). There is no overlay, no checkout and no second
build shape: the one command builds the complete product with all ten capabilities included.
The same build decides what the application image says about its own licence.
:services:karyo-app:imageLegalFiles, which quarkusBuild depends on, stages the licence files the
image carries - NOTICE, the Apache-2.0 LICENSE and the third-party inventory - and records the
licence expression (Apache-2.0) in services/karyo-app/build/image-licenses. The image's label is
a literal now; see container images.
Three version authorities, and only one of them is the product version
| Authority | Governs | Where |
|---|---|---|
allprojects.version |
the product release number | build.gradle.kts, allprojects.version |
gradle/libs.versions.toml |
dependency and plugin versions | the version catalog |
buildSrc/build.gradle.kts |
the Gradle plugin jars themselves | buildSrc/build.gradle.kts, dependencies |
The product version is one line in the root build file; how and when it moves is in releasing and ADR 0024.
The third authority is a problem. buildSrc/build.gradle.kts hardcodes the Quarkus and Kotlin
plugin versions under the comment "versions MUST match gradle/libs.versions.toml", and nothing
checks that they do (buildSrc/build.gradle.kts, dependencies, gradle/libs.versions.toml, versions.kotlin, versions.quarkus). Known
defect. Bump quarkus in the catalog alone and the platform BOM moves while the Gradle plugin
does not, so augmentation runs on one Quarkus version against a dependency set managed by another.
The Gradle wrapper pins the distribution URL and its bytes
(gradle/wrapper/gradle-wrapper.properties, distributionUrl, distributionSha256Sum):
validateDistributionUrl=true constrains the host, and the wrapper refuses a download whose
SHA-256 differs from distributionSha256Sum, so every build, including every build a deploy host
runs, executes only the distribution that was reviewed. Upgrading Gradle changes the two lines
together; Gradle publishes the checksum beside each distribution at <distributionUrl>.sha256.
tests/e2e/fixtures/release-hardening.test.ts fails if the checksum is removed.
Security floors, and why they are not plain constraints
build.gradle.kts answers vulnerability findings in transitive dependencies with version floors
rather than pins - a floor raises anything resolved below it and leaves anything at or above it
alone - so a later platform bump is never held back (build.gradle.kts, securityFloor).
Every module applies the Quarkus BOM with enforcedPlatform, whose forced versions beat a plain
dependency constraint outright and do so silently. So netty, Jackson, micrometer and the PostgreSQL
driver go through resolutionStrategy.eachDependency and a securityFloor helper that runs after
conflict resolution (build.gradle.kts, resolutionStrategy.eachDependency, securityFloor). A leaf transitive outside every BOM could still
take a plain constraints block; none is needed today. The one that existed, a floor on
opennlp-tools, left with the LangChain4j dependency that pulled it in.
Two exceptions inside the floors are worth knowing because they are the shape of mistake a
family-wide floor invites. netty-tcnative versions on its own 2.0.x line inside the io.netty
group, and jackson-annotations ships on a minor-only cadence, so a group-wide floor would demand
versions that have never been published and fail the whole configuration to resolve
(build.gradle.kts, resolutionStrategy.eachDependency, securityFloor). netty-tcnative is excluded from its family floor;
jackson-annotations receives a separate floor.
securityFloor compares the numeric runs in a version left to right and ignores qualifiers, so
4.1.121.Final < 4.1.136.Final while 4.2.13.Final is not below 4.1.136.Final
(build.gradle.kts, securityFloor, versionIsBelow). Its own KDoc bounds it: correct for every coordinate that uses it,
wrong for a pre-release line, and not to be reached for there.
Each entry names the CVEs it clears and how to retire it - delete it, run
./scripts/scan-image.sh, and drop it for good if the finding does not come back. That is the
best-documented part of the build and it is worth keeping that way.
Static analysis
Detekt is applied to every Kotlin module with a shared configuration
(build.gradle.kts), and existing findings are held in per-module
detekt-baseline.xml files so that they do not fail the build while new ones do. The nightly
quality job runs ./gradlew detekt and fails on a new finding (.github/workflows/nightly.yml, jobs.quality); a pull
request does not run it. The engine test
suites are ordinary src/test sources, so they are linted by the task and get the same exemptions
as any test source (config/detekt/detekt.yml, complexity, style).
Two things bound what that gate is worth. The pinned Detekt is an alpha prerelease
(gradle/libs.versions.toml, versions.detekt), and why a prerelease was chosen is not recorded. And the
whole-module detekt task the nightly run invokes performs no type resolution, so every rule marked
RequiresAnalysisApi is silently disabled on it: a measured 73 enabled against 154 disabled,
recorded in the configuration's own comment (config/detekt/detekt.yml, exceptions). Nothing in the
step's name or output says which rules did not run, and the baselines were captured against the
reduced set.
OWASP dependency-check is applied alongside it, failing at CVSS 7.0 and reading an optional
NVD_API_KEY (build.gradle.kts, DependencyCheckExtension). No CI job runs it; it is run by hand, and without an
API key the NVD service is heavily rate-limited.
The deterministic-test contract
build.gradle.kts, gradleTestContract reads config/test-runner-contracts.json at configuration time and
refuses to configure at all unless the Gradle contract rejects test filters and requires JUnit
Platform. Two later hooks enforce it: gradle.projectsEvaluated fails if a project with test
sources has no test task (build.gradle.kts, gradle.projectsEvaluated), and gradle.taskGraph.whenReady walks
every test task in the graph and fails on any of the ways to run fewer tests than the source set
contains - disabled, conditionally skipped, dry run, ignoring failures, include or exclude patterns
at either the task or the filter level, engine or tag filters, omitted sources, or a
testClassesDirs that does not equal the complete test source-set output
(build.gradle.kts, gradle.taskGraph.whenReady).
This is a delivery control, not a testing one. It exists so that a green pipeline cannot be produced by narrowing what the suite runs, which is the failure mode a release gate is most exposed to. What the suites themselves cover is in testing.
Licence notices, packaged and verified
Apache-2.0 section 4(d) requires the NOTICE to accompany a distribution. The root build packages
three files into every jar's META-INF (build.gradle.kts, Jar.metaInf):
NOTICE, from the repository root, identical for every module;LICENSE, per module: a module's ownLICENSEfile if it has one, otherwise the root Apache-2.0 text (build.gradle.kts,licenseFile). Every module in this repository takes the root text;THIRD-PARTY-NOTICES.md, renamed toTHIRD-PARTY-NOTICES, because the licence label deliberately does not enumerate the LGPL-2.1, EPL-2.0 and SIL-OFL-1.1 components a distribution contains (build.gradle.kts,thirdPartyFile, Jar.metaInf).
The copy alone guarantees nothing - Gradle's metaInf is silent about a missing source file, so
renaming NOTICE would empty every jar and fail no task. VerifyJarLegalFiles
(buildSrc/src/main/kotlin/com/karyo/conventions/VerifyJarLegalFiles.kt) reads the built jars
back and compares the packaged bytes against the files on disk, and its own KDoc states the bound
precisely: it is registered beside the copy over the same live Jar task collection, so it covers
exactly the jars the copy covers, and a module the convention never reaches is not covered
(VerifyJarLegalFiles). At the Karyo 2.0.0 release NOTICE states one Apache-2.0 grant
for the whole distribution (NOTICE), so every jar's NOTICE agrees with the licence packaged beside it.
The task is wired into check (build.gradle.kts, verifyJarLegalFiles, check), which is the conventional place, and no
workflow runs check: each names its Gradle tasks explicitly. The release workflow's build job
therefore runs the task by name, after it builds the jars and before it builds either image from
them (.github/workflows/release.yml, jobs.build.steps: Verify the jar legal files). A pull request does not run it; run it yourself after a change to
NOTICE, LICENSE or THIRD-PARTY-NOTICES.md. The next verification a contributor wires into
check the conventional way still will not run in any workflow until one names it.
THIRD-PARTY-NOTICES.md contains a human-readable overview and a version-specific package
inventory. The release workflow compares all three SBOMs with that inventory before building
images, on both tag pushes and dry runs. scripts/check-third-party-notices.py fails on a
missing package version, changed declared licence, empty licence, missing source URL or a
notice row that no SBOM uses. A dependency bump that merges without its notice row is therefore
caught here, at a release or a dry run, and not by a pull request or the nightly run. The script
checks nested bundled components and build dependencies too. The workflow retains
notices-check.txt with its release evidence. The comparison complements the byte verification;
it does not replace checking upstream licence terms.
SBOM
Every quarkusBuild emits a CycloneDX SBOM for the assembled application, because
quarkus-cyclonedx is part of the app's explicitly declared Quarkus extension union
(services/karyo-app/build.gradle.kts, libs.quarkus.cyclonedx). The file is named after the fast-jar's executable
and is written at the build root - services/karyo-app/build/quarkus-run-cyclonedx.json - with
the Quarkus default json format. It records the application as the main component and every
runtime and build-time dependency of the one distribution, each with its package URL, version,
hashes and a quarkus:component:scope of runtime or development; the application and the
runtime jars also carry an evidence location pointing into the fast-jar layout they ship in. It
currently carries no licence data with Gradle: the build reports that its dependency information
provider is unavailable. The notices therefore supply independently checked declarations from
Maven POMs, following parent POMs when needed, or the upstream project's licence statement.
Every such notice names an exact package version and its source URL. A dependency upgrade must
review that source again; the check never invents a licence from a package name. It reports
these version-reviewed declarations separately from licences it can compare directly.
The release workflow verifies the SBOM exists and lists components, checks that its main
component names the release version, and attaches it to the draft release
(.github/workflows/release.yml, jobs.build.steps: Generate and check the three SBOMs;
releasing). A pull request does not check it. The two front ends have no
Gradle build, so the release workflow generates their SBOMs from the checked-in lockfiles, without
installing node_modules, with the same commands anyone can run
(.github/workflows/release.yml, jobs.build.steps: Generate and check the three SBOMs):
(cd frontend/web && npx --yes @cyclonedx/[email protected] --package-lock-only --output-file /tmp/sbom-web.json)
(cd frontend/mobile && npx --yes @cyclonedx/[email protected] --package-lock-only --output-file /tmp/sbom-mobile.json)
After generating the three SBOMs, run the same comparison as the release workflow:
python3 scripts/check-third-party-notices.py \
services/karyo-app/build/quarkus-run-cyclonedx.json \
/tmp/sbom-web.json /tmp/sbom-mobile.json
When it reports a gap, check the upstream declaration for that exact version and update the
package inventory in THIRD-PARTY-NOTICES.md. npm SBOMs carry licence IDs or expressions from
the lockfiles; the inventory must agree exactly, including multiple declared choices. For a
component without licence metadata, record the verified declaration and an independent source
URL. Do not add wildcard versions or an unknown-licence placeholder. The check ignores only
Karyo's own Maven namespace and the five known Quarkus packaging outputs; they carry Karyo's
own licence. Unknown generated files still require a notice.
The check covers both runtime and build components. It establishes inventory coverage and agreement with available metadata, not a legal opinion or an independent rescan of upstream licences on every build. Scope and hashes remain in the SBOMs. The overview also records tools and documentation assets outside those three SBOMs (maintaining this repository).
Related
- Container images - what is built from the fast-jar
- The delivery pipeline - which of these checks CI runs
- Developer onboarding - building and running locally
- ADR 0002 - Kotlin on Quarkus
- ADR 0003 - Gradle, the Kotlin DSL and the version catalog