Gradle Plugin
The plugin lives at dev.kensa.gradle-plugin on the Gradle Plugin Portal. It does three things:
- Applies the Kensa Kotlin compiler plugin to the configured sourcesets so
@RenderedValueand@ExpandableSentencecapture works at compile time. - Adds an implicit
dev.kensa:kensa-coreruntime dependency to those compilations (so you don't have to declare it manually). - When site mode is on, wires
kensa.output.root/kensa.source.idsystem properties onto each sourceset'sTesttask and registers anassembleKensaSitetask to produce a single multi-source viewable site.
Apply
loading...
The Kensa version pulled by the plugin is paired with the plugin version — the plugin embeds the kensa-core / compiler-plugin coordinates it was built against. You don't need to declare these manually.
DSL
Configure via the kensa { … } extension:
| Property | Type | Default | Effect |
|---|---|---|---|
enabled | Boolean | true | Master switch. When false, the compiler plugin is not applied and no kensa-core dep is added. |
debug | Boolean | false | Forwards debug=true to the compiler plugin (verbose logs during compilation). |
sourceSets | Set<String> | setOf("test") | Which sourcesets/test-tasks Kensa attaches to. |
site | Boolean | false | Enable site mode (see Site Mode). |
siteRoot | Directory | build/kensa-site | Site-mode output root. |
Example with multiple sourcesets in site mode:
loading...
Behaviour
For each name in sourceSets, the plugin looks up a Test task with the same name. When found:
- A
dev.kensa:kensa-coredependency is added to that compilation's classpath via Kotlin's compiler-plugin support. - If
site = true:kensa.output.rootsystem property is set on the test task to the resolvedsiteRoot.kensa.source.idsystem property is set to the sourceset name (unless you've already set it explicitly — see overrides).- The
assembleKensaSitetask is registered, depending on every configured Test task.
The compiler plugin is only applied to compilations whose name appears in sourceSets. Other sourcesets compile normally without Kensa.
Per-source overrides
The plugin's per-task systemProperty wiring is last-write-wins, so you can override anything from the user side. For example, to prefix the source id with the CI build number:
tasks.named<Test>("uiTest") {
systemProperty("kensa.source.id", "${System.getenv("BUILD_NUMBER") ?: "local"}-uiTest")
systemProperty("kensa.source.title", "Build #${System.getenv("BUILD_NUMBER") ?: "local"} — UI Tests")
}
kensa.source.title overrides the default Configuration.titleText for that source's configuration.json (and therefore the label shown in the site sidebar).
Tasks added
| Task | Group | Description |
|---|---|---|
assembleKensaSite | verification | Aggregates all per-source bundles in siteRoot/sources/<id>/ into a single viewable site. Depends on every configured Test task. Only registered when site = true. |
assembleKensaSite is @CacheableTask — its inputs are the per-source configuration.json files plus the resolved kensa-core jar's content. Re-running with no changes is UP-TO-DATE; republishing kensa-core to your local maven invalidates the cache and re-extracts the new shell.
Source ID collisions
If two configured Test tasks resolve to the same kensa.source.id, the build fails fast with an actionable error pointing at how to disambiguate:
Kensa site mode: source id collision on 'foo' (multiple sourcesets / test tasks resolve to the same kensa.source.id).
Override one explicitly: tasks.named<Test>("<name>") { systemProperty("kensa.source.id", "<unique>") }
Maven plugin
Maven users — see the Maven plugin page. The assemble-site mojo provides the same site-mode aggregation; per-source bundles are driven by systemPropertyVariables on each surefire/failsafe execution.