Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
d1a3200
Reduce using "please" in docs
alexander-yevsyukov Jan 20, 2026
11c6121
Improve text layout
alexander-yevsyukov Jan 20, 2026
b16788a
Bump version -> `2.0.0-SNAPSHOT.394`
alexander-yevsyukov Jan 20, 2026
9c0a34b
Bump Validation and CoreJvm Compiler
alexander-yevsyukov Jan 20, 2026
6379b9f
Update dependency reports
alexander-yevsyukov Jan 20, 2026
1d17e3b
Merge remote-tracking branch 'origin/master' into docs-set-1
alexander-yevsyukov Jan 20, 2026
1397636
Update config ref.
alexander-yevsyukov Jan 20, 2026
6e2fe2b
Remove "Migration Guide" section
alexander-yevsyukov Jan 21, 2026
479c28c
Improve text layout
alexander-yevsyukov Jan 21, 2026
4230509
Remove unnecessary decorations
alexander-yevsyukov Jan 21, 2026
77bbd9c
Remove hallucinated section links
alexander-yevsyukov Jan 21, 2026
4bf36f0
Remove redundant horizontal lines
alexander-yevsyukov Jan 21, 2026
09a9d47
Convert titles to sentence case
alexander-yevsyukov Jan 22, 2026
90bc7db
Allow empty lines after headers
alexander-yevsyukov Jan 22, 2026
78da3fb
Fix the proto options example
alexander-yevsyukov Jan 22, 2026
2d1f0aa
Use braces around proto options
alexander-yevsyukov Jan 22, 2026
0300e79
Temporarily add source code of proto options
alexander-yevsyukov Jan 22, 2026
94f69c0
Fix capitalization
alexander-yevsyukov Jan 22, 2026
449a789
Backtick code in ToC
alexander-yevsyukov Jan 22, 2026
3671ae4
Put the "Collection constraints" section after "Temporal constraints"
alexander-yevsyukov Jan 22, 2026
16a2736
Describe Validation components
alexander-yevsyukov Jan 22, 2026
7fb87ac
Remove "Configuration & tooling" section
alexander-yevsyukov Jan 22, 2026
51c5036
Rename "Installation" to "Adding Validation to your build"
alexander-yevsyukov Jan 22, 2026
d3d0b60
Describe adding Validation to a Gradle build
alexander-yevsyukov Jan 22, 2026
5383ae2
Improve the example type name in the `ValidationError` docs
alexander-yevsyukov Jan 22, 2026
0bb6196
Remove the leading zero in the Introduction section title
alexander-yevsyukov Jan 22, 2026
f99685a
Add wording for the `first-model.md`
alexander-yevsyukov Jan 22, 2026
9f5204a
Remove mentioning of temporal constraints
alexander-yevsyukov Jan 23, 2026
e409aa5
Add `code/first-model` subproject
alexander-yevsyukov Jan 23, 2026
c681d66
Make JVM runtime expose `Base.lib` at the `api` level
alexander-yevsyukov Jan 23, 2026
9e97727
Remove redundant dependencies
alexander-yevsyukov Jan 23, 2026
5918462
Remove commented out code
alexander-yevsyukov Jan 23, 2026
fe8e722
Improve package name for the `BankCard` example
alexander-yevsyukov Jan 23, 2026
fe75e36
Fix Kotlin package path
alexander-yevsyukov Jan 23, 2026
5316c03
Add Java test for `BankCard`
alexander-yevsyukov Jan 23, 2026
8ee49bd
Improve Kotlin test name
alexander-yevsyukov Jan 23, 2026
652a545
Bump Gradle -> `9.3.0`
alexander-yevsyukov Jan 23, 2026
c1dde85
Update dependency reports
alexander-yevsyukov Jan 23, 2026
de11e7e
Add `spine-compiler` plugin dependency
alexander-yevsyukov Jan 29, 2026
e48782a
Remove outdated configuration proto code
alexander-yevsyukov Jan 29, 2026
5cc8b40
Update dependency reports
alexander-yevsyukov Jan 29, 2026
01e5e12
Add requirements for supported browsers
alexander-yevsyukov Jan 29, 2026
7300c06
Auto-updated by IDEA
alexander-yevsyukov Jan 29, 2026
a274f85
Improve the structure of the `docs` directory
alexander-yevsyukov Jan 31, 2026
b7f6ab0
Add structure proposal
alexander-yevsyukov Jan 31, 2026
ebe0672
Improve formatting
alexander-yevsyukov Jan 31, 2026
69f0da2
Move content under the `content/docs` dir
alexander-yevsyukov Feb 3, 2026
e6827a6
Add scripts and settings
alexander-yevsyukov Feb 3, 2026
0e9cc87
Add Gradle project
alexander-yevsyukov Feb 3, 2026
ea1dca4
Add Go module for Validation Docs
alexander-yevsyukov Feb 4, 2026
912a91e
Add `docs/.gitignore`
alexander-yevsyukov Feb 4, 2026
0f3b92f
Add assets
alexander-yevsyukov Feb 4, 2026
c475633
Rename `_site` to `_preview`
alexander-yevsyukov Feb 4, 2026
eff6d99
Add content for the preview
alexander-yevsyukov Feb 4, 2026
d383d34
Fix placement of `_index.md`
alexander-yevsyukov Feb 5, 2026
f340143
Fix import of `site-commons`
alexander-yevsyukov Feb 5, 2026
3b8236c
Add `buildAll` tasks for building embedded code
alexander-yevsyukov Feb 5, 2026
ae5826b
Obtain the example version from the main code build
alexander-yevsyukov Feb 5, 2026
d085a55
Use the same `gradle.properties` for the documentation Gradle build
alexander-yevsyukov Feb 5, 2026
091f906
Document Gradle project of the documentation
alexander-yevsyukov Feb 5, 2026
bf1ace9
Fix relative paths in scripts
alexander-yevsyukov Feb 5, 2026
9b38339
Fix symlinks to use relative paths
alexander-yevsyukov Feb 5, 2026
90bdaf4
Fix import placement
alexander-yevsyukov Feb 5, 2026
181ba88
Bump Gradle -> `9.3.1`
alexander-yevsyukov Feb 5, 2026
91cbf53
Get updates from `site-commons` and remove styles
JuliaEvseeva Feb 6, 2026
a979558
Remove the obsolete config
JuliaEvseeva Feb 6, 2026
24c9f79
Make index pages as sections to be able to render child pages
JuliaEvseeva Feb 6, 2026
fd7aa02
Remove the version configuration for now to render the documentation …
JuliaEvseeva Feb 6, 2026
60a14ee
Configure the "Validation" sidenav to bring it to the "documentation"…
JuliaEvseeva Feb 9, 2026
75a0f4e
Ignore `_out` directories in `_code` subprojects
alexander-yevsyukov Feb 9, 2026
011527b
Do not use code from `buildSrc` in example projects
alexander-yevsyukov Feb 9, 2026
d299f4d
Add `TIMEOUT_MINUTES` property
alexander-yevsyukov Feb 9, 2026
ca70c08
Refer to Spine Maven repositories for plugin management
alexander-yevsyukov Feb 9, 2026
169e733
Stop using `includeBuild`
alexander-yevsyukov Feb 9, 2026
a6adb93
Build `firat-model` via `RunGradle`
alexander-yevsyukov Feb 9, 2026
5edee38
Add `docs/buildSrc` reference
alexander-yevsyukov Feb 9, 2026
1df5d08
Improve regex patterns and docs
alexander-yevsyukov Feb 9, 2026
e31ae89
Improve regex patterns and docs
alexander-yevsyukov Feb 9, 2026
ca5f681
Fix the reference to the `clean` task
alexander-yevsyukov Feb 9, 2026
dfc60c8
Get latest theme updates with the proper link rendering
JuliaEvseeva Feb 10, 2026
18b11fa
Describe plugin version update task
alexander-yevsyukov Feb 10, 2026
6894cac
Introduce `UpdatePluginVersion` task
alexander-yevsyukov Feb 10, 2026
e947ca5
Have `docs` as a first-class module
alexander-yevsyukov Feb 10, 2026
c0da252
Pass the version to the update task explicitly
alexander-yevsyukov Feb 10, 2026
8351dd0
Remove unused parameter
alexander-yevsyukov Feb 10, 2026
fc28b5a
Update the samples workflow to use the new `docs` module
alexander-yevsyukov Feb 10, 2026
c362939
Apply `LicenseReporter` to `docs`
alexander-yevsyukov Feb 10, 2026
0b550c0
Update dependency reports
alexander-yevsyukov Feb 10, 2026
8b86f48
Fix forcing local publishing before building doc samples
alexander-yevsyukov Feb 10, 2026
9f784e2
Register `publishAllToMavenLocal` task locally to `docs`
alexander-yevsyukov Feb 10, 2026
7d55ce4
Apply sentence capitalization
alexander-yevsyukov Feb 10, 2026
615b572
Fix display name
alexander-yevsyukov Feb 10, 2026
791bd6f
Document `TIMEOUT_MINUTES` property
alexander-yevsyukov Feb 10, 2026
291e639
Get theme updates and delete additional CSS config files
JuliaEvseeva Feb 11, 2026
974c40c
Merge branch 'docs-set-1' into setup-theme
JuliaEvseeva Feb 11, 2026
54f07fb
Get theme updates with the common data variables
JuliaEvseeva Feb 11, 2026
ec167b7
Allow more than two words in the card owner name in examples
alexander-yevsyukov Feb 11, 2026
c87bc81
Make the Validation Gradle Plugin add the Compiler Gradle Plugin auto…
alexander-yevsyukov Feb 11, 2026
d80c84f
Update the version config for `major` version
JuliaEvseeva Feb 11, 2026
7a964de
Place the sidenav in the corresponding folder
JuliaEvseeva Feb 11, 2026
573cdf9
Make the Validation Gradle Plugin add the Protobuf Gradle Plugin auto…
alexander-yevsyukov Feb 11, 2026
ce5ddba
Remove outdated build code
alexander-yevsyukov Feb 11, 2026
86d9830
Merge pull request #262 from SpineEventEngine/setup-theme
JuliaEvseeva Feb 11, 2026
1e39011
Update Kotlin version in `UpdatePluginVersion` task
alexander-yevsyukov Feb 11, 2026
c3c1bb3
Update Kotlin version before building samples
alexander-yevsyukov Feb 11, 2026
8900b78
Merge remote-tracking branch 'origin/docs-set-1' into docs-set-1
alexander-yevsyukov Feb 11, 2026
9310b68
Use `embed-code` instruction for `BankCard` sample
alexander-yevsyukov Feb 11, 2026
e4c07aa
Describe adding Validation to a project
alexander-yevsyukov Feb 11, 2026
d30cd2a
Fix directory name
alexander-yevsyukov Feb 11, 2026
57eb151
Ignore `.hugo_build.lock` under the `docs`
alexander-yevsyukov Feb 11, 2026
6523133
Add command line samples
alexander-yevsyukov Feb 11, 2026
565df92
Add `first-model-with-framework` project
alexander-yevsyukov Feb 11, 2026
bc538eb
Get theme updates and update configuration to change the minor versio…
JuliaEvseeva Feb 12, 2026
18c431b
Use import alias for the Compiler Gradle Plugin class
alexander-yevsyukov Feb 12, 2026
6b051a8
Bump CoreJvm Compiler -> `2.0.0-SNAPSHOT.052`
alexander-yevsyukov Feb 12, 2026
2203f89
Add temporary dependency on Validation JVM Runtime for `first-model-o…
alexander-yevsyukov Feb 12, 2026
24495cd
Update dependency reports
alexander-yevsyukov Feb 12, 2026
59f3cf9
Merge pull request #263 from SpineEventEngine/setup-versioning
JuliaEvseeva Feb 13, 2026
a45aa94
Update build time
alexander-yevsyukov Feb 13, 2026
c8715b4
Remove no longer needed extension
alexander-yevsyukov Feb 13, 2026
a946c76
Put executed command and local directory to console
alexander-yevsyukov Feb 13, 2026
bc5fd0a
Make `build` tasks run after `clean`
alexander-yevsyukov Feb 13, 2026
09ea217
Improve documentation of the dependency
alexander-yevsyukov Feb 13, 2026
7a89bf5
Fix the description of `kotlinVersion` property
alexander-yevsyukov Feb 13, 2026
03b68be
Fix capitalization of the title
alexander-yevsyukov Feb 13, 2026
9d7296f
Remove temporary .md file
alexander-yevsyukov Feb 13, 2026
0d2d0ae
Fix capitalization of "plugin"
alexander-yevsyukov Feb 13, 2026
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
34 changes: 34 additions & 0 deletions .github/workflows/check-code-embedding.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Check Code Embedding

on:
pull_request:

jobs:
build-embedded-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'

- uses: actions/setup-java@v5
with:
java-version: 17
distribution: zulu

- run: ./gradlew :docs:buildAll

check-embedded-samples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
submodules: 'recursive'

- uses: actions/setup-java@v5
with:
java-version: 17
distribution: zulu

- name: Check Embedding
run: ./gradlew :docs:checkSamples
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ dependencies {
).forEach {
implementation(it)
}

testImplementation(platform("org.junit:junit-bom:5.11.4"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

tasks.test {
useJUnitPlatform()
}

dependOnBuildSrcJar()
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/BuildSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ object BuildSettings {
val javaVersionCompat = JavaVersion.toVersion(JVM_VERSION)
val jvmTarget = JvmTarget.JVM_17
const val REMOTE_DEBUG_PORT = 5566
/**
* Default timeout (in minutes) for long-running Gradle tasks in CI.
*/
const val TIMEOUT_MINUTES = 42L
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ object CoreJvmCompiler {
/**
* The version used to in the build classpath.
*/
const val dogfoodingVersion = "2.0.0-SNAPSHOT.050"
const val dogfoodingVersion = "2.0.0-SNAPSHOT.052"

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

/**
* The ID of the Gradle plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object Validation {
/**
* The version of the Validation library artifacts.
*/
const val version = "2.0.0-SNAPSHOT.392"
const val version = "2.0.0-SNAPSHOT.393"

/**
* The last version of Validation compatible with ProtoData.
Expand Down
12 changes: 8 additions & 4 deletions buildSrc/src/main/kotlin/io/spine/gradle/RunGradle.kt
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,17 @@ open class RunGradle : DefaultTask() {
return if (runsOnWindows) "gradlew.bat" else "gradlew"
}

private fun startProcess(command: List<String>, errorOut: File, debugOut: File) =
ProcessBuilder()
private fun startProcess(command: List<String>, errorOut: File, debugOut: File): Process {
val workingDir = project.file(directory)
val builder = ProcessBuilder()
.command(command)
.directory(project.file(directory))
.directory(workingDir)
.redirectError(errorOut)
.redirectOutput(debugOut)
.start()
System.err.println("[RunGradle] Running the command: '${command.joinToString(" ")}'." +
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using System.err.println in a Gradle task produces unstructured output and ignores Gradle log levels. Prefer logger.lifecycle(...) / logger.info(...) (and/or guard under a debug flag) so CI logs stay clean and users can control verbosity.

Suggested change
System.err.println("[RunGradle] Running the command: '${command.joinToString(" ")}'." +
logger.lifecycle("[RunGradle] Running the command: '${command.joinToString(" ")}'." +

Copilot uses AI. Check for mistakes.
" Directory: '${workingDir.absolutePath}'.")
return builder.start()
}
}

private fun File.truncate() {
Expand Down
124 changes: 124 additions & 0 deletions buildSrc/src/main/kotlin/io/spine/gradle/docs/UpdatePluginVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright 2026, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package io.spine.gradle.docs

import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction

/**
* Updates the version of a Gradle plugin in `build.gradle.kts` files.
*
* The task searches for plugin declarations in the format
* `id("plugin-id") version "version-number"` and replaces
* the version number with the one found in the version script file.
*
* @property directory
* The directory to scan recursively for `build.gradle.kts` files.
* @property version
* The version number to set for the plugin.
* @property pluginId
* The ID of the plugin whose version should be updated.
* @property kotlinVersion
* Optional. If set, updates the version of the Kotlin plugin declared with
* `kotlin("…") version "…"` syntax in the `plugins` block.
* This option works in combination with the [version] and [pluginId] properties.
*/
abstract class UpdatePluginVersion : DefaultTask() {

@get:InputDirectory
abstract val directory: DirectoryProperty

@get:Input
abstract val version: Property<String>

@get:Input
abstract val pluginId: Property<String>

@get:Input
@get:Optional
abstract val kotlinVersion: Property<String>

/**
* Updates plugin versions in build files within the path in the [directory].
*/
@TaskAction
fun update() {
val rootDir = directory.get().asFile

val kotlinVersionSet = kotlinVersion.isPresent
val kotlinVer = kotlinVersion.orNull
val id = pluginId.get()
val ver = version.get()

rootDir.walkTopDown()
.filter { it.name == "build.gradle.kts" }
.forEach { file ->
if (kotlinVersionSet && kotlinVer != null) {
updateKotlinPluginVersion(file, kotlinVer)
}
updatePluginVersion(file, id, ver)
}
}

private fun updatePluginVersion(file: File, id: String, version: String) {
val content = file.readText()
// Regex to match: id("plugin-id") version "version-number"
val regex = """id\("$id"\)\s+version\s+"([^"]+)"""".toRegex()

if (regex.containsMatchIn(content)) {
val updatedContent = regex.replace(content) {
"id(\"$id\") version \"$version\""
Comment on lines +93 to +100
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plugin id is interpolated directly into a regex pattern; since plugin IDs commonly contain dots (.), they will be treated as “any character” and can match/replace the wrong plugin declaration. Escape the id when building the regex (e.g., via Regex.escape(id)).

Copilot uses AI. Check for mistakes.
}
if (content != updatedContent) {
file.writeText(updatedContent)
logger.info("Updated version of '$id' in `${file.absolutePath}`.")
}
}
}

private fun updateKotlinPluginVersion(file: File, kotlinVersion: String) {
val content = file.readText()
// Regex to match Kotlin plugin declarations like: kotlin("jvm") version "1.9.0"
val regex = """kotlin\("([^"]+)"\)\s+version\s+"([^"]+)"""".toRegex()
if (regex.containsMatchIn(content)) {
val updatedContent = regex.replace(content) { matchResult ->
val plugin = matchResult.groupValues[1]
"kotlin(\"$plugin\") version \"$kotlinVersion\""
}
if (content != updatedContent) {
file.writeText(updatedContent)
logger.info("Updated Kotlin plugin version in `${file.absolutePath}`.")
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright 2026, TeamDev. All rights reserved.
*
* 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
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package io.spine.gradle.docs

import java.io.File
import org.gradle.testfixtures.ProjectBuilder
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir

class UpdatePluginVersionTest {

@TempDir
lateinit var tempDir: File

private lateinit var buildFile: File

@BeforeEach
fun setUp() {
val subDir = File(tempDir, "subproject")
subDir.mkdir()
buildFile = File(subDir, "build.gradle.kts")
buildFile.writeText("""
plugins {
id("io.spine.validation") version "1.0.0"
id("other-plugin") version "0.1.0"
}
""".trimIndent())
}

@Test
fun `update plugin version in build file`() {
val project = ProjectBuilder.builder().build()
val task = project.tasks.register("updatePluginVersion", UpdatePluginVersion::class.java) {
directory.set(tempDir)
version.set("2.0.0-TEST")
pluginId.set("io.spine.validation")
}
task.get().update()

val updatedContent = buildFile.readText()
assertTrue(updatedContent.contains("""id("io.spine.validation") version "2.0.0-TEST""""))
assertTrue(updatedContent.contains("""id("other-plugin") version "0.1.0""""))
}

@Test
fun `update 'kotlin' plugin version when 'kotlinVersion' is set`() {
// Overwrite with a file that uses kotlin("jvm") syntax
buildFile.writeText(
"""
plugins {
kotlin("jvm") version "1.9.10"
id("io.spine.validation") version "1.0.0"
}
""".trimIndent()
)

val project = ProjectBuilder.builder().build()
val task = project.tasks.register("updatePluginVersion", UpdatePluginVersion::class.java) {
directory.set(tempDir)
version.set("2.0.0-TEST")
pluginId.set("io.spine.validation")
kotlinVersion.set("2.2.21")
}
task.get().update()

val updatedContent = buildFile.readText()
assertTrue(updatedContent.contains("""kotlin("jvm") version "2.2.21"""))
assertTrue(updatedContent.contains("""id("io.spine.validation") version "2.0.0-TEST"""))
}

@Test
fun `handle multiple spaces between id and version`() {
buildFile.writeText("""
plugins {
id("io.spine.validation") version "1.0.0"
}
""".trimIndent())

val project = ProjectBuilder.builder().build()
val task = project.tasks.register("updatePluginVersion", UpdatePluginVersion::class.java) {
directory.set(tempDir)
version.set("2.0.0-TEST")
pluginId.set("io.spine.validation")
}

task.get().update()

val updatedContent = buildFile.readText()
assertTrue(updatedContent.contains("""id("io.spine.validation") version "2.0.0-TEST""""))
}
}
Loading
Loading