Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b982021
Bump CoreJvm Compiler -> `2.0.0-SNAPSHOT.064`
alexander-yevsyukov May 15, 2026
605670b
Update dependency reports
alexander-yevsyukov May 15, 2026
6091ed8
Suppress false duplicate depenencies warning
alexander-yevsyukov May 15, 2026
2df5d38
Bump Time -> `2.0.0-SNAPSHOT.240`
alexander-yevsyukov May 15, 2026
af4d057
Update dependency reports
alexander-yevsyukov May 15, 2026
9b43f9a
Rename `error_message.proto` to `template_string.proto`
alexander-yevsyukov May 15, 2026
f255455
Remove deprecated `ErrorPlaceholder`
alexander-yevsyukov May 15, 2026
70d0811
Add integration tests for the `(when)` constraint compilation
alexander-yevsyukov May 15, 2026
384a042
Introduce `Placeholder`, rename `ErrorPlaceholder` to `StandardPlaceh…
alexander-yevsyukov May 15, 2026
e83dd68
Bump base version -> `2.0.0-SNAPSHOT.388`
alexander-yevsyukov May 15, 2026
51ffaaf
Move `TemplateString` and `Placeholder` to `base`
alexander-yevsyukov May 15, 2026
ba82d54
Update dependency reports
alexander-yevsyukov May 15, 2026
87e403e
Bump version -> `2.0.0-SNAPSHOT.430`
alexander-yevsyukov May 15, 2026
b7e1044
Update dependency reports
alexander-yevsyukov May 15, 2026
6607211
Adopt new `Placeholder` API
alexander-yevsyukov May 15, 2026
0853ce6
Bump Validation -> `2.0.0-SNAPSHOT.419`
alexander-yevsyukov May 15, 2026
ab3a9de
Update dependency reports
alexander-yevsyukov May 15, 2026
0253ce8
Add the `StandardPlaceholder.placed` property
alexander-yevsyukov May 15, 2026
1f3ff27
Improve file name
alexander-yevsyukov May 15, 2026
84d4927
Replace class names in the generated code
alexander-yevsyukov May 15, 2026
5f7a20b
Migrate to new `TemplateString`
alexander-yevsyukov May 15, 2026
40f03c8
Use older placeholders code, for now
alexander-yevsyukov May 15, 2026
6554acb
Remove redundant `@JvmName`
alexander-yevsyukov May 15, 2026
f356b62
Bump Base -> `2.0.0-SNAPSHOT.389`
alexander-yevsyukov May 15, 2026
95fa800
Update dependency reports
alexander-yevsyukov May 15, 2026
3a08b4d
Migrate to `Placeholder` API
alexander-yevsyukov May 15, 2026
483781e
Update dependency reports
alexander-yevsyukov May 15, 2026
5780fa5
Force Time runtime libraries
alexander-yevsyukov May 15, 2026
5191bb1
Update build time
alexander-yevsyukov May 15, 2026
e4e9b0b
Merge branch 'master' into migrate-to-template-string-from-base
alexander-yevsyukov May 16, 2026
b84be35
Update embedded code
alexander-yevsyukov May 16, 2026
c7c17ef
Bump Validation
alexander-yevsyukov May 16, 2026
6f6da7c
Update build time
alexander-yevsyukov May 16, 2026
d438c4b
Update docs/_examples submodule reference
alexander-yevsyukov May 16, 2026
5abad2e
Update `_example` ref.
alexander-yevsyukov May 16, 2026
1e7e1ff
Update examples ref.
alexander-yevsyukov May 16, 2026
44f3657
Update build time
alexander-yevsyukov May 16, 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
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ allprojects {
Roaster.jdt,
Time.lib,
Time.javaExtensions,
Time.kotlinExtensions,
ToolBase.lib,
ToolBase.pluginBase,
Validation.javaBundle,
Expand Down
83 changes: 83 additions & 0 deletions buildSrc/src/main/kotlin/PatchGeneratedTemplateString.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.
*/

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register

/**
* Registers a `patchGeneratedTemplateString` task in the project, which replaces
* references to the legacy `io.spine.validation.TemplateString` class (and its
* proto FQN `.spine.validation.TemplateString`) with `io.spine.string.TemplateString`
* in the `generated/` sources.
*
* The task is wired to run after [upstreamTask] (the task that produces the sources
* to be patched) and before `compileJava` and `kspKotlin`.
*
* @param upstreamTask the name of the task whose output should be patched
* (e.g., `generateProto` or `launchSpineCompiler`).
*/
fun Project.patchGeneratedTemplateString(upstreamTask: String): TaskProvider<Task> {
val patchTask = tasks.register("patchGeneratedTemplateString") {
dependsOn(upstreamTask)

val generatedDir = layout.projectDirectory.dir("generated")
inputs.dir(generatedDir).withPropertyName("generatedSources")
outputs.dir(generatedDir).withPropertyName("patchedSources")

doLast {
val oldClassRef = "io.spine.validation.TemplateString"
val newClassRef = "io.spine.string.TemplateString"
val oldProtoRef = ".spine.validation.TemplateString"
val newProtoRef = ".spine.string.TemplateString"
Comment thread
alexander-yevsyukov marked this conversation as resolved.
generatedDir.asFile.walkTopDown()
.filter { it.isFile && (it.extension == "java" || it.extension == "kt") }
.forEach { file ->
val original = file.readText()
if (original.contains(oldClassRef) || original.contains(oldProtoRef)) {
val patched = original
.replace(oldClassRef, newClassRef)
.replace(oldProtoRef, newProtoRef)
file.writeText(patched)
Comment thread
alexander-yevsyukov marked this conversation as resolved.
}
}
}
Comment thread
alexander-yevsyukov marked this conversation as resolved.
}

tasks.named("compileJava") {
dependsOn(patchTask)
}

afterEvaluate {
tasks.named("kspKotlin") {
dependsOn(patchTask)
}
}

return patchTask
}
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ package io.spine.dependency.local
*/
@Suppress("ConstPropertyName", "unused")
object Base {
const val version = "2.0.0-SNAPSHOT.387"
const val versionForBuildScript = "2.0.0-SNAPSHOT.387"
const val version = "2.0.0-SNAPSHOT.389"
const val versionForBuildScript = "2.0.0-SNAPSHOT.389"
const val group = Spine.group
private const val prefix = "spine"
const val libModule = "$prefix-base"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object CoreJvmCompiler {
/**
* The version used to in the build classpath.
*/
const val dogfoodingVersion = "2.0.0-SNAPSHOT.063"
const val dogfoodingVersion = "2.0.0-SNAPSHOT.064"

/**
* The version to be used for integration tests.
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import io.spine.dependency.Dependency
)
object Time : Dependency() {
override val group = Spine.group
override val version = "2.0.0-SNAPSHOT.238"
override val version = "2.0.0-SNAPSHOT.240"
private const val infix = "spine-time"

fun lib(version: String): String = "$group:$infix:$version"
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.415"
const val version = "2.0.0-SNAPSHOT.419"

/**
* The last version of Validation compatible with ProtoData.
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/module.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ fun Module.forceConfigurations() {
Base.environment,
Protobuf.compiler,
Time.lib,
Time.javaExtensions,
Time.kotlinExtensions,
TestLib.lib,
ToolBase.gradlePluginApi,
ToolBase.jvmTools,
Expand Down
2 changes: 2 additions & 0 deletions context/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ afterEvaluate {
val launchSpineCompiler by tasks.getting
kspKotlin.dependsOn(launchSpineCompiler)
}

patchGeneratedTemplateString(upstreamTask = "launchSpineCompiler")

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import io.spine.tools.compiler.ast.OneofGroup
import io.spine.tools.compiler.ast.Span
import io.spine.tools.compiler.ast.qualifiedName
import io.spine.tools.compiler.check
import io.spine.validation.ErrorPlaceholder
import io.spine.validation.extractPlaceholders
import io.spine.string.Placeholder
import io.spine.string.Placeholder.Companion.extractPlaceholders

/**
* Checks if this [String] contains placeholders that are not present in the given
Expand All @@ -47,7 +47,7 @@ import io.spine.validation.extractPlaceholders
* @param option The name of the option with which the message template was specified.
*/
internal fun String.checkPlaceholders(
supported: Set<ErrorPlaceholder>,
supported: Set<Placeholder>,
message: MessageType,
file: File,
option: String
Expand All @@ -69,7 +69,7 @@ internal fun String.checkPlaceholders(
* @param option The name of the option with which the message template was specified.
*/
internal fun String.checkPlaceholders(
supported: Set<ErrorPlaceholder>,
supported: Set<Placeholder>,
oneof: OneofGroup,
file: File,
option: String
Expand All @@ -91,7 +91,7 @@ internal fun String.checkPlaceholders(
* @param option The name of the option with which the message template was specified.
*/
public fun String.checkPlaceholders(
supported: Set<ErrorPlaceholder>,
supported: Set<Placeholder>,
field: Field,
file: File,
option: String
Expand All @@ -108,7 +108,7 @@ public fun String.checkPlaceholders(
* set of the [supported] placeholders, and reports a compilation error if so.
*/
private fun String.checkPlaceholders(
supported: Set<ErrorPlaceholder>,
supported: Set<Placeholder>,
declaration: String,
span: Span,
file: File,
Expand All @@ -119,7 +119,7 @@ private fun String.checkPlaceholders(
Compilation.check(missing.isEmpty(), file, span) {
"The $declaration specifies an error message for the `($option)` option using unsupported" +
" placeholders: `$missing`. Supported placeholders are the following:" +
" `${supported.map { it.value }}`."
" `${supported.map { it.name }}`."
}
}

Expand All @@ -132,13 +132,12 @@ private fun String.checkPlaceholders(
*/
private fun missingPlaceholders(
template: String,
placeholders: Set<ErrorPlaceholder>
): Set<String> {
placeholders: Set<Placeholder>
): Set<Placeholder> {
val requested = extractPlaceholders(template)
val provided = placeholders.map { it.value }
val missing = mutableSetOf<String>()
val missing = mutableSetOf<Placeholder>()
for (placeholder in requested) {
if (!provided.contains(placeholder)) {
if (!placeholders.contains(placeholder)) {
missing.add(placeholder)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ import io.spine.tools.validation.checkPlaceholders
import io.spine.tools.validation.defaultMessage
import io.spine.tools.validation.option.MAX
import io.spine.tools.validation.option.RANGE
import io.spine.validation.ErrorPlaceholder.FIELD_PATH
import io.spine.validation.ErrorPlaceholder.FIELD_TYPE
import io.spine.validation.ErrorPlaceholder.FIELD_VALUE
import io.spine.validation.ErrorPlaceholder.MAX_OPERATOR
import io.spine.validation.ErrorPlaceholder.MAX_VALUE
import io.spine.validation.ErrorPlaceholder.PARENT_TYPE
import io.spine.validation.StandardPlaceholder.FIELD_PATH
import io.spine.validation.StandardPlaceholder.FIELD_TYPE
import io.spine.validation.StandardPlaceholder.FIELD_VALUE
import io.spine.validation.StandardPlaceholder.MAX_OPERATOR
import io.spine.validation.StandardPlaceholder.MAX_VALUE
import io.spine.validation.StandardPlaceholder.PARENT_TYPE

/**
* A reaction to add a validation rule to a type whenever the `(max)` field option
Expand Down Expand Up @@ -107,10 +107,10 @@ internal class MaxFieldView : View<FieldRef, MaxField, MaxField.Builder>() {
}

private val SUPPORTED_PLACEHOLDERS = setOf(
FIELD_PATH,
FIELD_TYPE,
FIELD_VALUE,
MAX_OPERATOR,
MAX_VALUE,
PARENT_TYPE,
FIELD_PATH.value,
FIELD_TYPE.value,
FIELD_VALUE.value,
MAX_OPERATOR.value,
MAX_VALUE.value,
PARENT_TYPE.value,
)
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ import io.spine.tools.validation.checkPlaceholders
import io.spine.tools.validation.defaultMessage
import io.spine.tools.validation.option.MIN
import io.spine.tools.validation.option.RANGE
import io.spine.validation.ErrorPlaceholder.FIELD_PATH
import io.spine.validation.ErrorPlaceholder.FIELD_TYPE
import io.spine.validation.ErrorPlaceholder.FIELD_VALUE
import io.spine.validation.ErrorPlaceholder.MIN_OPERATOR
import io.spine.validation.ErrorPlaceholder.MIN_VALUE
import io.spine.validation.ErrorPlaceholder.PARENT_TYPE
import io.spine.validation.StandardPlaceholder.FIELD_PATH
import io.spine.validation.StandardPlaceholder.FIELD_TYPE
import io.spine.validation.StandardPlaceholder.FIELD_VALUE
import io.spine.validation.StandardPlaceholder.MIN_OPERATOR
import io.spine.validation.StandardPlaceholder.MIN_VALUE
import io.spine.validation.StandardPlaceholder.PARENT_TYPE

/**
* A reaction to add a validation rule to a type whenever the `(min)` field option
Expand Down Expand Up @@ -107,10 +107,10 @@ internal class MinFieldView : View<FieldRef, MinField, MinField.Builder>() {
}

private val SUPPORTED_PLACEHOLDERS = setOf(
FIELD_PATH,
FIELD_TYPE,
FIELD_VALUE,
MIN_OPERATOR,
MIN_VALUE,
PARENT_TYPE,
FIELD_PATH.value,
FIELD_TYPE.value,
FIELD_VALUE.value,
MIN_OPERATOR.value,
MIN_VALUE.value,
PARENT_TYPE.value,
)
Loading
Loading