The Klok gradle plugin (dev.klok.integration, artifact dev.klok.framework:klok-gradle-plugin) is what makes a Klok
project build the same way everywhere: an integration, a datamodel, an application or the framework itself applies the
plugin, sets a handful of klok { } properties, and gets versioning, repositories, dependency bundles, publishing,
release and documentation facts without a build script of its own.
plugins {
alias klokLibs.plugins.gradle
}
klok {
projectType = 'INTEGRATION'
projectVisibility = 'DOMAIN'
projectDesc = 'Fortnox invoices for the finance domain'
majorVersion = '1'
minorVersion = '0'
patchVersion = '0'
}
What the plugin does when applied:
- computes the version
<major.minor.patch>-build.<timestamp> with one timestamp for every module of the build, and
writes build/klok-release.properties for the CI catalog update; for an integration or an application the timestamp is
the commit time, and its jars and its Quarkus output are written without build times, so a rebuild of the same commit
gives the same bytes (Versioning and
publishing);
- offers the repositories block
klokRespositories { klokDefaultRepositories() } (Maven Central, Maven local, the
tenant's GitLab group registry and the platform registry klok), authenticated with the job token in CI and a personal
token elsewhere (Extension reference);
- applies the dependency bundle for the project type from the
klokLibs version catalog (klokIntegrationImpl,
klokApplicationImpl, klokDatamodelImpl) and enforces the Quarkus and Camel platforms; the tenant's own datamodels
come from the second catalog, tenantLibs (Catalog update);
- configures publishing:
publish stages the publication locally in build/staging-deploy, and JReleaser deploys
it from there, to the project's GitLab package registry, or to Maven Central for a PUBLIC project, and creates the
GitLab release;
- registers the tasks
updateKlokLibsToml (refreshes both catalog copies), updateKlokAgents (alias initKlokAgents;
the platform instructions and skills plus the tenant's skills), extractKlokKnowledge (with fetchKlokAgentsZip),
initDocsGeneration, publishKlokDocs, publishKlokContext, klokTopics, klokTopicCheck, klokMcpTools and
klokSolutionCheck;
- for a project that says
klokKnowledge=true, bundles the shared Klok knowledge blocks from the catalog as resources
under /klok-knowledge/, and fails its CI build on a missing block (Documentation tasks);
- for a datamodel, generates and publishes the Python package and the TypeScript package of the datamodel from
the Avro schema Java registers on the broker (
dumpKlokWireSchemas, buildKlokPythonDatamodel,
publishKlokPythonDatamodel, buildKlokTypeScriptDatamodel, publishKlokTypeScriptDatamodel, part of publish), and
refuses to release a build that breaks a service on an earlier release (klokDatamodelCompatibilityCheck, part of
check and publish).
Versions
The plugin itself is published as 0.2.0-build.<timestamp> to Maven Central (its GitLab registry deploy is switched off
in this repository's build.gradle); each release updates klokGradlePlugin in the platform dependency catalog, and
every project takes the plugin version from its catalog copy (gradle/klok-libs.versions.toml, refreshed with
updateKlokLibsToml). Nobody pins the plugin version by hand. A tenant's own datamodels and libraries move the same way
through the tenant's private catalog and the project's second copy, gradle/tenant-libs.versions.toml (tenantLibs).
Who uses the plugin, and how
An integration developer applies the plugin (alias klokLibs.plugins.gradle), fills in klok { } and otherwise
runs ordinary Gradle: ./gradlew build, ./gradlew quarkusDev. The plugin gives the project its version, its
repositories and the framework dependencies for an INTEGRATION. The tasks worth knowing by name are
updateKlokLibsToml (take the newest framework versions into gradle/klok-libs.versions.toml and the tenant's newest
datamodels into gradle/tenant-libs.versions.toml; every pipeline does this itself, a Klok job keeps the committed
copies current, and you commit them only when your change needs a new alias), updateKlokAgents (install what git does
not track of the AI agent instructions, and the tenant's context skills), initDocsGeneration (write the documentation
payload locally, to see what the route scan finds) and klokTopics (every broker topic the service needs; the broker
creates none by itself, so a topic missing from the tenant's Pulsar file holds the routes that need it, from
klok-quarkus-extension 3.14.0, or stops the whole service on an older extension version). klokTopicCheck asks klok.dev
whether those topics exist and are granted, and fails a deploy when one is not (Broker topics of a
project). klokMcpTools lists the MCP tools the service exposes to an agent (MCP tools of a
project). klokSolutionCheck checks that every route id starts with a solution registered in the
tenant's <tenant>/integration-solutions (Solution ids of a project). Publishing, release and
publishKlokDocs run in CI, on main.
A datamodel author sets projectType = 'DATAMODEL'. publish then produces three things from one build: the Java
jar with the generated classes, a Python package and a TypeScript (npm) package, all generated from the Avro schema the
Java classes register on the broker. The pipeline on main publishes them and writes the version into the dependency
catalog; see Python datamodel packages and TypeScript datamodel
packages. Before any of it, klokDatamodelCompatibilityCheck compares the new schema with
every earlier release, both ways, and fails a change that would break a service on one of them; such a change is a new
major version, a new datamodel (Datamodel compatibility). The pipeline runs the same check
on every merge request. It then publishes the repository's documentation payload, its klok-docs/ and one entry per
class of the model, with publishKlokDocs; see Documentation tasks, Datamodel projects.
A framework maintainer changes the plugin through a merge request like any other change. The merge is the release:
the main pipeline of this repository (build-template-java.yml from build-ci-templates) builds
0.2.0-build.<timestamp>, deploys it to Maven Central with JReleaser (Central can take 30 to 40 minutes to report it as
published) and update_klok_catalog writes it into klok/framework/klok-gradle-dependency-catalog as
klokGradlePlugin; every project moves to it on its next updateKlokLibsToml. Watch for the catalog commit
chore(catalog): update klok-gradle-plugin … rather than the merge. The plugin takes klok-common, the broker client and
the documentation datamodel from the catalog (Catalog update), so klok catalog release-dependents
starts its pipeline when one of them is released. See Versioning and publishing.
Pages
- Extension reference: every
klok { } property, its environment variable and default.
- Versioning and publishing
- Documentation tasks
- Broker topics of a project:
klokTopics, klokTopicCheck, topics.json and how to read and fix a failed
check.
- MCP tools of a project:
klokMcpTools, mcp-tools.json and how the scan reads a @KlokMcpTool.
- Solution ids of a project:
klokSolutionCheck, how it reads the tenant's solution registry, its
codes and solution-check.json.
- Catalog update: the platform catalog and the tenant catalog,
klokLibs and tenantLibs, and what
updateKlokLibsToml does when the tenant catalog is missing or unreadable.
- Python datamodel packages: the package every datamodel publishes for Python services and workers,
and where its schema comes from.
- TypeScript datamodel packages: the npm package every datamodel publishes for Node services,
klok-cli and the TypeScript broker client.
- Datamodel compatibility:
klokDatamodelCompatibilityCheck, which changes keep a
datamodel's major version and which make a new one, how to read a failed check, and how a datamodel records releases
nobody runs any more.
- Agent instructions:
updateKlokAgents, the catalog zip, KLOK-AGENTS.md, the managed row in
each harness file, and the tenant skills with the marker rule that decides what is pruned.
- Design decisions