-
Notifications
You must be signed in to change notification settings - Fork 0
Add initial Validation library documentation with Hugo preview infrastructure #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d1a3200
11c6121
b16788a
9c0a34b
6379b9f
1d17e3b
1397636
6e2fe2b
479c28c
4230509
77bbd9c
4bf36f0
09a9d47
90bc7db
78da3fb
2d1f0aa
0300e79
94f69c0
449a789
3671ae4
16a2736
7fb87ac
51c5036
d3d0b60
5383ae2
0bb6196
f99685a
9f5204a
e409aa5
c681d66
9e97727
5918462
fe8e722
fe75e36
5316c03
8ee49bd
652a545
c1dde85
de11e7e
e48782a
5cc8b40
01e5e12
7300c06
a274f85
b7f6ab0
ebe0672
69f0da2
e6827a6
0e9cc87
ea1dca4
912a91e
0f3b92f
c475633
eff6d99
d383d34
f340143
3b8236c
ae5826b
d085a55
091f906
bf1ace9
9b38339
90bdaf4
181ba88
91cbf53
a979558
24c9f79
fd7aa02
60a14ee
75a0f4e
011527b
d299f4d
ca70c08
169e733
a6adb93
5edee38
1df5d08
e31ae89
ca5f681
dfc60c8
18b11fa
6894cac
e947ca5
c0da252
8351dd0
fc28b5a
c362939
0b550c0
8b86f48
9f784e2
7d55ce4
615b572
791bd6f
291e639
974c40c
54f07fb
ec167b7
c87bc81
d80c84f
7a964de
573cdf9
ce5ddba
86d9830
1e39011
c3c1bb3
8900b78
9310b68
e4c07aa
d30cd2a
57eb151
6523133
565df92
bc538eb
18c431b
6b051a8
2203f89
24495cd
59f3cf9
a45aa94
c8715b4
a946c76
bc5fd0a
09ea217
7a89bf5
03b68be
9d7296f
0d2d0ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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(" ")}'." + | ||||||
|
||||||
| System.err.println("[RunGradle] Running the command: '${command.joinToString(" ")}'." + | |
| logger.lifecycle("[RunGradle] Running the command: '${command.joinToString(" ")}'." + |
| 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() | ||
alexander-yevsyukov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (regex.containsMatchIn(content)) { | ||
| val updatedContent = regex.replace(content) { | ||
| "id(\"$id\") version \"$version\"" | ||
|
Comment on lines
+93
to
+100
|
||
| } | ||
| 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() | ||
alexander-yevsyukov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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"""")) | ||
alexander-yevsyukov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @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"""")) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.