Skip to content

Commit 9bb9340

Browse files
Merge pull request #65 from SpineEventEngine/apply-validation-gradle-plugin
Apply Validation Gradle Plugin
2 parents 72dbfb2 + f731bdb commit 9bb9340

File tree

27 files changed

+159
-222
lines changed

27 files changed

+159
-222
lines changed

annotation/src/test/kotlin/io/spine/tools/core/jvm/annotation/ApiAnnotationsPluginIgTest.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,40 +69,41 @@ import org.junit.jupiter.api.io.TempDir
6969
* [Internal] or [SPI].
7070
*
7171
* The subject of test is [io.spine.tools.core.annotation.ApiAnnotationsPlugin] which is
72-
* a plugin to ProtoData. We test the plugin as a part of the Gradle build performed by
72+
* a plugin to Spine Compiler. We test the plugin as a part of the Gradle build performed by
7373
* the CoreJvm Compiler Gradle plugin.
7474
*
7575
* The test project is located in `resources/annotator-plugin-test` directory.
7676
*
77-
* ### Enabling remote debugging for ProtoData CLI
78-
* Since ProtoData launches the code generation in a separate JVM, it is not possible to debug
77+
* ### Enabling remote debugging for the Compiler CLI
78+
* Since the Compiler launches the code generation in a separate JVM, it is not possible to debug
7979
* it directly in an IDE. To debug the code generation, perform the following steps:
8080
* 1. Open the resource file `resources/annotator-plugin-test/build.gradle.kts`.
8181
* 2. Find the `debugOptions` block.
8282
* 3. Set the value of the `enabled` property to `true`. Pay attention to the fact that when
83-
* enabled, the ProtoData CLI process will be suspended until a debugger is attached.
83+
* enabled, the Compiler CLI process will be suspended until a debugger is attached.
8484
*
8585
* ### Creating a remote debugging configuration in IDEA
86-
* Check or create `LaunchProtoData Remote Debug` Run/Debug configuration is available in IDEA:
86+
* Check or create `LaunchSpineCompiler Remote Debug` Run/Debug configuration is available in IDEA:
8787
* 1. Open the Run/Debug configuration window.
88-
* 2. Under "Remote JVM Debug" on the left, check if the `LaunchProtoData Remote Debug` is
88+
* 2. Under "Remote JVM Debug" on the left, check if the `LaunchSpineCompiler Remote Debug` is
8989
* present, if not, create it via the "+" button at the top left of the dialog.
9090
* 3. Under "Debugger mode" select "Attach to remote JVM".
9191
* 4. Under "Host" enter `localhost`.
9292
* 5. Under "Port" enter `5566`.
9393
* 6. Under "Use module classpath" selection `io.spine.tools.mc-java-annotations.test`.
9494
*
9595
* ### Starting debugging session
96-
* 1. Put a breakpoint on `project.executeTask(launchProtoData)` in the `AnnotatorPluginSpec`.
96+
* 1. Put a breakpoint on `project.executeTask(launchSpineCompile)` in the `AnnotatorPluginSpec`.
9797
* 2. Run "Debug 'AnnotatorPluginSpec'" configuration.
98-
* 3. Once the breakpoint is reached, hit F8 or F9 to run the `launchProtoData` task.
98+
* 3. Once the breakpoint is reached, hit F8 or F9 to run the `launchSpineCompile` task.
9999
* It would take several seconds, depending on the performance of your workstation.
100100
* The task will be suspended until the debugger is attached.
101101
* 4. Once the task is suspended, put a breakpoint in the place of interest of your
102-
* [Plugin] or [Renderer] code, which is called by ProtoData.
103-
* 5. Run the "LaunchProtoData Remote Debug" configuration. You should see a console message
102+
* [io.spine.tools.compiler.plugin.Plugin] or [io.spine.tools.compiler.render.Renderer] code,
103+
* which is called by the Compiler.
104+
* 5. Run the "LaunchSpineCompile Remote Debug" configuration. You should see a console message
104105
* about attaching to a process. If attaching to a process fails, it could mean that
105-
* ProtoData CLI has not been started yet. Repeat the attempt in a few seconds.
106+
* the Compiler CLI has not been started yet. Repeat the attempt in a few seconds.
106107
*/
107108
@DisplayName("`ApiAnnotationsPlugin` should")
108109
internal class ApiAnnotationsPluginIgTest {

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ buildscript {
8080
"${compiler.module}:${compiler.dogfoodingVersion}",
8181
compiler.api,
8282
"${validation.runtimeModule}:${validation.version}",
83-
"${validation.runtimeModule}:${validation.version}"
83+
"${validation.runtimeModule}:${validation.version}",
84+
"io.spine.validation:spine-validation-java-runtime:2.0.0-SNAPSHOT.360"
8485
)
8586
}
8687
}

buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ package io.spine.dependency.local
3333
*/
3434
@Suppress("ConstPropertyName", "unused")
3535
object Base {
36-
const val version = "2.0.0-SNAPSHOT.382"
37-
const val versionForBuildScript = "2.0.0-SNAPSHOT.382"
36+
const val version = "2.0.0-SNAPSHOT.383"
37+
const val versionForBuildScript = "2.0.0-SNAPSHOT.383"
3838
const val group = Spine.group
39-
const val artifact = "spine-base"
40-
const val lib = "$group:$artifact:$version"
41-
const val format = "$group:spine-format:$version"
42-
const val libForBuildScript = "$group:$artifact:$versionForBuildScript"
43-
const val annotations = "$group:spine-annotations:$version"
39+
private const val prefix = "spine"
40+
const val libModule = "$prefix-base"
41+
const val lib = "$group:$libModule:$version"
42+
const val libForBuildScript = "$group:$libModule:$versionForBuildScript"
43+
const val annotations = "$group:$prefix-annotations:$version"
44+
const val environment = "$group:$prefix-environment:$version"
45+
const val format = "$group:$prefix-format:$version"
4446
}

buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
package io.spine.dependency.local
2828

29+
import io.spine.dependency.Dependency
30+
2931
/**
3032
* Dependencies on the Spine Compiler modules.
3133
*
@@ -56,9 +58,9 @@ package io.spine.dependency.local
5658
"ConstPropertyName" /* We use custom convention for artifact properties. */,
5759
"MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */,
5860
)
59-
object Compiler {
61+
object Compiler : Dependency() {
6062
const val pluginGroup = Spine.group
61-
const val group = "io.spine.tools"
63+
override val group = "io.spine.tools"
6264
const val pluginId = "io.spine.compiler"
6365

6466
/**
@@ -69,8 +71,8 @@ object Compiler {
6971
/**
7072
* The version of the Compiler dependencies.
7173
*/
72-
val version: String
73-
private const val fallbackVersion = "2.0.0-SNAPSHOT.034"
74+
override val version: String
75+
private const val fallbackVersion = "2.0.0-SNAPSHOT.035"
7476

7577
/**
7678
* The distinct version of the Compiler used by other build tools.
@@ -79,7 +81,7 @@ object Compiler {
7981
* transitive dependencies, this is the version used to build the project itself.
8082
*/
8183
val dogfoodingVersion: String
82-
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.030"
84+
private const val fallbackDfVersion = "2.0.0-SNAPSHOT.035"
8385

8486
/**
8587
* The artifact for the Compiler Gradle plugin.
@@ -129,6 +131,9 @@ object Compiler {
129131
val testlib
130132
get() = "$group:compiler-testlib:$version"
131133

134+
override val modules: List<String>
135+
get() = listOf(api, backend, params, protocPlugin, gradleApi, cliApi, jvm, fatCli, testlib)
136+
132137
/**
133138
* An env variable storing a custom [version].
134139
*/

buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typealias CoreJava = CoreJvm
3838
@Suppress("ConstPropertyName", "unused")
3939
object CoreJvm {
4040
const val group = Spine.group
41-
const val version = "2.0.0-SNAPSHOT.356"
41+
const val version = "2.0.0-SNAPSHOT.358"
4242

4343
const val coreArtifact = "spine-core"
4444
const val clientArtifact = "spine-client"

buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ object CoreJvmCompiler {
4646
/**
4747
* The version used to in the build classpath.
4848
*/
49-
const val dogfoodingVersion = "2.0.0-SNAPSHOT.035"
49+
const val dogfoodingVersion = "2.0.0-SNAPSHOT.040"
5050

5151
/**
5252
* The version to be used for integration tests.
5353
*/
54-
const val version = "2.0.0-SNAPSHOT.035"
54+
const val version = "2.0.0-SNAPSHOT.040"
5555

5656
/**
5757
* The ID of the Gradle plugin.

buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
package io.spine.dependency.local
2828

2929
/**
30-
* Dependencies on smaller Spine modules.
30+
* Defines Maven groups for the Spine SDK artifacts.
3131
*/
3232
@Suppress("unused", "ConstPropertyName")
3333
object Spine {

buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@ object Validation {
3636
/**
3737
* The version of the Validation library artifacts.
3838
*/
39-
const val version = "2.0.0-SNAPSHOT.360"
39+
const val version = "2.0.0-SNAPSHOT.375"
4040

4141
/**
4242
* The last version of Validation compatible with ProtoData.
4343
*/
4444
const val pdCompatibleVersion = "2.0.0-SNAPSHOT.342"
4545

46-
const val group = "io.spine.validation"
47-
private const val prefix = "spine-validation"
46+
const val group = Spine.toolsGroup
47+
private const val prefix = "validation"
4848

49-
const val runtimeModule = "$group:$prefix-java-runtime"
49+
const val gradlePluginLib = "$group:$prefix-gradle-plugin:$version"
50+
51+
const val runtimeModule = "${Spine.group}:spine-$prefix-jvm-runtime"
5052
const val runtime = "$runtimeModule:$version"
5153
const val javaModule = "$group:$prefix-java"
5254
const val java = "$javaModule:$version"
53-
5455
const val javaBundleModule = "$group:$prefix-java-bundle"
5556

5657
/** Obtains the artifact for the `java-bundle` artifact of the given version. */

buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly
3030
import io.spine.gradle.Cli
3131
import io.spine.gradle.fs.LazyTempPath
3232
import java.util.concurrent.TimeUnit.MILLISECONDS
33-
import org.gradle.api.logging.Logger
33+
import org.gradle.api.Project
3434

3535
/**
3636
* Interacts with a real Git repository.
@@ -47,16 +47,17 @@ import org.gradle.api.logging.Logger
4747
* release of resources please use the provided functionality inside a `use` block or
4848
* call the `close` method manually.
4949
*
50+
* @property project The Gradle project in which context the repo operations are held.
5051
* @property sshUrl The GitHub SSH URL to the underlying repository.
5152
* @property user Current user configuration.
5253
* This configuration determines what ends up in the `author` and `committer` fields of a commit.
5354
* @property currentBranch The currently checked-out branch.
5455
*/
5556
class Repository private constructor(
57+
private val project: Project,
5658
private val sshUrl: String,
5759
private var user: UserInfo,
5860
private var currentBranch: String,
59-
private val logger: Logger
6061
) : AutoCloseable {
6162

6263
/**
@@ -75,10 +76,9 @@ class Repository private constructor(
7576
* Executes a command in the [location].
7677
*/
7778
private fun repoExecute(vararg command: String): String {
78-
if (logger.isErrorEnabled) {
79-
val msg = "[Repository] Executing command: `${command.toList().joinToString(" ")}`."
80-
logger.error(msg)
81-
}
79+
val cmd = command.toList().joinToString(" ")
80+
val msg = "[Repo (${project.path})] Executing command: `$cmd`."
81+
System.err.println(msg)
8282
return Cli(location.toFile()).execute(*command)
8383
}
8484

@@ -159,14 +159,14 @@ class Repository private constructor(
159159
* @throws IllegalArgumentException if SSH URL is an empty string.
160160
*/
161161
fun clone(
162+
project: Project,
162163
sshUrl: String,
163164
user: UserInfo,
164165
branch: String = Branch.master,
165-
logger: Logger
166166
): Repository {
167167
require(sshUrl.isNotBlank()) { "SSH URL cannot be an empty string." }
168168

169-
val repo = Repository(sshUrl, user, branch, logger)
169+
val repo = Repository(project, sshUrl, user, branch)
170170
repo.clone()
171171
repo.configureUser(user)
172172

@@ -199,9 +199,9 @@ class Repository private constructor(
199199
*/
200200
@Suppress("TooGenericExceptionCaught", "LongParameterList")
201201
private fun <T> withRetries(
202-
times: Int = 3,
203-
initialDelay: Long = 100, // ms
204-
maxDelay: Long = 2000, // ms
202+
times: Int = 5,
203+
initialDelay: Long = 2000, // ms
204+
maxDelay: Long = 20000, // ms
205205
factor: Double = 2.0,
206206
description: String = "",
207207
block: () -> T

buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import io.spine.gradle.git.Branch
3030
import io.spine.gradle.git.Repository
3131
import io.spine.gradle.git.UserInfo
3232
import io.spine.gradle.repo.RepoSlug
33-
import org.gradle.api.logging.Logger
33+
import org.gradle.api.Project
3434

3535
/**
3636
* Clones the current project repository with the branch dedicated to publishing
@@ -47,7 +47,7 @@ import org.gradle.api.logging.Logger
4747
* @throws org.gradle.api.GradleException if any of the environment variables described above
4848
* is not set.
4949
*/
50-
internal fun Repository.Factory.forPublishingDocumentation(logger: Logger): Repository {
50+
internal fun Repository.Factory.forPublishingDocumentation(project: Project): Repository {
5151
val host = RepoSlug.fromVar().gitHost()
5252

5353
val username = "UpdateGitHubPages Plugin"
@@ -56,5 +56,5 @@ internal fun Repository.Factory.forPublishingDocumentation(logger: Logger): Repo
5656

5757
val branch = Branch.documentation
5858

59-
return clone(host, user, branch, logger)
59+
return clone(project, host, user, branch)
6060
}

0 commit comments

Comments
 (0)