diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt index 21417f4ef..8dabdb885 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt @@ -1,5 +1,5 @@ /* - * Copyright 2024, TeamDev. All rights reserved. + * Copyright 2025, 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. diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt index 1e2daa69a..beaa9aa2a 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt @@ -33,8 +33,8 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName") object Base { - const val version = "2.0.0-SNAPSHOT.242" - const val versionForBuildScript = "2.0.0-SNAPSHOT.242" + const val version = "2.0.0-SNAPSHOT.244" + const val versionForBuildScript = "2.0.0-SNAPSHOT.244" const val group = Spine.group const val artifact = "spine-base" const val lib = "$group:$artifact:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt index 1b7b10d2f..75bfc63bb 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt @@ -42,12 +42,12 @@ object McJava { /** * The version used to in the build classpath. */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.263" + const val dogfoodingVersion = "2.0.0-SNAPSHOT.264" /** * The version to be used for integration tests. */ - const val version = "2.0.0-SNAPSHOT.264" + const val version = "2.0.0-SNAPSHOT.265" /** * The ID of the Gradle plugin. diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt index 1639e8b57..c5afba44c 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt @@ -73,7 +73,7 @@ object ProtoData { * The version of ProtoData dependencies. */ val version: String - private const val fallbackVersion = "0.92.7" + private const val fallbackVersion = "0.92.9" /** * The distinct version of ProtoData used by other build tools. @@ -82,7 +82,7 @@ object ProtoData { * transitional dependencies, this is the version used to build the project itself. */ val dogfoodingVersion: String - private const val fallbackDfVersion = "0.92.6" + private const val fallbackDfVersion = "0.92.9" /** * The artifact for the ProtoData Gradle plugin. diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt index 24c2767be..ddcacf7d4 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt @@ -36,7 +36,7 @@ object Validation { /** * The version of the Validation library artifacts. */ - const val version = "2.0.0-SNAPSHOT.193" + const val version = "2.0.0-SNAPSHOT.195" const val group = "io.spine.validation" private const val prefix = "spine-validation" diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt index ff70b82fa..9144e2f21 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt @@ -1,5 +1,5 @@ /* - * Copyright 2024, TeamDev. All rights reserved. + * Copyright 2025, 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. @@ -75,20 +75,21 @@ object PomGenerator { plugin(BasePlugin::class.java) } - val task = project.tasks.create("generatePom") - task.doLast { - val pomFile = project.projectDir.resolve("pom.xml") - project.delete(pomFile) + val task = project.tasks.register("generatePom") { + doLast { + val pomFile = project.projectDir.resolve("pom.xml") + project.delete(pomFile) - val projectData = project.metadata() - val writer = PomXmlWriter(projectData) - writer.writeTo(pomFile) + val projectData = project.metadata() + val writer = PomXmlWriter(projectData) + writer.writeTo(pomFile) + } + + val assembleTask = project.tasks.findByName("assemble")!! + dependsOn(assembleTask) } val buildTask = project.tasks.findByName("build")!! buildTask.finalizedBy(task) - - val assembleTask = project.tasks.findByName("assemble")!! - task.dependsOn(assembleTask) } } diff --git a/config b/config index d3f2e696f..8bc443da2 160000 --- a/config +++ b/config @@ -1 +1 @@ -Subproject commit d3f2e696f3de878d19f7c635107620becb7829f1 +Subproject commit 8bc443da2ac11dbe7dbdf44f5fb5d54cfa7bb27a diff --git a/dependencies.md b/dependencies.md index 74527f7ea..fcd067af1 100644 --- a/dependencies.md +++ b/dependencies.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:spine-mc-java:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : aopalliance. **Name** : aopalliance. **Version** : 1.0. @@ -757,6 +757,14 @@ 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -1046,12 +1054,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:25 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:53 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-annotation:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-annotation:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -1969,12 +1977,12 @@ This report was generated on **Mon Feb 24 14:20:25 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:53 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-base:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-base:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -2627,6 +2635,14 @@ This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -2892,12 +2908,12 @@ This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:53 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-checks:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-checks:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : aopalliance. **Name** : aopalliance. **Version** : 1.0. @@ -3708,12 +3724,12 @@ This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:53 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-comparable:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-comparable:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -4631,12 +4647,12 @@ This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-comparable-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-comparable-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -5420,12 +5436,12 @@ This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-entity:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-entity:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -6343,12 +6359,12 @@ This report was generated on **Mon Feb 24 14:20:26 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-entity-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-entity-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -6867,6 +6883,14 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -7124,12 +7148,12 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-marker:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-marker:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -7782,6 +7806,14 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -8047,12 +8079,12 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:54 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-marker-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-marker-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -8571,6 +8603,14 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -8828,12 +8868,12 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:55 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-message-group:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-message-group:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -9486,6 +9526,14 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -9751,12 +9799,12 @@ This report was generated on **Mon Feb 24 14:20:27 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:55 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-message-group-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-message-group-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -10275,6 +10323,14 @@ This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -10532,12 +10588,12 @@ This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:55 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-plugin-bundle:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-plugin-bundle:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : aopalliance. **Name** : aopalliance. **Version** : 1.0. @@ -11534,12 +11590,12 @@ This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:55 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-routing:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-routing:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -11583,6 +11639,10 @@ This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-Lice * **Project URL:** [https://github.com/googleapis/sdk-platform-java](https://github.com/googleapis/sdk-platform-java) * **License:** [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : com.google.auto.service. **Name** : auto-service-annotations. **Version** : 1.1.1. + * **Project URL:** [https://github.com/google/auto/tree/main/service](https://github.com/google/auto/tree/main/service) + * **License:** [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. * **Project URL:** [http://findbugs.sourceforge.net/](http://findbugs.sourceforge.net/) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -12516,12 +12576,12 @@ This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-routing-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-routing-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -13338,12 +13398,12 @@ This report was generated on **Mon Feb 24 14:20:28 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-signal:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-signal:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -13996,6 +14056,14 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -14261,12 +14329,12 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-signal-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-signal-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -14785,6 +14853,14 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -15042,12 +15118,12 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-uuid:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-uuid:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.fasterxml.jackson. **Name** : jackson-bom. **Version** : 2.15.3. @@ -15700,6 +15776,14 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -15965,12 +16049,12 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Wed Feb 26 18:12:56 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine.tools:spine-mc-java-uuid-tests:2.0.0-SNAPSHOT.264` +# Dependencies of `io.spine.tools:spine-mc-java-uuid-tests:2.0.0-SNAPSHOT.265` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -16489,6 +16573,14 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice 1. **Group** : org.apache.httpcomponents.core5. **Name** : httpcore5-h2. **Version** : 5.1.3. * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) +1. **Group** : org.apache.logging.log4j. **Name** : log4j-api. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + +1. **Group** : org.apache.logging.log4j. **Name** : log4j-core. **Version** : 2.20.0. + * **Project URL:** [https://www.apache.org/](https://www.apache.org/) + * **License:** [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.apiguardian. **Name** : apiguardian-api. **Version** : 1.1.2. * **Project URL:** [https://github.com/apiguardian-team/apiguardian](https://github.com/apiguardian-team/apiguardian) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -16746,4 +16838,4 @@ This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-Lice The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Mon Feb 24 14:20:29 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Wed Feb 26 18:12:57 WET 2025** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/CommandRoutingSetupITest.kt b/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/CommandRoutingSetupITest.kt new file mode 100644 index 000000000..6dae530af --- /dev/null +++ b/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/CommandRoutingSetupITest.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2025, 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.tools.mc.java.routing.tests + +import io.spine.given.home.Device +import io.spine.given.home.DeviceAggregate +import io.spine.given.home.DeviceId +import io.kotest.matchers.shouldBe +import io.spine.given.home.State +import io.spine.given.home.commands.addDevice +import io.spine.given.home.commands.setState +import io.spine.given.home.homeAutomation +import io.spine.testing.server.blackbox.BlackBox +import io.spine.testing.server.blackbox.assertEntity +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test + +@DisplayName("Generated `CommandRoutingSetup` should") +internal class CommandRoutingSetupITest { + + @Test + fun `apply generated routes`() { + BlackBox.from(homeAutomation()).use { context -> + val l1 = DeviceId.generate() + + context.receivesCommand( + addDevice { + device = l1 + name = "First Lamp" + } + ) + + // The first command is handled using the standard routing + // via the first command field. + var lamp = context.readState(l1) + lamp.state shouldBe State.OFF + + context.receivesCommand( + setState { + device = l1 + state = State.ON + } + ) + + // The command was handled via custom routing declared in the class. + lamp = context.readState(l1) + lamp.state shouldBe State.ON + } + } +} + +/** + * Reads the state of the [DeviceAggregate] with the given ID. + */ +private fun BlackBox.readState(id: DeviceId) = + assertEntity(id).actual()?.state() as Device diff --git a/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/EventRoutingSetupITest.kt b/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/EventRoutingSetupITest.kt index a874a6d67..80d7c4cd2 100644 --- a/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/EventRoutingSetupITest.kt +++ b/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/EventRoutingSetupITest.kt @@ -38,11 +38,18 @@ import io.spine.given.home.homeAutomation import io.spine.testing.server.blackbox.BlackBox import org.junit.jupiter.api.Test import io.spine.testing.server.blackbox.assertEntity +import org.junit.jupiter.api.DisplayName +@DisplayName("Generated `EventRoutingSetup` should") internal class EventRoutingSetupITest { + /** + * This test verifies that routing functions declared in the [RoomProjection] class + * effectively work because the state of the projection is expected after + * the dispatched events. + */ @Test - fun `loads event routing setup as a service`() { + fun `apply generated routes`() { BlackBox.from(homeAutomation()).use { context -> val r1 = RoomId.generate() val lamp = DeviceId.generate() diff --git a/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/StateRoutingSetupITest.kt b/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/StateRoutingSetupITest.kt new file mode 100644 index 000000000..8cd41b745 --- /dev/null +++ b/mc-java-routing-tests/src/test/kotlin/io/spine/tools/mc/java/routing/tests/StateRoutingSetupITest.kt @@ -0,0 +1,71 @@ +/* + * Copyright 2025, 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.tools.mc.java.routing.tests + +import io.kotest.matchers.shouldBe +import io.spine.given.home.Home +import io.spine.given.home.HomeProjection +import io.spine.given.home.HomeProjection.Companion.SINGLETON_ID +import io.spine.given.home.RoomId +import io.spine.given.home.events.roomAdded +import io.spine.given.home.homeAutomation +import io.spine.testing.server.blackbox.BlackBox +import io.spine.testing.server.blackbox.assertEntity +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test + +@DisplayName("Generated `StateRoutingSetup` should") +internal class StateRoutingSetupITest { + + @Test + fun `apply generated routes`() { + BlackBox.from(homeAutomation()).use { context -> + val r1 = RoomId.generate() + val r2 = RoomId.generate() + + context.receivesEvent( + roomAdded { + room = r1 + name = "Living Room" + } + ) + context.receivesEvent( + roomAdded { + room = r2 + name = "Bedroom" + } + ) + + val home = context.assertEntity(SINGLETON_ID) + .actual()?.state() as Home + + // This means that two `Room` instances were routed by the routing + // function directing all the updates to the singleton. + home.roomList.map { it.name } shouldBe listOf("Living Room", "Bedroom") + } + } +} diff --git a/mc-java-routing-tests/src/testFixtures/kotlin/io/spine/given/home/HomeAutomationContext.kt b/mc-java-routing-tests/src/testFixtures/kotlin/io/spine/given/home/HomeAutomationContext.kt index 9f79dffdb..79d530bff 100644 --- a/mc-java-routing-tests/src/testFixtures/kotlin/io/spine/given/home/HomeAutomationContext.kt +++ b/mc-java-routing-tests/src/testFixtures/kotlin/io/spine/given/home/HomeAutomationContext.kt @@ -26,27 +26,35 @@ package io.spine.given.home +import com.google.common.annotations.VisibleForTesting import io.spine.core.Subscribe +import io.spine.given.home.commands.AddDevice +import io.spine.given.home.commands.SetState +import io.spine.given.home.events.DeviceAdded import io.spine.given.home.events.DeviceMoved import io.spine.given.home.events.RoomAdded import io.spine.given.home.events.RoomEvent import io.spine.given.home.events.RoomRenamed +import io.spine.given.home.events.StateChanged +import io.spine.given.home.events.deviceAdded +import io.spine.given.home.events.stateChanged import io.spine.protobuf.isDefault import io.spine.server.BoundedContext +import io.spine.server.aggregate.Aggregate +import io.spine.server.aggregate.Apply +import io.spine.server.command.Assign import io.spine.server.entity.alter import io.spine.server.projection.Projection -import io.spine.server.projection.ProjectionRepository -import io.spine.server.route.EventRouting -import io.spine.server.route.setup.EventRoutingSetup import io.spine.server.route.Route -import io.spine.server.route.setup.StateRoutingSetup -import io.spine.server.route.StateUpdateRouting fun homeAutomation(): BoundedContext = BoundedContext.singleTenant("HomeAutomation") - .add(RoomProjectionRepository()) + .add(RoomProjection::class.java) + .add(DeviceAggregate::class.java) + .add(HomeProjection::class.java) .build() -public class RoomProjection : Projection() { +@VisibleForTesting +class RoomProjection : Projection() { @Subscribe internal fun on(e: RoomAdded) = alter { @@ -73,33 +81,67 @@ public class RoomProjection : Projection() { companion object { + /** + * The routing function accepting the interface. + */ @Route - @JvmStatic fun route(e: RoomEvent): RoomId = e.room + /** + * The routing function accepting the event class. + */ @Route - @JvmStatic fun routeMoved(e: DeviceMoved): Set = if (e.prevRoom.isDefault()) setOf(e.room) else setOf(e.prevRoom, e.room) } } -internal class RoomProjectionRepository : ProjectionRepository() { +@VisibleForTesting +class DeviceAggregate : Aggregate() { - override fun setupEventRouting(routing: EventRouting) { - super.setupEventRouting(routing) + @Assign + internal fun handle(c: AddDevice): DeviceAdded = + deviceAdded { device = c.device; name = c.name } - // Remove routs added via reflective class analysis. - routing.run { - remove() - remove() - } + @Assign + internal fun handle(c: SetState): StateChanged = + stateChanged { device = id(); current = c.state } + + @Apply + private fun event(e: DeviceAdded) = alter { + name = e.name + state = State.OFF + } + + @Apply + private fun event(e: StateChanged) = alter { + state = e.current + } + + companion object { + + @Route + fun command(c: SetState): DeviceId = c.device + } +} - EventRoutingSetup.apply(entityClass(), routing) +@VisibleForTesting +class HomeProjection : Projection() { + + @Subscribe + internal fun on(updated: Room) = alter { + val builder = roomBuilderList.find { b -> b.id == updated.id } + if (builder != null) { + builder.clear().mergeFrom(updated) + } else { + addRoom(updated) + } } - override fun setupStateRouting(routing: StateUpdateRouting) { - super.setupStateRouting(routing) - StateRoutingSetup.apply(entityClass(), routing) + companion object { + const val SINGLETON_ID = "OurHome" + + @Route + internal fun room(@Suppress("UNUSED_PARAMETER") r: Room): String = SINGLETON_ID } } diff --git a/mc-java-routing-tests/src/testFixtures/proto/given/home/commands.proto b/mc-java-routing-tests/src/testFixtures/proto/given/home/commands.proto index 5c77e41c3..92fa36e8b 100644 --- a/mc-java-routing-tests/src/testFixtures/proto/given/home/commands.proto +++ b/mc-java-routing-tests/src/testFixtures/proto/given/home/commands.proto @@ -54,6 +54,9 @@ message MoveDevice { } message SetState { - DeviceId device = 1; + // Normally the first field of a command is the ID of the target entity. + // We deliberately put another field so that a route function would be "useful" + // for obtaining the device ID from the `device` field which comes second. State state = 2 [(required) = true]; + DeviceId device = 1; } diff --git a/mc-java-routing/build.gradle.kts b/mc-java-routing/build.gradle.kts index b432ac88f..967abbd74 100644 --- a/mc-java-routing/build.gradle.kts +++ b/mc-java-routing/build.gradle.kts @@ -42,14 +42,18 @@ plugins { dependencies { ksp(AutoServiceKsp.processor) - compileOnlyApi(AutoService.annotations) + implementation(AutoService.annotations)?.because( + """ + We use the `@AutoService` annotation not only to annotate `RouteProcessorProvider` as + a service provider but also for annotating the generated code. + """.trimIndent() + ) implementation(kotlin("stdlib")) implementation(Ksp.symbolProcessingApi) implementation(KotlinPoet.ksp) implementation(CoreJava.server) implementation(project(":mc-java-base")) - testImplementation(AutoService.annotations) testImplementation(Kotest.assertions) testImplementation(KotlinCompileTesting.libKsp) testImplementation(Logging.testLib) diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommandRouteSignature.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommandRouteSignature.kt similarity index 98% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommandRouteSignature.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommandRouteSignature.kt index 0096930db..d031bb191 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommandRouteSignature.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommandRouteSignature.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSType diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommandRouteVisitor.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommandRouteVisitor.kt similarity index 82% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommandRouteVisitor.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommandRouteVisitor.kt index 03c5f2020..9dddae7c0 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommandRouteVisitor.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommandRouteVisitor.kt @@ -24,10 +24,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.squareup.kotlinpoet.ksp.toClassName +/** + * Creates a routing setup class for tuning + * [EventRouting][io.spine.server.route.CommandRouting] of a repository. + * + * The generated setup class will have the name after the pattern + * [<EntityClass>CommandRouting][classNameSuffix]. + * + * @see RouteVisitor + */ internal class CommandRouteVisitor( functions: List, environment: Environment @@ -52,8 +61,12 @@ internal class CommandRouteVisitor( } companion object { + + /** + * Processes the given route functions using [CommandRouteVisitor]. + */ fun process(qualified: List, environment: Environment) { - runVisitors(qualified) { functions -> + runVisitors(qualified, environment) { functions -> CommandRouteVisitor(functions, environment) } } diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommonChecks.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommonChecks.kt similarity index 65% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommonChecks.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommonChecks.kt index 4630def92..ef56a7a9d 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/CommonChecks.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/CommonChecks.kt @@ -24,20 +24,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.processing.KSPLogger import com.google.devtools.ksp.symbol.FunctionKind import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import com.google.devtools.ksp.symbol.Origin import com.google.devtools.ksp.symbol.Origin.JAVA import com.google.devtools.ksp.symbol.Origin.KOTLIN -import funRef import io.spine.server.entity.Entity -import io.spine.tools.mc.java.routing.proessor.RouteSignature.Companion.jvmStaticRef -import io.spine.tools.mc.java.routing.proessor.RouteSignature.Companion.routeRef -import msg +import io.spine.tools.mc.java.routing.processor.RouteSignature.Companion.routeRef /** * Runs general usage checks for this function declaration. @@ -103,6 +99,19 @@ private fun KSFunctionDeclaration.acceptsOneOrTwoParameters(logger: KSPLogger): return (!wrongNumber).toErrorCount() } +/** + * Obtains the entity class which declares this function. + * + * If the function is declared in a Kotlin companion object (which is the right way to declare + * routing functions in Kotlin), the function obtains the class enclosing the companion object. + * + * The function checks if the declaring class implements the [Entity] interface. + * If it does not, the error is logged using the logger of the [environment] pointing to + * this function declaration as the source of the error, and `null` is returned. + * + * @return The entity class which declares this routing function, or `null` if the class + * does not implement the [Entity] interface. + */ internal fun KSFunctionDeclaration.declaringClass(environment: Environment): EntityClass? { val parent = parentDeclaration!!.qualifiedName!! var declaringClass = environment.resolver.getClassDeclarationByName(parent)!! @@ -121,3 +130,49 @@ internal fun KSFunctionDeclaration.declaringClass(environment: Environment): Ent } return EntityClass(declaringClass, environment.entityInterface) } + +/** + * Checks if given [functions] do not have the same type as the first parameter. + * + * If duplicates are found they are [reported][KSPLogger.error], and the function returns `true`. + * + * @return `true` if duplicating route functions found, `false` otherwise. + */ +internal fun EntityClass.hasDuplicatedRoutes( + functions: List, + environment: Environment +): Boolean { + val logger = environment.logger + val nl = System.lineSeparator() + var found = false + // Group functions by the first parameter. + val grouped = functions.groupBy { fn -> fn.messageClass } + grouped.forEach { + var routes = it.value + if (routes.size <= 1) { + return@forEach + } + found = true + // Sort duplicates by line numbers. + routes = routes.sortedBy { fn -> fn.lineNumber } + + // The qualified message class to be mentioned once in the error message. + // The functions will have the simple name. + val messageType = routes[0].messageClass.canonicalName + + // List the duplicates. + val duplicates = routes.joinToString(nl) { fn -> + " * `${fn.asString(qualifiedParameters = false)}`" + } + logger.error( + "The class `$this` declares more than one route function" + + " for the same message class `$messageType`:$nl" + + duplicates + nl + + "Please have only one function per routed message class.", + // Give the last duplicate as the error pointer to be reported. + // This would allow the user to scroll back for the duplicate(s). + routes.last().decl + ) + } + return found +} diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EntityClass.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EntityClass.kt similarity index 73% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EntityClass.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EntityClass.kt index 7c41e6ea9..4a39dd660 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EntityClass.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EntityClass.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.ClassKind.CLASS import com.google.devtools.ksp.symbol.KSClassDeclaration @@ -32,16 +32,34 @@ import com.google.devtools.ksp.symbol.KSType import com.google.devtools.ksp.symbol.KSTypeArgument import com.google.devtools.ksp.symbol.KSTypeReference +/** + * Provides information about an entity class. + * + * @property decl The declaration of the class. + * @param entityInterface The type of the [io.spine.server.entity.Entity] + * interface for resolving generic parameters. + * This is a supportive parameter that we pass instead of [Environment] instance + * to narrow down the dependencies of this class. + */ internal class EntityClass( val decl: KSClassDeclaration, entityInterface: KSType ) { + /** + * Applies the given visitor to the class declaration. + */ fun accept(visitor: RouteVisitor<*>, data: Unit) { decl.accept(visitor, data) } + /** + * The type of the entity class resolved without generic parameters. + */ val type: KSType by lazy { decl.asStarProjectedType() } + /** + * The type of the entity identifiers as [KSTypeArgument]. + */ val idClassTypeArgument: KSTypeArgument by lazy { val asEntity = decl.superTypes.find { entityInterface.isAssignableFrom(it.resolve()) @@ -53,14 +71,23 @@ internal class EntityClass( asEntity.element!!.typeArguments.first() } + /** + * The reference to the ID class. + */ private val idClassReference: KSTypeReference by lazy { idClassTypeArgument.type!! } + /** + * The type of the entity identifiers. + */ val idClass: KSType by lazy { idClassReference.resolve() } + /** + * The class which this entity class extends. + */ fun superClass(): KSType { val found = decl.superTypes.find { val superType = it.resolve().declaration @@ -75,7 +102,10 @@ internal class EntityClass( return decl == other.decl } - override fun hashCode(): Int { - return decl.hashCode() - } + override fun hashCode(): Int = decl.hashCode() + + /** + * Obtains the qualified name of the entity class. + */ + override fun toString(): String = decl.qualifiedName!!.asString() } diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Environment.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Environment.kt similarity index 98% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Environment.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Environment.kt index 5fbbc4043..b56402903 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Environment.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Environment.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.KSPLogger diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EventRouteSignature.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EventRouteSignature.kt similarity index 98% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EventRouteSignature.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EventRouteSignature.kt index 55a4eaa38..4bf464d18 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EventRouteSignature.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EventRouteSignature.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSType diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EventRouteVisitor.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EventRouteVisitor.kt similarity index 62% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EventRouteVisitor.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EventRouteVisitor.kt index 1e06b13dc..b981ad42f 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/EventRouteVisitor.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/EventRouteVisitor.kt @@ -24,47 +24,27 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor - -import com.squareup.kotlinpoet.ksp.toClassName +package io.spine.tools.mc.java.routing.processor +/** + * Creates a routing setup class for tuning + * [EventRouting][io.spine.server.route.EventRouting] of a repository. + * + * The generated setup class will have the name after the pattern + * [<EntityClass>EventRouting][classNameSuffix]. + * + * @see MulticastRouteVisitor + */ internal class EventRouteVisitor( functions: List, environment: Environment -) : RouteVisitor( +) : MulticastRouteVisitor( environment.eventRoutingSetup, functions, environment ) { override val classNameSuffix: String = "EventRouting" - - /** - * Adds the entry in the routing setup function inside the [routingRunBlock]. - * - * For a multicast route it would be something like: - * ```kotlin - * route { e, c -> MyEntity.myRouteFun(e, c) } - * ``` - * For an unicast route it would be something like: - * ```kotlin - * unicast { e, c -> MyEntity.myRoutFun(e, c) } - * ``` - * If a route function does not accept context, the lambdas would have only the `e` parameter. - */ - override fun addRoute(fn: EventRouteFun) { - val params = if (fn.acceptsContext) "e, c" else "e" - val entryFn = if (fn.isUnicast) "unicast" else ROUTE_FUN_NAME - - routingRunBlock.add( - "%L<%T> { %L -> %T.%L(%L) }\n", - entryFn, - fn.messageClass, - params, - entityClass.type.toClassName(), - fn.decl.simpleName.asString(), - params - ) - } + override val messageParameterName: String = "e" companion object { @@ -72,7 +52,7 @@ internal class EventRouteVisitor( * Processes the given route functions using [EventRouteVisitor]. */ internal fun process(qualified: List, environment: Environment) { - runVisitors(qualified) { functions -> + runVisitors(qualified, environment) { functions -> EventRouteVisitor(functions, environment) } } diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Exts.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Exts.kt similarity index 98% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Exts.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Exts.kt index c28bff4ab..6b03eafbc 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Exts.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Exts.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.processing.Resolver import com.google.devtools.ksp.symbol.KSType diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/KSDeclarationExts.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSDeclarationExts.kt similarity index 96% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/KSDeclarationExts.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSDeclarationExts.kt index 30af5da6e..829d08905 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/KSDeclarationExts.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSDeclarationExts.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.KSDeclaration diff --git a/mc-java-routing/src/main/kotlin/KSFunctionDeclarationExts.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSFunctionDeclarationExts.kt similarity index 88% rename from mc-java-routing/src/main/kotlin/KSFunctionDeclarationExts.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSFunctionDeclarationExts.kt index 61ace9641..8824eec1a 100644 --- a/mc-java-routing/src/main/kotlin/KSFunctionDeclarationExts.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSFunctionDeclarationExts.kt @@ -24,10 +24,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +package io.spine.tools.mc.java.routing.processor + import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.Origin.JAVA import com.google.devtools.ksp.symbol.Origin.JAVA_LIB +/** + * Obtains the short name of the function. + * + * @returns just a name without braces. + */ +internal val KSFunctionDeclaration.shortName: String + get() = simpleName.getShortName() + /** * Selects either diagnostic message depending on * the [origin][KSFunctionDeclaration.origin] of the declaration. @@ -47,6 +57,6 @@ internal fun KSFunctionDeclaration.msg(kotlin: String, java: String): String = */ internal val KSFunctionDeclaration.funRef: String get() { - val shortRef = "`${simpleName.getShortName()}()`" + val shortRef = "`$shortName()`" return msg("function $shortRef", "method $shortRef") } diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/KSTypeExts.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSTypeExts.kt similarity index 97% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/KSTypeExts.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSTypeExts.kt index df4a81490..e07b59c41 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/KSTypeExts.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/KSTypeExts.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.ClassKind.INTERFACE import com.google.devtools.ksp.symbol.KSClassDeclaration diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/MulticastRouteVisitor.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/MulticastRouteVisitor.kt new file mode 100644 index 000000000..dee80b8fc --- /dev/null +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/MulticastRouteVisitor.kt @@ -0,0 +1,96 @@ +/* + * Copyright 2025, 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.tools.mc.java.routing.processor + +import com.google.common.annotations.VisibleForTesting +import com.squareup.kotlinpoet.ksp.toClassName +import io.spine.tools.mc.java.routing.processor.Environment.SetupType + +/** + * The base class for generators of the routing setup classes that + * serve [multicast][io.spine.server.route.Multicast] routing schemas. + * + * @param F The type of route functions handled by the visitor. + * + * @param setup The type of the routing setup class generated by this visitor. + * @param functions The route functions declared in the [entityClass]. + * @param environment The environment for code generation. + */ +internal abstract class MulticastRouteVisitor( + setup: SetupType, + functions: List, + environment: Environment +) : RouteVisitor(setup, functions, environment) { + + /** + * The name of the message parameter passed to the routing function in the generated code. + * + * Can be any string valid as a name for a Kotlin variable, but `"c"`, + * which is reserved for the second parameter. + */ + protected abstract val messageParameterName: String + + @VisibleForTesting + internal fun checkMessageParameterName() { + check(messageParameterName != "c") { + "The value of the `messageParameterName` property cannot be `c`." + + " This name is reserved for context parameters." + } + } + + /** + * Adds an entry for the given function [fn] in the routing + * [setup][io.spine.server.route.setup.RoutingSetup.setup] function + * inside the [routingRunBlock]. + * + * For a [multicast][io.spine.server.route.Multicast] route it would be something like: + * ```kotlin + * route { e, c -> MyEntity.myRouteFun(e, c) } + * ``` + * For an [unicast][io.spine.server.route.Unicast] route it would be something like: + * ```kotlin + * unicast { e, c -> MyEntity.myRoutFun(e, c) } + * ``` + * If a route function does not accept context, the lambdas would have only the `e` parameter. + */ + override fun addRoute(fn: F) { + checkMessageParameterName() + val p = messageParameterName + val params = if (fn.acceptsContext) "$p, c" else p + val entryFn = if (fn.isUnicast) UNICAST_FUN_NAME else ROUTE_FUN_NAME + + routingRunBlock.add( + "%L<%T> { %L -> %T.%L(%L) }\n", + entryFn, + fn.messageClass, + params, + entityClass.type.toClassName(), + fn.decl.simpleName.asString(), + params + ) + } +} diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Qualifier.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Qualifier.kt similarity index 82% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Qualifier.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Qualifier.kt index e283bedb4..8b2af3996 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/Qualifier.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/Qualifier.kt @@ -24,14 +24,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import io.spine.tools.mc.java.routing.proessor.RouteSignature.Companion.routeRef +import io.spine.tools.mc.java.routing.processor.RouteSignature.Companion.routeRef /** * The helper class which transforms the incoming sequence with [functions] into - * a list containing [CommandRouteFun] or [EventRouteFun]. + * a list containing [CommandRouteFun], [EventRouteFun], or [StateUpdateRouteFun]. * * If a function is not recognized to be one of these types, * the compilation terminates with an error. @@ -45,6 +45,16 @@ internal class Qualifier( private val eventRoutes = EventRouteSignature(environment) private val stateRoutes = StateUpdateRouteSignature(environment) + /** + * Transforms the incoming sequence of [KSFunctionDeclaration] instances + * into the list of [RouteFun] by analyzing their signatures. + * + * Each function goes through [common checks][KSFunctionDeclaration.commonChecks]. + * Failed checks are reported as errors via [Environment.logger]. + * + * If at least one error is detected, the function terminates with [IllegalStateException] + * after all the functions are checked. + */ fun run(): List { val result = mutableListOf() functions.forEach { fn -> diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteFun.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteFun.kt new file mode 100644 index 000000000..c386dd7d2 --- /dev/null +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteFun.kt @@ -0,0 +1,156 @@ +/* + * Copyright 2025, 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.tools.mc.java.routing.processor + +import com.google.devtools.ksp.symbol.FileLocation +import com.google.devtools.ksp.symbol.KSFunctionDeclaration +import com.google.devtools.ksp.symbol.KSType +import com.squareup.kotlinpoet.ClassName +import com.squareup.kotlinpoet.ksp.toClassName + +/** + * Provides information about a route function detected in the [declaringClass] + * + * @property decl The declaration of the function + * @property declaringClass The class that declares the function. + * @param parameters The parameter(s) of the function. + * If the [Pair.second] property is non-null the function accepts a context parameter. + * @param returnType The type returned by the function. + */ +internal sealed class RouteFun( + val decl: KSFunctionDeclaration, + val declaringClass: EntityClass, + parameters: Pair, + returnType: KSType +) { + /** + * The line number of the function declaration. + */ + val lineNumber: Int by lazy { + (decl.location as? FileLocation)?.lineNumber ?: 0 + } + + /** + * The type of the first parameter of the route function. + */ + val messageParameter: KSType = parameters.first + + /** + * The class name of the first parameter. + */ + val messageClass: ClassName = messageParameter.toClassName() + + /** + * Tells if the function accepts a context parameter. + */ + val acceptsContext: Boolean = parameters.second != null + + /** + * The class of the message context, if the function accepts the second parameter. + */ + private val contextClass: ClassName? by lazy { + parameters.second?.toClassName() + } + + /** + * Tells if the function returns one identifier rather than a set of identifiers. + */ + val isUnicast: Boolean = returnType.declaration.typeParameters.isEmpty() + + /** + * Obtains the name of the function with the types of its parameters. + * + * @param qualifiedParameters If `true` the parameter types will be fully qualified. + * Otherwise, simple names will be used for the parameter types. + */ + fun asString(qualifiedParameters: Boolean): String { + fun ClassName.name(): String = if (qualifiedParameters) canonicalName else simpleName + return buildString { + append(decl.shortName) + append("(") + append(messageClass.name()) + if (acceptsContext) { + append(", ") + append(contextClass!!.name()) + } + append(")") + } + } + + /** + * Gives the name of the function with fully qualified names for parameters. + */ + override fun toString(): String = asString(qualifiedParameters = true) + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as RouteFun + + if (decl != other.decl) return false + if (declaringClass != other.declaringClass) return false + + return true + } + + override fun hashCode(): Int { + var result = decl.hashCode() + result = 31 * result + declaringClass.hashCode() + return result + } +} + +/** + * The declaration of a route function for commands. + */ +internal class CommandRouteFun( + fn: KSFunctionDeclaration, + declaringClass: EntityClass, + parameters: Pair, + returnType: KSType +) : RouteFun(fn, declaringClass, parameters, returnType) + +/** + * The declaration of a route function for events. + */ +internal class EventRouteFun( + fn: KSFunctionDeclaration, + declaringClass: EntityClass, + parameters: Pair, + returnType: KSType +) : RouteFun(fn, declaringClass, parameters, returnType) + +/** + * The declaration of a route function for entity states. + */ +internal class StateUpdateRouteFun( + fn: KSFunctionDeclaration, + declaringClass: EntityClass, + parameters: Pair, + returnType: KSType +) : RouteFun(fn, declaringClass, parameters, returnType) diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteProcessor.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteProcessor.kt similarity index 98% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteProcessor.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteProcessor.kt index aa12781f6..00584332c 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteProcessor.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteProcessor.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.processing.CodeGenerator import com.google.devtools.ksp.processing.KSPLogger diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteProcessorProvider.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteProcessorProvider.kt similarity index 97% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteProcessorProvider.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteProcessorProvider.kt index c47fba0dd..f62b0cfe0 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteProcessorProvider.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteProcessorProvider.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.auto.service.AutoService import com.google.devtools.ksp.processing.SymbolProcessor diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteSignature.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteSignature.kt similarity index 96% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteSignature.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteSignature.kt index 6b36f969a..3cb9aaf3d 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteSignature.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteSignature.kt @@ -24,16 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSType import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper -import funRef import io.spine.core.SignalContext import io.spine.server.route.Route import io.spine.string.simply -import io.spine.tools.mc.java.routing.proessor.RouteSignature.Companion.qualify +import io.spine.tools.mc.java.routing.processor.RouteSignature.Companion.qualify import io.spine.type.KnownMessage /** @@ -151,7 +150,6 @@ internal sealed class RouteSignature( companion object { val routeRef by lazy { "`@${simply()}`" } - val jvmStaticRef by lazy { "`@${simply()}`" } fun qualify( functions: Sequence, diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteVisitor.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteVisitor.kt similarity index 64% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteVisitor.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteVisitor.kt index da4e5a3af..7f0a19619 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteVisitor.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/RouteVisitor.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.auto.service.AutoService import com.google.devtools.ksp.processing.Dependencies @@ -33,7 +33,6 @@ import com.google.devtools.ksp.symbol.KSFile import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSTypeArgument import com.google.devtools.ksp.symbol.KSVisitorVoid -import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FileSpec @@ -51,28 +50,85 @@ import com.squareup.kotlinpoet.ksp.writeTo import io.spine.server.entity.Entity import io.spine.string.Indent import io.spine.tools.mc.java.GeneratedAnnotation -import io.spine.tools.mc.java.routing.proessor.Environment.SetupType +import io.spine.tools.mc.java.routing.processor.Environment.SetupType +/** + * The base class for code generators implementing routing setup classes. + * + * The type of the generated setup class is determined by the [setup] property. + * The type of the generated route functions is specified by the generic parameter [F]. + * + * The visitor generates a class named after the class declaring routing function(s) + * using the pattern: [entityClass] + [classNameSuffix]. The class is generated + * in the same package with the [entityClass]. + * + * The generated class will be annotated with the [AutoService] annotation which + * would accept the interface implemented by the generated class as the argument for + * the annotation. E.g., [EventRoutingSetup][io.spine.server.route.setup.EventRoutingSetup] or + * [CommandRoutingSetup][io.spine.server.route.setup.CommandRoutingSetup]. + * The reference to this interface is passed as the value of + * the [cls][SetupType.cls] property of the [setup] parameter. + * + * @param F The type of route functions handled by the visitor. + * @property setup The type of the routing setup class generated by this visitor. + * @property functions The route functions declared in the [entityClass]. + * @property environment The environment for code generation. + */ internal sealed class RouteVisitor( - protected val setup: SetupType, + private val setup: SetupType, private val functions: List, - protected val environment: Environment, + protected val environment: Environment ) : KSVisitorVoid() { + /** + * The suffix added to the generated class. + */ protected abstract val classNameSuffix: String + /** + * The name of the package for the generated class. + */ private lateinit var packageName: String + + /** + * The file declaring the class with the routing functions. + */ private lateinit var originalFile: KSFile + /** + * The builder of the generated class. + */ protected lateinit var routingClass: TypeSpec.Builder + + /** + * The builder for the generated + * [setup][io.spine.server.route.setup.RoutingSetup.setup] function. + */ protected lateinit var setupFun: FunSpec.Builder + + /** + * The builder for the `run` block in the [setup][setupFun] function. + * + * The generated block will look like this: + * ```kotlin + * routing.run { + * // Route functions are added here. This comment will not be added. + * } + * ``` + */ protected lateinit var routingRunBlock: CodeBlock.Builder - val entityClass: EntityClass by lazy { + /** + * The class declaring route functions. + */ + protected val entityClass: EntityClass by lazy { val fn = functions.first() fn.declaringClass } + /** + * The type of the entity identifiers. + */ private val idClassTypeArgument: KSTypeArgument by lazy { entityClass.idClassTypeArgument } @@ -85,8 +141,7 @@ internal sealed class RouteVisitor( handleRouteFunctions() } - @OverridingMethodsMustInvokeSuper - protected open fun createClass(className: String) { + private fun createClass(className: String) { val generated = GeneratedAnnotation.forKotlinPoet() val autoService = AnnotationSpec.builder(AutoService::class) .addMember("%T::class", setup.cls) @@ -114,7 +169,7 @@ internal sealed class RouteVisitor( .build() /** - * Adds the method that overrides [io.spine.server.route.RoutingSetup.entityClass]. + * Adds the method that overrides [io.spine.server.route.setup.RoutingSetup.entityClass]. */ private fun addEntityClassFunction() { val entityType = Entity::class.asClassName().parameterizedBy( @@ -153,6 +208,9 @@ internal sealed class RouteVisitor( .beginControlFlow("%N.run", paramName) } + /** + * The callback to add a route function to the routing schema. + */ protected abstract fun addRoute(fn: F) private fun closeSetupFunction() { @@ -161,7 +219,7 @@ internal sealed class RouteVisitor( routingClass.addFunction(setupFun.build()) } - fun writeFile() { + private fun writeFile() { val cls = routingClass.build() val code = FileSpec.builder(packageName, cls.name!!) .indent(Indent.defaultJavaIndent.value) @@ -176,11 +234,26 @@ internal sealed class RouteVisitor( /** * The name of the inline extension functions for classes extending * [MessageRouting][io.spine.server.route.MessageRouting] which are used in - * the generated code of [RoutingSetup][io.spine.server.route.RoutingSetup] classes. + * the generated code of [RoutingSetup][io.spine.server.route.setup.RoutingSetup] classes. */ - internal const val ROUTE_FUN_NAME: String = "route" + const val ROUTE_FUN_NAME: String = "route" - internal fun process( + /** + * The name of the inline extension function for classing extending + * [MessageRouting][io.spine.server.route.MessageRouting] which are used in + * the generated code of [RoutingSetup][io.spine.server.route.setup.RoutingSetup] classes + * for returning only [one entity identifier][io.spine.server.route.Unicast]. + */ + const val UNICAST_FUN_NAME: String = "unicast" + + /** + * Runs all the visitors through the given sequence of found functions. + * + * @see CommandRouteVisitor + * @see EventRouteVisitor + * @see StateUpdateRouteVisitor + */ + fun process( allValid: Sequence, environment: Environment ) { @@ -190,16 +263,39 @@ internal sealed class RouteVisitor( StateUpdateRouteVisitor.process(qualified, environment) } - internal inline fun , reified F : RouteFun> runVisitors( - qualified: List, + /** + * Runs a visitor through the list of given functions. + * + * The visitor runs only through a sub-list of functions containing only + * instances of the generic parameter [F] of this function. + * For example, a [CommandRouteVisitor] ([V]) will only run + * through [CommandRouteFun] ([F]) instances. + * + * The function also performs the check for + * [duplicated route functions][EntityClass.hasDuplicatedRoutes] per declaring class. + * If such duplicates are found, errors will be logged and all the functions of + * the declaring class will not be processed by the visitor. + * + * @param V The type of the [RouteVisitor] used during the traversal. + * @param F The type of the [RouteFun] processed by the visitor. + * @param allFunctions All the routing functions found by the annotation processor and + * [transformed][Qualifier] into [RouteFun] instances. + * @param environment The environment of the code generation. + * @param createVisitor The function to create an instance of the visitor class. + */ + inline fun , reified F : RouteFun> runVisitors( + allFunctions: List, + environment: Environment, createVisitor: (List) -> V ) { - val routing = qualified.filterIsInstance() + val routing = allFunctions.filterIsInstance() val grouped = routing.groupByClasses() grouped.forEach { (declaringClass, functions) -> + if (!declaringClass.hasDuplicatedRoutes(functions, environment)) { val v = createVisitor(functions) - declaringClass.accept(v, Unit) - v.writeFile() + declaringClass.accept(v, Unit) + v.writeFile() + } } } } diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/StateUpdateRouteSignature.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/StateUpdateRouteSignature.kt similarity index 97% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/StateUpdateRouteSignature.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/StateUpdateRouteSignature.kt index f333d2aa0..56e804368 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/StateUpdateRouteSignature.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/StateUpdateRouteSignature.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor import com.google.devtools.ksp.symbol.KSFunctionDeclaration import com.google.devtools.ksp.symbol.KSType diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/StateUpdateRouteVisitor.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/StateUpdateRouteVisitor.kt similarity index 73% rename from mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/StateUpdateRouteVisitor.kt rename to mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/StateUpdateRouteVisitor.kt index 78100869a..2a4ad9db3 100644 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/StateUpdateRouteVisitor.kt +++ b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/processor/StateUpdateRouteVisitor.kt @@ -24,26 +24,38 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing.proessor +package io.spine.tools.mc.java.routing.processor +/** + * Creates a routing setup class for tuning + * [StateUpdateRouting][io.spine.server.route.StateUpdateRouting] of a repository. + * + * The generated setup class will have the name after the pattern + * [<EntityClass>StateUpdateRouting][classNameSuffix]. + * + * @see MulticastRouteVisitor + */ internal class StateUpdateRouteVisitor( functions: List, environment: Environment -) : RouteVisitor( +) : MulticastRouteVisitor( environment.stateRoutingSetup, functions, environment ) { - override val classNameSuffix: String = "StateUpdateRouting" - - override fun addRoute(fn: StateUpdateRouteFun) { - //TODO:2025-01-22:alexander.yevsyukov: Implement. - } + override val messageParameterName: String = "s" companion object { + + /** + * Processes the given route functions using [StateUpdateRouteVisitor]. + */ fun process(qualified: List, environment: Environment) { - runVisitors(qualified) { functions -> + runVisitors( + qualified, + environment + ) { functions -> StateUpdateRouteVisitor(functions, environment) } } diff --git a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteFun.kt b/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteFun.kt deleted file mode 100644 index 71e0a49bb..000000000 --- a/mc-java-routing/src/main/kotlin/io/spine/tools/mc/java/routing/proessor/RouteFun.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2025, 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.tools.mc.java.routing.proessor - -import com.google.devtools.ksp.symbol.KSFunctionDeclaration -import com.google.devtools.ksp.symbol.KSType -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.ksp.toClassName - -internal sealed class RouteFun( - val decl: KSFunctionDeclaration, - val declaringClass: EntityClass, - parameters: Pair, - returnType: KSType -) { - val messageParameter: KSType = parameters.first - val messageClass: ClassName = messageParameter.toClassName() - val acceptsContext: Boolean = parameters.second != null - val isUnicast: Boolean = returnType.declaration.typeParameters.isEmpty() -} - -internal class CommandRouteFun( - fn: KSFunctionDeclaration, - declaringClass: EntityClass, - parameters: Pair, - returnType: KSType -) : RouteFun(fn, declaringClass, parameters, returnType) - -internal class EventRouteFun( - fn: KSFunctionDeclaration, - declaringClass: EntityClass, - parameters: Pair, - returnType: KSType -) : RouteFun(fn, declaringClass, parameters, returnType) - -internal class StateUpdateRouteFun( - fn: KSFunctionDeclaration, - declaringClass: EntityClass, - parameters: Pair, - returnType: KSType -) : RouteFun(fn, declaringClass, parameters, returnType) diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/JavaRouteErrorSpec.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/JavaRouteErrorSpec.kt similarity index 98% rename from mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/JavaRouteErrorSpec.kt rename to mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/JavaRouteErrorSpec.kt index 7ccdb67b0..782507a49 100644 --- a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/JavaRouteErrorSpec.kt +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/JavaRouteErrorSpec.kt @@ -29,7 +29,7 @@ "MissingPackageInfo" /* don't need them for these tests. */ ) -package io.spine.tools.mc.java.routing +package io.spine.tools.mc.java.routing.processor import com.tschuchort.compiletesting.KotlinCompilation.ExitCode.COMPILATION_ERROR import io.kotest.matchers.shouldBe @@ -41,7 +41,7 @@ import io.spine.server.entity.Entity import io.spine.server.procman.ProcessManager import io.spine.server.projection.Projection import io.spine.string.simply -import io.spine.tools.mc.java.routing.proessor.RouteSignature.Companion.routeRef +import io.spine.tools.mc.java.routing.processor.RouteSignature.Companion.routeRef import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/JavaRouteSpec.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/JavaRouteSpec.kt similarity index 98% rename from mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/JavaRouteSpec.kt rename to mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/JavaRouteSpec.kt index ba5d29db1..c7c93131c 100644 --- a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/JavaRouteSpec.kt +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/JavaRouteSpec.kt @@ -29,7 +29,7 @@ "MissingPackageInfo" /* don't need them for these tests. */ ) -package io.spine.tools.mc.java.routing +package io.spine.tools.mc.java.routing.processor import com.tschuchort.compiletesting.KotlinCompilation.ExitCode import io.kotest.matchers.shouldBe diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/KotlinRouteErrorSpec.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/KotlinRouteErrorSpec.kt similarity index 71% rename from mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/KotlinRouteErrorSpec.kt rename to mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/KotlinRouteErrorSpec.kt index 470b9b49d..c2b471cc6 100644 --- a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/KotlinRouteErrorSpec.kt +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/KotlinRouteErrorSpec.kt @@ -29,13 +29,14 @@ "MissingPackageInfo" /* don't need them for these tests. */ ) -package io.spine.tools.mc.java.routing +package io.spine.tools.mc.java.routing.processor import com.tschuchort.compiletesting.KotlinCompilation.ExitCode import com.tschuchort.compiletesting.KotlinCompilation.ExitCode.COMPILATION_ERROR import io.kotest.matchers.shouldBe import io.kotest.matchers.string.shouldContain -import io.spine.tools.mc.java.routing.proessor.RouteSignature.Companion.routeRef +import io.kotest.matchers.string.shouldNotContain +import io.spine.tools.mc.java.routing.processor.RouteSignature.Companion.routeRef import org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi import org.junit.jupiter.api.DisplayName import org.junit.jupiter.api.Test @@ -108,6 +109,47 @@ internal class KotlinRouteErrorSpec : RouteCompilationTest() { } } + private val duplicatedRoutes = kotlinFile("DuplicatedRoutes", """ + package io.spine.given.devices + + import io.spine.core.EventContext + import io.spine.given.devices.events.StatusReported + import io.spine.given.devices.events.DeviceRegistered + import io.spine.server.projection.Projection + import io.spine.server.route.Route + + class DuplicatedRoutes : Projection() { + + companion object { + @Route fun route(e: StatusReported): DeviceId = event.getDevice() + @Route fun route(e: DeviceRegistered): DeviceId = event.getDevice() + @Route fun routeAgain(e: StatusReported, ctx: EventContext): DeviceId = + event.getDevice() + } + } + """.trimIndent()) + + @Test + fun `when two or more route functions accept the same message type`() { + compilation.apply { + sources = listOf(duplicatedRoutes) + } + + val result = compilation.compileSilently() + + result.exitCode shouldBe COMPILATION_ERROR + result.messages.let { + it shouldContain "The class `io.spine.given.devices.DuplicatedRoutes` declares more" + + " than one route function for the same message class" + + " `io.spine.given.devices.events.StatusReported`:" + it shouldContain "`route(StatusReported)`" + it shouldContain "`routeAgain(StatusReported, EventContext)`" + it shouldContain "Please have only one function per routed message class." + // The route for this event is not duplicated. + it shouldNotContain "DeviceRegistered" + } + } + /** * Correct routing method. */ diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/MulticastRouteVisitorSpec.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/MulticastRouteVisitorSpec.kt new file mode 100644 index 000000000..a21eb62df --- /dev/null +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/MulticastRouteVisitorSpec.kt @@ -0,0 +1,52 @@ +/* + * Copyright 2025, 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.tools.mc.java.routing.processor + +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +@DisplayName("`MulticastRouteVisitor` should") +internal class MulticastRouteVisitorSpec { + + @Test + fun `prohibit 'c' as the message parameter name`() { + assertThrows { + StubVisitor("c", "SomeSuffix").checkMessageParameterName() + } + } +} + +private class StubVisitor( + override val messageParameterName: String, + override val classNameSuffix: String, +) : MulticastRouteVisitor( + stubEnvironment.eventRoutingSetup, + listOf(), + stubEnvironment +) + diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/RouteCompilationTest.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/RouteCompilationTest.kt similarity index 96% rename from mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/RouteCompilationTest.kt rename to mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/RouteCompilationTest.kt index 70244b8e4..5c7e45c93 100644 --- a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/RouteCompilationTest.kt +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/RouteCompilationTest.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing +package io.spine.tools.mc.java.routing.processor import com.google.auto.service.AutoService import com.google.protobuf.MessageOrBuilder @@ -35,7 +35,6 @@ import io.spine.core.EventContext import io.spine.given.devices.Device import io.spine.logging.testing.ConsoleTap import io.spine.server.route.Route -import io.spine.tools.mc.java.routing.proessor.RouteProcessorProvider import io.spine.validate.ValidatingBuilder import kotlin.collections.plus import org.junit.jupiter.api.BeforeAll diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/Stubs.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/Stubs.kt new file mode 100644 index 000000000..20bdb0b87 --- /dev/null +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/Stubs.kt @@ -0,0 +1,205 @@ +/* + * Copyright 2025, 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.tools.mc.java.routing.processor + +import com.google.devtools.ksp.KspExperimental +import com.google.devtools.ksp.processing.CodeGenerator +import com.google.devtools.ksp.processing.Dependencies +import com.google.devtools.ksp.processing.KSBuiltIns +import com.google.devtools.ksp.processing.KSPLogger +import com.google.devtools.ksp.processing.Resolver +import com.google.devtools.ksp.symbol.KSAnnotated +import com.google.devtools.ksp.symbol.KSClassDeclaration +import com.google.devtools.ksp.symbol.KSDeclaration +import com.google.devtools.ksp.symbol.KSDeclarationContainer +import com.google.devtools.ksp.symbol.KSFile +import com.google.devtools.ksp.symbol.KSFunctionDeclaration +import com.google.devtools.ksp.symbol.KSName +import com.google.devtools.ksp.symbol.KSNode +import com.google.devtools.ksp.symbol.KSPropertyAccessor +import com.google.devtools.ksp.symbol.KSPropertyDeclaration +import com.google.devtools.ksp.symbol.KSType +import com.google.devtools.ksp.symbol.KSTypeArgument +import com.google.devtools.ksp.symbol.KSTypeReference +import com.google.devtools.ksp.symbol.Modifier +import com.google.devtools.ksp.symbol.Variance +import java.io.File +import java.io.OutputStream + +/** + * A stub instance of [Environment] which can be used only as a parameter for no-op visitors. + */ +internal val stubEnvironment = Environment(NotResolver(), NotLogger(), NotCodeGenerator()) + +private fun notImplemented(): Nothing = TODO("Not implemented.") + +/** + * The stub implementation of [Resolver] which throws [NotImplementedError] from all functions. + */ +@Suppress("TooManyFunctions") +private class NotResolver : Resolver { + + override val builtIns: KSBuiltIns + get() = notImplemented() + + override fun createKSTypeReferenceFromKSType(type: KSType): KSTypeReference = notImplemented() + + @KspExperimental + override fun effectiveJavaModifiers(declaration: KSDeclaration): Set = + notImplemented() + + override fun getAllFiles(): Sequence = notImplemented() + + override fun getClassDeclarationByName(name: KSName): KSClassDeclaration? = notImplemented() + + @KspExperimental + override fun getDeclarationsFromPackage(packageName: String): Sequence = + notImplemented() + + @KspExperimental + override fun getDeclarationsInSourceOrder( + container: KSDeclarationContainer + ): Sequence = notImplemented() + + override fun getFunctionDeclarationsByName( + name: KSName, + includeTopLevel: Boolean + ): Sequence = notImplemented() + + @KspExperimental + override fun getJavaWildcard(reference: KSTypeReference): KSTypeReference = notImplemented() + + @KspExperimental + override fun getJvmCheckedException(function: KSFunctionDeclaration): Sequence = + notImplemented() + + @KspExperimental + override fun getJvmCheckedException(accessor: KSPropertyAccessor): Sequence = + notImplemented() + + @KspExperimental + override fun getJvmName(declaration: KSFunctionDeclaration): String? = notImplemented() + + @KspExperimental + override fun getJvmName(accessor: KSPropertyAccessor): String? = notImplemented() + + override fun getKSNameFromString(name: String): KSName = notImplemented() + + override fun getNewFiles(): Sequence = notImplemented() + + @KspExperimental + override fun getOwnerJvmClassName(declaration: KSFunctionDeclaration): String? = + notImplemented() + + @KspExperimental + override fun getOwnerJvmClassName(declaration: KSPropertyDeclaration): String? = + notImplemented() + + override fun getPropertyDeclarationByName( + name: KSName, + includeTopLevel: Boolean + ): KSPropertyDeclaration? = notImplemented() + + override fun getSymbolsWithAnnotation( + annotationName: String, + inDepth: Boolean + ): Sequence = notImplemented() + + override fun getTypeArgument(typeRef: KSTypeReference, variance: Variance): KSTypeArgument = + notImplemented() + + @KspExperimental + override fun isJavaRawType(type: KSType): Boolean = notImplemented() + + @KspExperimental + override fun mapJavaNameToKotlin(javaName: KSName): KSName? = notImplemented() + + @KspExperimental + override fun mapKotlinNameToJava(kotlinName: KSName): KSName? = notImplemented() + + @KspExperimental + override fun mapToJvmSignature(declaration: KSDeclaration): String? = notImplemented() + + override fun overrides(overrider: KSDeclaration, overridee: KSDeclaration): Boolean = + notImplemented() + + override fun overrides( + overrider: KSDeclaration, + overridee: KSDeclaration, + containingClass: KSClassDeclaration + ): Boolean = notImplemented() +} + +/** + * The stub implementation of [KSPLogger] which throws [NotImplementedError] from all functions. + */ +private class NotLogger : KSPLogger { + override fun error(message: String, symbol: KSNode?): Unit = notImplemented() + override fun exception(e: Throwable): Unit = notImplemented() + override fun info(message: String, symbol: KSNode?): Unit = notImplemented() + override fun logging(message: String, symbol: KSNode?): Unit = notImplemented() + override fun warn(message: String, symbol: KSNode?): Unit = notImplemented() +} + +/** + * The stub implementation of [CodeGenerator] which throws [NotImplementedError] from all functions. + */ +private class NotCodeGenerator : CodeGenerator { + + override val generatedFile: Collection + get() = notImplemented() + + override fun associate( + sources: List, + packageName: String, + fileName: String, + extensionName: String + ): Unit = notImplemented() + + override fun associateByPath(sources: List, path: String, extensionName: String): Unit = + notImplemented() + + override fun associateWithClasses( + classes: List, + packageName: String, + fileName: String, + extensionName: String + ): Unit = notImplemented() + + override fun createNewFile( + dependencies: Dependencies, + packageName: String, + fileName: String, + extensionName: String + ): OutputStream = notImplemented() + + override fun createNewFileByPath( + dependencies: Dependencies, + path: String, + extensionName: String + ): OutputStream = notImplemented() +} diff --git a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/TestExts.kt b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/TestExts.kt similarity index 98% rename from mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/TestExts.kt rename to mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/TestExts.kt index 4f5510576..3370041ba 100644 --- a/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/TestExts.kt +++ b/mc-java-routing/src/test/kotlin/io/spine/tools/mc/java/routing/processor/TestExts.kt @@ -24,7 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.tools.mc.java.routing +package io.spine.tools.mc.java.routing.processor import com.tschuchort.compiletesting.KotlinCompilation import com.tschuchort.compiletesting.SourceFile diff --git a/pom.xml b/pom.xml index 76f23cfda..841152690 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine.tools mc-java -2.0.0-SNAPSHOT.264 +2.0.0-SNAPSHOT.265 2015 @@ -56,13 +56,13 @@ all modules and does not describe the project structure per-subproject. io.spine protodata - 0.92.7 + 0.92.9 compile io.spine spine-base - 2.0.0-SNAPSHOT.242 + 2.0.0-SNAPSHOT.244 compile @@ -86,13 +86,13 @@ all modules and does not describe the project structure per-subproject. io.spine.protodata protodata-java - 0.92.7 + 0.92.9 compile io.spine.protodata protodata-params - 0.92.7 + 0.92.9 compile @@ -116,13 +116,13 @@ all modules and does not describe the project structure per-subproject. io.spine.validation spine-validation-configuration - 2.0.0-SNAPSHOT.193 + 2.0.0-SNAPSHOT.195 compile io.spine.validation spine-validation-java-runtime - 2.0.0-SNAPSHOT.193 + 2.0.0-SNAPSHOT.195 compile @@ -188,7 +188,7 @@ all modules and does not describe the project structure per-subproject. io.spine.protodata protodata-testlib - 0.92.7 + 0.92.9 test @@ -335,12 +335,12 @@ all modules and does not describe the project structure per-subproject. io.spine.protodata protodata-fat-cli - 0.92.6 + 0.92.9 io.spine.protodata protodata-protoc - 0.92.6 + 0.92.9 io.spine.tools @@ -355,18 +355,18 @@ all modules and does not describe the project structure per-subproject. io.spine.tools spine-mc-java-checks - 2.0.0-SNAPSHOT.263 + 2.0.0-SNAPSHOT.264 provided io.spine.tools spine-mc-java-plugins - 2.0.0-SNAPSHOT.263 + 2.0.0-SNAPSHOT.264 io.spine.validation spine-validation-java-bundle - 2.0.0-SNAPSHOT.193 + 2.0.0-SNAPSHOT.195 net.sourceforge.pmd diff --git a/version.gradle.kts b/version.gradle.kts index 5b7dc1c0c..dbb72f541 100644 --- a/version.gradle.kts +++ b/version.gradle.kts @@ -31,5 +31,5 @@ * * For versions of Spine-based dependencies please see [io.spine.internal.dependency.spine]. */ -val mcJavaVersion by extra("2.0.0-SNAPSHOT.264") +val mcJavaVersion by extra("2.0.0-SNAPSHOT.265") val versionToPublish by extra(mcJavaVersion)