Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ on:
jobs:
publish:
name: Publish to Maven repositories
uses: SpineEventEngine/config/.github/workflows/publishing.yml@5ddff23286f7f6353d4714b0399ab89109c56c79
uses: SpineEventEngine/config/.github/workflows/publishing.yml@3cc29d4e51eb6de7da4234d2677973cead2cea84
permissions:
contents: read
packages: write
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object Compiler : Dependency() {
* The version of the Compiler dependencies.
*/
override val version: String
private const val fallbackVersion = "2.0.0-SNAPSHOT.081"
private const val fallbackVersion = "2.0.0-SNAPSHOT.083"

/**
* The distinct version of the Compiler used by other build tools.
Expand All @@ -69,7 +69,7 @@ object Compiler : Dependency() {
* transitive dependencies, this is the version used to build the project itself.
*/
val dogfoodingVersion: String
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.081"
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.083"

/**
* The artifact for the Compiler Gradle plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typealias CoreJava = CoreJvm
)
object CoreJvm {
const val group = Spine.group
const val version = "2.0.0-SNAPSHOT.577"
const val version = "2.0.0-SNAPSHOT.611"

const val coreArtifact = "spine-core"
const val clientArtifact = "spine-client"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ object CoreJvmCompiler {
/**
* The version used in the build classpath.
*/
const val dogfoodingVersion = "2.0.0-SNAPSHOT.099"
const val dogfoodingVersion = "2.0.0-SNAPSHOT.104"

/**
* The version to be used for integration tests.
*/
const val version = "2.0.0-SNAPSHOT.099"
const val version = "2.0.0-SNAPSHOT.104"

/**
* The ID of the Gradle plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ package io.spine.dependency.local
)
object ProtoTap {
const val group = Spine.toolsGroup
const val version = "0.17.4"
const val version = "0.17.5"
const val gradlePluginId = "io.spine.prototap"
const val api = "$group:prototap-api:$version"
const val gradlePlugin = "$group:prototap-gradle-plugin:$version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ package io.spine.dependency.local
)
object ToolBase {
const val group = Spine.toolsGroup
const val version = "2.0.0-SNAPSHOT.428"
const val dogfoodingVersion = "2.0.0-SNAPSHOT.428"
const val version = "2.0.0-SNAPSHOT.451"
const val dogfoodingVersion = "2.0.0-SNAPSHOT.451"

const val archive = "$group:archive:$version"
const val code = "$group:code:$version"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object Validation {
/**
* The version of the Validation library artifacts.
*/
const val version = "2.0.0-SNAPSHOT.469"
const val version = "2.0.0-SNAPSHOT.470"

const val group = Spine.toolsGroup
private const val prefix = "validation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import org.gradle.kotlin.dsl.withType
* dedicated [AGENT_CONFIGURATION] configuration.
* 2. Passes the agent JAR path and a per-module exec directory
* (`build/`[TESTKIT_COVERAGE_DIR]) to the test JVM as system properties.
* The `plugin-testlib` harness reads these and writes a `gradle.properties`
* into the worker's Gradle user home that adds `-javaagent:…` to the worker JVM.
* The `plugin-testlib` harness reads these and attaches `-javaagent:…` to the
* worker JVM.
* 3. Wipes the exec directory at most once per build invocation, from the
* `doFirst` of the first `Test` task that actually executes, so stale worker
* coverage from a previous run does not accumulate. Two failure modes are
Expand All @@ -58,6 +58,11 @@ import org.gradle.kotlin.dsl.withType
* coverage. An up-to-date (non-cache) run is unaffected: the previous run's
* files remain on disk and the guarded `doFirst` never deletes them.
*
* The method does not choose the TestKit directory of the worker builds.
* The `module-testing` and `kmp-module` script plugins point the `Test` tasks
* of a module at a shared one (see [useSharedTestKitDir]), which a harness
* that passes its own directory to `withTestKitDir(...)` does not use.
*
* The produced `.exec` files are merged into the Kover reports by
* [io.spine.gradle.report.coverage.KoverConfig]. The agent emits binary
* execution data rather than an XML report because that is its only file output,
Expand Down
84 changes: 84 additions & 0 deletions buildSrc/src/main/kotlin/io/spine/gradle/testing/TestKitDir.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright 2026 CodeMatters, Lda.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/

package io.spine.gradle.testing

import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.withType

/**
* Configures the `Test` tasks of this project so that the Gradle TestKit builds
* they run use the TestKit directory [shared by all modules][SHARED_TESTKIT_DIR].
*
* A TestKit directory is the Gradle user home of the builds that
* [GradleRunner][org.gradle.testkit.runner.GradleRunner] runs. It holds mostly
* Gradle's instrumented copies of the JARs on the classpath of the plugin under
* test, and the compiled build scripts of the test projects. When the directory
* is empty, the TestKit builds recreate them, which is slow on a CI runner.
*
* Without the [`org.gradle.testkit.dir`][TESTKIT_DIR_PROPERTY] system property,
* TestKit keeps the directory at `build/tmp/<task>/work/.gradle-test-kit`, in
* the temporary directory of the `Test` task. So each `Test` task of each module
* has its own, which is empty in a fresh checkout and after `clean`. This
* function passes the shared directory to the test JVM as that property, which
* `GradleRunner.create()` reads. A runner given a directory with
* `withTestKitDir(...)` still uses that one.
*
* The property is set from a `doFirst` action rather than at configuration time,
* so it is not a task input. Where TestKit builds keep their caches does not
* affect the test results, while the absolute path differs between machines.
* As an input, it would only break the reuse of the `Test` task results from
* the build cache across machines. A `Test` task that already has the property
* keeps its value, so a repeated call has no further effect.
*
* The function applies to all the `Test` tasks of the project, whether they
* run TestKit builds or not, and whether the project collects the coverage of
* those builds or not (see [enableTestKitCoverage]).
*/
fun Project.useSharedTestKitDir() {
val testKitDir = gradle.gradleUserHomeDir.resolve(SHARED_TESTKIT_DIR)
tasks.withType<Test>().configureEach {
doFirst {
if (TESTKIT_DIR_PROPERTY !in systemProperties) {
systemProperty(TESTKIT_DIR_PROPERTY, testKitDir.absolutePath)
}
}
}
}

/**
* The name of the system property carrying the absolute path to the TestKit
* directory, which `GradleRunner.create()` reads.
*
* A runner given a directory with `withTestKitDir(...)` uses that one instead.
*
* @see org.gradle.testkit.runner.GradleRunner.withTestKitDir
*/
private const val TESTKIT_DIR_PROPERTY: String = "org.gradle.testkit.dir"

/**
* The path, relative to the Gradle user home of the build, of the TestKit
* directory shared by the TestKit builds of all modules.
*
* The directory is placed under `caches/`, which `gradle/actions/setup-gradle`
* restores on every run but saves only on the default branch. So a pull request
* run starts with a warm directory once a run on the default branch has saved it.
* Locally, the TestKit builds of all the repositories that use this `buildSrc`
* share it.
*
* Unlike a directory under `build/`, it is not reset by `clean`. Delete it to make
* the TestKit builds start from an empty one.
*/
private const val SHARED_TESTKIT_DIR: String = "caches/spine-testkit"
7 changes: 7 additions & 0 deletions buildSrc/src/main/kotlin/kmp-module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.spine.gradle.kotlin.setFreeCompilerArgs
import io.spine.gradle.publish.IncrementGuard
import io.spine.gradle.report.license.LicenseReporter
import io.spine.gradle.testing.configureLogging
import io.spine.gradle.testing.useSharedTestKitDir

/**
* Configures this [Project] as a Kotlin Multiplatform module.
Expand Down Expand Up @@ -167,6 +168,12 @@ tasks {
}
}

/**
* Gives all the `Test` tasks the TestKit directory shared by all modules,
* as `module-testing` does (see [useSharedTestKitDir]).
*/
project.useSharedTestKitDir()

/**
* Overrides the default location of Kotlin sources.
*
Expand Down
5 changes: 5 additions & 0 deletions buildSrc/src/main/kotlin/module-testing.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ import io.spine.dependency.test.Kotest
import io.spine.dependency.test.Truth
import io.spine.gradle.testing.configureLogging
import io.spine.gradle.testing.registerTestTasks
import io.spine.gradle.testing.useSharedTestKitDir

/**
* This convention plugin applies test dependencies and configures test-related tasks.
*
* All the `Test` tasks of the module get the TestKit directory shared by all
* modules (see [useSharedTestKitDir]).
*
* The version of the [JUnit] platform must be applied via the [BomsPlugin][io.spine.dependency.boms.BomsPlugin]:
*
* ```kotlin
Expand All @@ -40,6 +44,7 @@ plugins {
project.run {
setupTests()
forceTestDependencies()
useSharedTestKitDir()
}

dependencies {
Expand Down
Loading
Loading