From 25f8407c0ca3e32b9e94aa3cf96a8a58878bca72 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Fri, 26 Sep 2025 23:11:14 +0100 Subject: [PATCH 01/25] Update `config` --- build.gradle.kts | 61 +-- buildSrc/src/main/kotlin/BuildExtensions.kt | 154 ++++++-- .../src/main/kotlin/DependencyResolution.kt | 27 +- .../local/CoreJava.kt => LicenseSettings.kt} | 31 +- .../kotlin/io/spine/dependency/build/Dokka.kt | 4 +- .../kotlin/io/spine/dependency/build/Ksp.kt | 29 +- .../kotlin/io/spine/dependency/build/Pmd.kt | 9 +- .../kotlin/io/spine/dependency/lib/Aedile.kt | 4 +- .../io/spine/dependency/lib/Caffeine.kt | 6 +- .../io/spine/dependency/lib/Coroutines.kt | 25 +- .../kotlin/io/spine/dependency/lib/Grpc.kt | 65 ++- .../io/spine/dependency/lib/GrpcKotlin.kt | 3 +- .../kotlin/io/spine/dependency/lib/Gson.kt | 2 +- .../kotlin/io/spine/dependency/lib/Guava.kt | 2 +- .../kotlin/io/spine/dependency/lib/Jackson.kt | 108 +++-- .../kotlin/io/spine/dependency/lib/JavaX.kt | 2 +- .../kotlin/io/spine/dependency/lib/Kotlin.kt | 78 ++-- .../io/spine/dependency/lib/KotlinPoet.kt | 2 +- .../io/spine/dependency/lib/KotlinSemver.kt | 2 +- .../kotlin/io/spine/dependency/lib/KotlinX.kt | 28 +- .../io/spine/dependency/lib/Protobuf.kt | 6 +- .../kotlin/io/spine/dependency/lib/Roaster.kt | 2 +- .../spine/dependency/local/ArtifactVersion.kt | 137 ------- .../kotlin/io/spine/dependency/local/Base.kt | 8 +- .../io/spine/dependency/local/BaseTypes.kt | 2 +- .../io/spine/dependency/local/Change.kt | 2 +- .../io/spine/dependency/local/Logging.kt | 2 +- .../io/spine/dependency/local/McJava.kt | 6 +- .../io/spine/dependency/local/ProtoData.kt | 11 +- .../io/spine/dependency/local/ProtoTap.kt | 2 +- .../io/spine/dependency/local/Reflect.kt | 2 +- .../kotlin/io/spine/dependency/local/Spine.kt | 81 ---- .../io/spine/dependency/local/TestLib.kt | 4 +- .../kotlin/io/spine/dependency/local/Time.kt | 4 +- .../io/spine/dependency/local/ToolBase.kt | 29 +- .../io/spine/dependency/local/Validation.kt | 14 +- .../io/spine/dependency/test/AssertK.kt | 2 +- .../io/spine/dependency/test/Hamcrest.kt | 2 +- .../kotlin/io/spine/dependency/test/JUnit.kt | 85 +++- .../kotlin/io/spine/dependency/test/Jacoco.kt | 2 +- .../dependency/test/KotlinCompileTesting.kt | 2 +- .../kotlin/io/spine/dependency/test/Kover.kt | 2 +- .../kotlin/io/spine/dependency/test/Truth.kt | 2 +- .../kotlin/io/spine/gradle/ConfigTester.kt | 2 +- .../io/spine/gradle/ProjectExtensions.kt | 11 +- .../main/kotlin/io/spine/gradle/RepoSlug.kt | 66 ---- .../kotlin/io/spine/gradle/Repositories.kt | 370 ------------------ .../main/kotlin/io/spine/gradle/RunBuild.kt | 2 +- .../main/kotlin/io/spine/gradle/RunGradle.kt | 2 +- .../main/kotlin/io/spine/gradle/Runtime.kt | 15 +- .../gradle/checkstyle/CheckStyleConfig.kt | 13 +- .../github/pages/RepositoryExtensions.kt | 2 +- .../gradle/github/pages/UpdateGitHubPages.kt | 2 +- .../gradle/javadoc/ExcludeInternalDoclet.kt | 10 +- .../io/spine/gradle/javadoc/JavadocConfig.kt | 31 +- .../gradle/javadoc/TaskContainerExtensions.kt | 40 -- .../io/spine/gradle/kotlin/KotlinConfig.kt | 6 +- .../gradle/protobuf/ProtoTaskExtensions.kt | 75 +++- .../gradle/publish/CheckVersionIncrement.kt | 20 +- .../gradle/publish/CloudArtifactRegistry.kt | 10 +- .../io/spine/gradle/publish/CloudRepo.kt | 5 +- .../io/spine/gradle/publish/GitHubPackages.kt | 14 +- .../io/spine/gradle/publish/Publications.kt | 234 ----------- .../io/spine/gradle/publish/PublishingExts.kt | 73 +++- .../spine/gradle/publish/PublishingRepos.kt | 2 +- .../spine/gradle/publish/SpinePublishing.kt | 223 +++++++---- .../gradle/report/coverage/CodebaseFilter.kt | 1 - .../gradle/report/coverage/JacocoConfig.kt | 6 +- .../gradle/report/license/LicenseReporter.kt | 10 +- .../report/license/ModuleDataExtensions.kt | 1 - .../spine/gradle/report/license/Template.kt | 17 +- .../gradle/report/pom/DependencyWriter.kt | 4 +- .../gradle/report/pom/ModuleDependency.kt | 4 +- .../spine/gradle/report/pom/PomFormatting.kt | 2 +- .../spine/gradle/report/pom/PomGenerator.kt | 10 +- .../spine/gradle/report/pom/PomXmlWriter.kt | 16 +- .../kotlin/io/spine/gradle/testing/Tasks.kt | 7 +- settings.gradle.kts.template | 43 +- 78 files changed, 985 insertions(+), 1415 deletions(-) rename buildSrc/src/main/kotlin/{io/spine/dependency/local/CoreJava.kt => LicenseSettings.kt} (63%) delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/ArtifactVersion.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/RepoSlug.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/Repositories.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javadoc/TaskContainerExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/Publications.kt diff --git a/build.gradle.kts b/build.gradle.kts index d2639d2..48105b4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,54 +24,57 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import io.spine.dependency.local.McJava -import io.spine.dependency.local.ProtoData -import io.spine.dependency.local.CoreJava +import io.spine.dependency.local.Compiler +import io.spine.dependency.local.CoreJvm +import io.spine.dependency.local.CoreJvmCompiler import io.spine.dependency.local.Validation import io.spine.gradle.UpdateJournal import io.spine.gradle.base.build -import io.spine.gradle.standardToSpineSdk +import io.spine.gradle.repo.standardToSpineSdk import java.util.function.Supplier -plugins { - java - id("com.google.protobuf") - idea - id("com.osacky.doctor") version "0.8.1" -} - buildscript { standardSpineSdkRepositories() - dependencies { - classpath(mcJava.pluginLib(mcJava.version)) - } - configurations.all { resolutionStrategy.force( - protoData.pluginLib, - protoData.backend, - protoData.java, - validation.java, - validation.javaBundle, + spineCompiler.pluginLib, + spineCompiler.backend, + spineCompiler.jvm, +// validation.java, +// validation.javaBundle, ) } + + dependencies { + coreJvmCompiler.run { + classpath(pluginLib(version)) + } + } +} + +plugins { + java + id("com.google.protobuf") + idea + id("com.osacky.doctor") version "0.8.1" + id("io.spine.core-jvm") version "2.0.0-SNAPSHOT.006" } repositories.standardToSpineSdk() -apply(plugin = McJava.pluginId) +//apply(plugin = CoreJvmCompiler.pluginId) dependencies { - implementation(CoreJava.server) + implementation(CoreJvm.server) } configurations.all { resolutionStrategy.force( - ProtoData.backend, - ProtoData.java, - Validation.java, - Validation.runtime, + Compiler.backend, + Compiler.jvm, +// Validation.java, +// Validation.runtime, ) } @@ -110,10 +113,10 @@ val recordExecTime by tasks.registering(UpdateJournal::class) { startTime = Supplier { startTimeMillis!! } versions.set( mapOf( - "core" to CoreJava.version, - "ProtoData" to ProtoData.version, + "Compiler" to Compiler.version, + "CoreJvmCompiler" to CoreJvmCompiler.version, + "CoreJvm" to CoreJvm.version, "Validation" to Validation.version, - "mc-java" to McJava.version ) ) } diff --git a/buildSrc/src/main/kotlin/BuildExtensions.kt b/buildSrc/src/main/kotlin/BuildExtensions.kt index 1c1b774..34e262b 100644 --- a/buildSrc/src/main/kotlin/BuildExtensions.kt +++ b/buildSrc/src/main/kotlin/BuildExtensions.kt @@ -29,14 +29,15 @@ import io.spine.dependency.build.ErrorProne import io.spine.dependency.build.GradleDoctor import io.spine.dependency.build.Ksp +import io.spine.dependency.build.PluginPublishPlugin import io.spine.dependency.lib.Protobuf +import io.spine.dependency.local.CoreJvmCompiler +import io.spine.dependency.local.Compiler import io.spine.dependency.local.McJava -import io.spine.dependency.local.Validation -import io.spine.dependency.local.ProtoData import io.spine.dependency.local.ProtoTap import io.spine.dependency.test.Kotest import io.spine.dependency.test.Kover -import io.spine.gradle.standardToSpineSdk +import io.spine.gradle.repo.standardToSpineSdk import org.gradle.api.Project import org.gradle.api.Task import org.gradle.api.tasks.JavaExec @@ -67,52 +68,55 @@ import org.gradle.plugin.use.PluginDependencySpec private const val ABOUT_DEPENDENCY_EXTENSIONS = "" /** - * Applies [standard][standardToSpineSdk] repositories to this `buildscript`. + * Applies [standard][io.spine.gradle.repo.standardToSpineSdk] repositories to this `buildscript`. */ fun ScriptHandlerScope.standardSpineSdkRepositories() { repositories.standardToSpineSdk() } /** - * Shortcut to [McJava] dependency object for using under `buildScript`. - * - * This plugin is not published to Gradle Portal and cannot be applied directly to a project. - * Firstly, it should be put to buildscript's classpath and then applied by ID only. + * Shortcut to [Protobuf] dependency object for using under `buildScript`. */ -val ScriptHandlerScope.mcJava: McJava - get() = McJava +val ScriptHandlerScope.protobuf: Protobuf + get() = Protobuf /** - * Shortcut to [Validation] dependency object for using under `buildScript`. + * Shortcut to [CoreJvmCompiler] dependency object for using under `buildScript`. */ -val ScriptHandlerScope.validation: Validation - get() = Validation +val ScriptHandlerScope.coreJvmCompiler: CoreJvmCompiler + get() = CoreJvmCompiler + +/** + * Shortcut to [McJava] dependency object for using under `buildScript`. + */ +val ScriptHandlerScope.mcJava: McJava + get() = McJava /** - * Shortcut to [McJava] dependency object. + * Shortcut to [CoreJvmCompiler] dependency object. * * This plugin is not published to Gradle Portal and cannot be applied directly to a project. * Firstly, it should be put to buildscript's classpath and then applied by ID only. */ -val PluginDependenciesSpec.mcJava: McJava - get() = McJava +val PluginDependenciesSpec.coreJvmCompiler: CoreJvmCompiler + get() = CoreJvmCompiler /** - * Shortcut to [ProtoData] dependency object for using under `buildscript`. + * Shortcut to [Compiler] dependency object for using under `buildscript`. */ -val ScriptHandlerScope.protoData: ProtoData - get() = ProtoData +val ScriptHandlerScope.spineCompiler: Compiler + get() = Compiler /** - * Shortcut to [ProtoData] dependency object. + * Shortcut to [Compiler] dependency object. * * This plugin is published at Gradle Plugin Portal. * But when used in a pair with [mcJava], it cannot be applied directly to a project. - * It is so, because [mcJava] uses [protoData] as its dependency. + * It is so, because [mcJava] uses [spineCompiler] as its dependency. * And the buildscript's classpath ends up with both of them. */ -val PluginDependenciesSpec.protoData: ProtoData - get() = ProtoData +val PluginDependenciesSpec.spineCompiler: Compiler + get() = Compiler /** * Provides shortcuts for applying plugins from our dependency objects. @@ -121,8 +125,8 @@ val PluginDependenciesSpec.protoData: ProtoData * declared in auto-generated `org.gradle.kotlin.dsl.PluginAccessors.kt` file. * It conflicts with our own declarations. * - * Declaring of top-level shortcuts eliminates the need in applying plugins - * using fully qualified name of dependency objects. + * Declaring of top-level shortcuts eliminates the need to apply plugins + * using a fully qualified name of dependency objects. * * It is still possible to apply a plugin with a custom version, if needed. * Just declare a version again on the returned [PluginDependencySpec]. @@ -160,13 +164,16 @@ val PluginDependenciesSpec.kover: PluginDependencySpec val PluginDependenciesSpec.ksp: PluginDependencySpec get() = id(Ksp.id).version(Ksp.version) +val PluginDependenciesSpec.`plugin-publish`: PluginDependencySpec + get() = id(PluginPublishPlugin.id).version(PluginPublishPlugin.version) + /** * Configures the dependencies between third-party Gradle tasks - * and those defined via ProtoData and Spine Model Compiler. + * and those defined via the Spine Compiler and its plugins. * * It is required to avoid warnings in build logs, detecting the undeclared * usage of Spine-specific task output by other tasks, - * e.g., the output of `launchProtoData` is used by `compileKotlin`. + * e.g., the output of `launchSpineCompiler` is used by `compileKotlin`. */ @Suppress("unused") fun Project.configureTaskDependencies() { @@ -195,7 +202,10 @@ fun Project.configureTaskDependencies() { val generateProto = "generateProto" val createVersionFile = "createVersionFile" val compileKotlin = "compileKotlin" - compileKotlin.dependOn(launchProtoData) + compileKotlin.run { + dependOn(generateProto) + dependOn(launchProtoData) + } val compileTestKotlin = "compileTestKotlin" compileTestKotlin.dependOn(launchTestProtoData) val sourcesJar = "sourcesJar" @@ -222,8 +232,8 @@ fun Project.configureTaskDependencies() { compileKotlin.dependOn(kspKotlin) compileTestKotlin.dependOn("kspTestKotlin") "compileTestFixturesKotlin".dependOn("kspTestFixturesKotlin") - "dokkaKotlinJar".dependOn(dokkaJavadoc) "javadocJar".dependOn(dokkaHtml) + "dokkaKotlinJar".dependOn(dokkaJavadoc) } } @@ -233,17 +243,38 @@ fun Project.configureTaskDependencies() { * By convention, such modules are for integration tests and should be treated differently. */ val Project.productionModules: Iterable - get() = rootProject.subprojects.filter { !it.name.contains("-tests") } + get() = rootProject.subprojects.filterNot { subproject -> + subproject.name.run { + contains("-tests") + || contains("test-fixtures") + || contains("integration-tests") + } + } +/** + * Obtains the names of the [productionModules]. + * + * The extension could be useful for excluding modules from standard publishing: + * ```kotlin + * spinePublishing { + * val customModule = "my-custom-module" + * modules = productionModuleNames.toSet().minus(customModule) + * modulesWithCustomPublishing = setOf(customModule) + * //... + * } + * ``` + */ +val Project.productionModuleNames: List + get() = productionModules.map { it.name } /** - * Sets the remote debug option for this task. + * Sets the remote debug option for this [JavaExec] task. * * The port number is [5566][BuildSettings.REMOTE_DEBUG_PORT]. * * @param enabled If `true` the task will be suspended. */ -fun Task.remoteDebug(enabled: Boolean = true) { this as JavaExec +fun JavaExec.remoteDebug(enabled: Boolean = true) { debugOptions { this@debugOptions.enabled.set(enabled) port.set(BuildSettings.REMOTE_DEBUG_PORT) @@ -253,23 +284,66 @@ fun Task.remoteDebug(enabled: Boolean = true) { this as JavaExec } /** - * Sets remote debug options for the `launchProtoData` task. + * Sets the remote debug option for the task of [JavaExec] type with the given name. + * + * The port number is [5566][BuildSettings.REMOTE_DEBUG_PORT]. + * + * @param enabled If `true` the task will be suspended. + * @throws IllegalStateException if the task with the given name is not found, or, + * if the taks is not of [JavaExec] type. + */ +fun Project.setRemoteDebug(taskName: String, enabled: Boolean = true) { + val task = tasks.findByName(taskName) + check(task != null) { + "Could not find a task named `$taskName` in the project `$name`." + } + check(task is JavaExec) { + "The task `$taskName` is not of type `JavaExec`." + } + task.remoteDebug(enabled) +} + +/** + * Sets remote debug options for the `launchSpineCompiler` task. * * @param enabled if `true` the task will be suspended. * * @see remoteDebug */ -fun Project.protoDataRemoteDebug(enabled: Boolean = true) { - tasks.findByName("launchProtoData")?.remoteDebug(enabled) -} +fun Project.spineCompilerRemoteDebug(enabled: Boolean = true) = + setRemoteDebug("launchSpineCompiler", enabled) /** - * Sets remote debug options for the `launchTestProtoData` task. + * Sets remote debug options for the `launchTestSpineCompiler` task. * * @param enabled if `true` the task will be suspended. * * @see remoteDebug */ -fun Project.testProtoDataRemoteDebug(enabled: Boolean = true) { - tasks.findByName("launchTestProtoData")?.remoteDebug(enabled) -} +fun Project.testSpineCompilerRemoteDebug(enabled: Boolean = true) = + setRemoteDebug("launchTestSpineCompiler", enabled) + +/** + * Sets remote debug options for the `launchTestFixturesSpineCompiler` task. + * + * @param enabled if `true` the task will be suspended. + * + * @see remoteDebug + */ +fun Project.testFixturesSpineCompilerRemoteDebug(enabled: Boolean = true) = + setRemoteDebug("launchTestFixturesSpineCompiler", enabled) + +/** + * Parts of names of configurations to be excluded by + * `artifactMeta/excludeConfigurations/containing` in the modules + * where `io.spine.atifact-meta` plugin is applied. + */ +val buildToolConfigurations: Array = arrayOf( + "detekt", + "jacoco", + "pmd", + "checkstyle", + "checkerframework", + "ksp", + "dokka", +) diff --git a/buildSrc/src/main/kotlin/DependencyResolution.kt b/buildSrc/src/main/kotlin/DependencyResolution.kt index adf5eae..124adb3 100644 --- a/buildSrc/src/main/kotlin/DependencyResolution.kt +++ b/buildSrc/src/main/kotlin/DependencyResolution.kt @@ -29,6 +29,7 @@ import io.spine.dependency.build.CheckerFramework import io.spine.dependency.build.Dokka import io.spine.dependency.build.ErrorProne import io.spine.dependency.build.FindBugs +import io.spine.dependency.build.JSpecify import io.spine.dependency.lib.Asm import io.spine.dependency.lib.AutoCommon import io.spine.dependency.lib.AutoService @@ -39,7 +40,6 @@ import io.spine.dependency.lib.CommonsLogging import io.spine.dependency.lib.Gson import io.spine.dependency.lib.Guava import io.spine.dependency.lib.J2ObjC -import io.spine.dependency.lib.Jackson import io.spine.dependency.lib.JavaDiffUtils import io.spine.dependency.lib.Kotlin import io.spine.dependency.lib.Okio @@ -49,7 +49,6 @@ import io.spine.dependency.lib.Slf4J import io.spine.dependency.local.Base import io.spine.dependency.local.Spine import io.spine.dependency.test.Hamcrest -import io.spine.dependency.test.JUnit import io.spine.dependency.test.Kotest import io.spine.dependency.test.OpenTest4J import io.spine.dependency.test.Truth @@ -86,6 +85,9 @@ fun NamedDomainObjectContainer.forceVersions() { private fun ResolutionStrategy.forceProductionDependencies() { @Suppress("DEPRECATION") // Force versions of SLF4J and Kotlin libs. + Protobuf.libs.forEach { + force(it) + } force( AnimalSniffer.lib, AutoCommon.lib, @@ -97,11 +99,7 @@ private fun ResolutionStrategy.forceProductionDependencies() { FindBugs.annotations, Gson.lib, Guava.lib, - Kotlin.reflect, - Kotlin.stdLib, - Kotlin.stdLibCommon, - Kotlin.stdLibJdk7, - Kotlin.stdLibJdk8, + JSpecify.annotations, Protobuf.GradlePlugin.lib, Protobuf.libs, Slf4J.lib @@ -111,11 +109,6 @@ private fun ResolutionStrategy.forceProductionDependencies() { private fun ResolutionStrategy.forceTestDependencies() { force( Guava.testLib, - JUnit.api, - JUnit.bom, - JUnit.Platform.commons, - JUnit.Platform.launcher, - JUnit.legacy, Truth.libs, Kotest.assertions, ) @@ -138,16 +131,6 @@ private fun ResolutionStrategy.forceTransitiveDependencies() { Gson.lib, Hamcrest.core, J2ObjC.annotations, - JUnit.Platform.engine, - JUnit.Platform.suiteApi, - JUnit.runner, - Jackson.annotations, - Jackson.bom, - Jackson.core, - Jackson.databind, - Jackson.dataformatXml, - Jackson.dataformatYaml, - Jackson.moduleKotlin, JavaDiffUtils.lib, Kotlin.jetbrainsAnnotations, Okio.lib, diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt b/buildSrc/src/main/kotlin/LicenseSettings.kt similarity index 63% rename from buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt rename to buildSrc/src/main/kotlin/LicenseSettings.kt index 01dad32..70eb367 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJava.kt +++ b/buildSrc/src/main/kotlin/LicenseSettings.kt @@ -24,25 +24,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.dependency.local - /** - * Dependencies on `core-java` modules. + * The settings of the software license which apply to the code of this project. + * + * The constants defined in this object are used by the + * [PublicationHandler][io.spine.gradle.publish.PublicationHandler] to set up + * corresponding properties of the published `pom.xml` file of an artifact. + * + * So, in order to adapt the license settings to the requirements of a particular project, + * simply change the values of the constants defined in this object. * - * See [`SpineEventEngine/core-java`](https://github.com/SpineEventEngine/core-java/). + * @see io.spine.gradle.publish.PublicationHandler */ -@Suppress("ConstPropertyName", "unused") -object CoreJava { - const val group = Spine.group - const val version = "2.0.0-SNAPSHOT.201" - - const val coreArtifact = "spine-core" - const val clientArtifact = "spine-client" - const val serverArtifact = "spine-server" - - const val core = "$group:$coreArtifact:$version" - const val client = "$group:$clientArtifact:$version" - const val server = "$group:$serverArtifact:$version" - - const val testUtilServer = "${Spine.toolsGroup}:spine-testutil-server:$version" +@Suppress("ConstPropertyName", "unused") // https://bit.ly/kotlin-prop-names +object LicenseSettings { + const val name = "The Apache License, Version 2.0" + const val url = "https://www.apache.org/licenses/LICENSE-2.0.txt" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt index 41757db..003bf58 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt @@ -35,7 +35,7 @@ object Dokka { * When changing the version, also change the version used in the * `buildSrc/build.gradle.kts`. */ - const val version = "1.9.20" + const val version = "2.0.0" object GradlePlugin { const val id = "org.jetbrains.dokka" @@ -78,7 +78,7 @@ object Dokka { object SpineExtensions { private const val group = "io.spine.tools" - const val version = "2.0.0-SNAPSHOT.6" + const val version = "2.0.0-SNAPSHOT.7" const val lib = "$group:spine-dokka-extensions:$version" } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt index 4534c52..3ea45b3 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt @@ -26,18 +26,31 @@ package io.spine.dependency.build +import io.spine.dependency.Dependency + /** * Kotlin Symbol Processing API. * * @see KSP GitHub repository */ -@Suppress("ConstPropertyName", "unused") -object Ksp { - const val version = "2.1.10-1.0.31" +@Suppress("unused") +object Ksp : Dependency() { + override val version = "2.1.21-2.0.1" + override val group = "com.google.devtools.ksp" + const val id = "com.google.devtools.ksp" - const val group = "com.google.devtools.ksp" - const val symbolProcessingApi = "$group:symbol-processing-api:$version" - const val symbolProcessing = "$group:symbol-processing:$version" - const val symbolProcessingAaEmb = "$group:symbol-processing-aa-embeddable:$version" - const val symbolProcessingCommonDeps = "$group:symbol-processing-common-deps:$version" + + val symbolProcessingApi = "$group:symbol-processing-api" + val symbolProcessing = "$group:symbol-processing" + val symbolProcessingAaEmb = "$group:symbol-processing-aa-embeddable" + val symbolProcessingCommonDeps = "$group:symbol-processing-common-deps" + val gradlePlugin = "$group:symbol-processing-gradle-plugin" + + override val modules = listOf( + symbolProcessingApi, + symbolProcessing, + symbolProcessingAaEmb, + symbolProcessingCommonDeps, + gradlePlugin, + ) } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt index e4f7fdd..dd71b49 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt @@ -31,12 +31,5 @@ package io.spine.dependency.build // https://github.com/pmd/pmd/releases @Suppress("unused", "ConstPropertyName") object Pmd { - /** - * This is the last version in the 6.x series. - * - * There's a major update to 7.x series. - * - * @see Aedile at GitHub */ @Suppress("unused") object Aedile { - private const val version = "1.3.1" + private const val version = "2.1.2" const val lib = "com.sksamuel.aedile:aedile-core:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt index 9b0c7c1..23f44a4 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt @@ -30,12 +30,14 @@ package io.spine.dependency.lib * A [high performance](https://github.com/ben-manes/caffeine/wiki/Benchmarks), * [near optimal](https://github.com/ben-manes/caffeine/wiki/Efficiency) caching library. * - * This library is a transitive dependency for us via ErrorProne. + * This library is a transitive dependency for us via + * [io.spine.dependency.lib.Aedile] and + * [io.spine.dependency.build.ErrorProne]. * * @see Caffeine at GitHub */ @Suppress("unused") object Caffeine { - private const val version = "3.0.5" + private const val version = "3.2.0" const val lib = "com.github.ben-manes.caffeine:caffeine:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt index cb3c281..2073d76 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt @@ -28,14 +28,25 @@ package io.spine.dependency.lib /** * Kotlin Coroutines. - * + * * @see GitHub projecet */ -@Suppress("unused") +@Suppress("unused", "ConstPropertyName") +@Deprecated( + message = "Please use `Coroutines` from the `io.spine.dependency.kotlinx` package", + replaceWith = ReplaceWith( + expression = "Coroutines", + imports = ["io.spine.dependency.kotlinx.Coroutines"] + ) +) object Coroutines { - const val version = "1.6.4" - const val jdk8 = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$version" - const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version" - const val bom = "org.jetbrains.kotlinx:kotlinx-coroutines-bom:$version" - const val coreJvm = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:$version" + const val group = "org.jetbrains.kotlinx" + val version = io.spine.dependency.kotlinx.Coroutines.version + val bom = "$group:kotlinx-coroutines-bom:$version" + val core = "$group:kotlinx-coroutines-core:$version" + val coreJvm = "$group:kotlinx-coroutines-core-jvm:$version" + val jdk8 = "$group:kotlinx-coroutines-jdk8:$version" + val debug = "$group:kotlinx-coroutines-debug:$version" + val test = "$group:kotlinx-coroutines-test:$version" + val testJvm = "$group:kotlinx-coroutines-test-jvm:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt index 011b4d2..48e70f4 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt @@ -26,26 +26,57 @@ package io.spine.dependency.lib +import io.spine.dependency.DependencyWithBom + // https://github.com/grpc/grpc-java -@Suppress("unused", "ConstPropertyName") -object Grpc { - @Suppress("MemberVisibilityCanBePrivate") - const val version = "1.59.0" - const val group = "io.grpc" - const val api = "$group:grpc-api:$version" - const val auth = "$group:grpc-auth:$version" - const val core = "$group:grpc-core:$version" - const val context = "$group:grpc-context:$version" - const val inProcess = "$group:grpc-inprocess:$version" - const val stub = "$group:grpc-stub:$version" - const val okHttp = "$group:grpc-okhttp:$version" - const val protobuf = "$group:grpc-protobuf:$version" - const val protobufLite = "$group:grpc-protobuf-lite:$version" - const val netty = "$group:grpc-netty:$version" - const val nettyShaded = "$group:grpc-netty-shaded:$version" +@Suppress("unused") +object Grpc : DependencyWithBom() { + + override val version = "1.72.0" + override val group = "io.grpc" + override val bom = "$group:grpc-bom:$version" + + val api = "$group:grpc-api" + val auth = "$group:grpc-auth" + val core = "$group:grpc-core" + val context = "$group:grpc-context" + val inProcess = "$group:grpc-inprocess" + val stub = "$group:grpc-stub" + val okHttp = "$group:grpc-okhttp" + val protobuf = "$group:grpc-protobuf" + val protobufLite = "$group:grpc-protobuf-lite" + val netty = "$group:grpc-netty" + val nettyShaded = "$group:grpc-netty-shaded" + + override val modules = listOf( + api, + auth, + core, + context, + inProcess, + stub, + okHttp, + protobuf, + protobufLite, + netty, + nettyShaded + ) object ProtocPlugin { const val id = "grpc" - const val artifact = "$group:protoc-gen-grpc-java:$version" + @Deprecated( + message = "Please use `GrpcKotlin.ProtocPlugin.artifact` instead.", + replaceWith = ReplaceWith("GrpcKotlin.ProtocPlugin.artifact") + ) + const val kotlinPluginVersion = GrpcKotlin.version + val artifact = "$group:protoc-gen-grpc-java:$version" + + // https://github.com/grpc/grpc-kotlin + // https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-kotlin/ + @Deprecated( + message = "Please use `GrpcKotlin.ProtocPlugin.artifact` instead.", + replaceWith = ReplaceWith("GrpcKotlin.ProtocPlugin.artifact") + ) + const val artifactKotlin = GrpcKotlin.ProtocPlugin.artifact } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt index e695f6f..05d21dd 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt @@ -33,11 +33,12 @@ package io.spine.dependency.lib */ @Suppress("unused") object GrpcKotlin { - const val version = "1.3.0" + const val version = "1.4.1" const val stub = "io.grpc:grpc-kotlin-stub:$version" object ProtocPlugin { const val id = "grpckt" + // https://central.sonatype.com/artifact/io.grpc/protoc-gen-grpc-kotlin const val artifact = "io.grpc:protoc-gen-grpc-kotlin:$version:jdk8@jar" } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt index 229c434..da9ae93 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt @@ -34,6 +34,6 @@ package io.spine.dependency.lib */ @Suppress("unused", "ConstPropertyName") object Gson { - private const val version = "2.10.1" + private const val version = "2.13.0" const val lib = "com.google.code.gson:gson:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt index 5ea5fcc..9115701 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt @@ -37,7 +37,7 @@ package io.spine.dependency.lib */ @Suppress("unused", "ConstPropertyName") object Guava { - private const val version = "32.1.3-jre" + private const val version = "33.4.8-jre" const val group = "com.google.guava" const val lib = "$group:guava:$version" const val testLib = "$group:guava-testlib:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt index 4b78c8f..b47b0c5 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt @@ -26,38 +26,102 @@ package io.spine.dependency.lib +import io.spine.dependency.Dependency +import io.spine.dependency.DependencyWithBom + // https://github.com/FasterXML/jackson/wiki/Jackson-Releases -@Suppress("unused", "ConstPropertyName") -object Jackson { - const val version = "2.15.3" - private const val databindVersion = "2.15.3" +@Suppress("unused") +object Jackson : DependencyWithBom() { + override val group = "com.fasterxml.jackson" + override val version = "2.18.3" + + // https://github.com/FasterXML/jackson-bom + override val bom = "$group:jackson-bom:$version" + + private val groupPrefix = group + private val coreGroup = "$groupPrefix.core" + private val moduleGroup = "$groupPrefix.module" - private const val coreGroup = "com.fasterxml.jackson.core" - private const val dataformatGroup = "com.fasterxml.jackson.dataformat" - private const val moduleGroup = "com.fasterxml.jackson.module" + // Constants coming below without `$version` are covered by the BOM. // https://github.com/FasterXML/jackson-core - const val core = "$coreGroup:jackson-core:$version" + val core = "$coreGroup:jackson-core" + // https://github.com/FasterXML/jackson-databind - const val databind = "$coreGroup:jackson-databind:$databindVersion" - // https://github.com/FasterXML/jackson-annotations - const val annotations = "$coreGroup:jackson-annotations:$version" + val databind = "$coreGroup:jackson-databind" - // https://github.com/FasterXML/jackson-dataformat-xml/releases - const val dataformatXml = "$dataformatGroup:jackson-dataformat-xml:$version" - // https://github.com/FasterXML/jackson-dataformats-text/releases - const val dataformatYaml = "$dataformatGroup:jackson-dataformat-yaml:$version" + // https://github.com/FasterXML/jackson-annotations + val annotations = "$coreGroup:jackson-annotations" // https://github.com/FasterXML/jackson-module-kotlin/releases - const val moduleKotlin = "$moduleGroup:jackson-module-kotlin:$version" + val moduleKotlin = "$moduleGroup:jackson-module-kotlin" - // https://github.com/FasterXML/jackson-bom - const val bom = "com.fasterxml.jackson:jackson-bom:$version" + override val modules = listOf( + core, + databind, + annotations, + moduleKotlin + ) + + object DataFormat : Dependency() { + override val version = Jackson.version + override val group = "$groupPrefix.dataformat" + + private const val infix = "jackson-dataformat" + + // https://github.com/FasterXML/jackson-dataformat-xml/releases + val xml = "$group:$infix-xml" + + // https://github.com/FasterXML/jackson-dataformats-text/releases + val yaml = "$group:$infix-yaml" + + val xmlArtifact = "$xml:$version" + val yamlArtifact = "$yaml:$version" + + override val modules = listOf(xml, yaml) + } + + object DataType : Dependency() { + override val version = Jackson.version + override val group = "$groupPrefix.datatype" + + private const val infix = "jackson-datatype" + + // https://github.com/FasterXML/jackson-modules-java8 + val jdk8 = "$group:$infix-jdk8" + + // https://github.com/FasterXML/jackson-modules-java8/tree/2.19/datetime + val dateTime = "$group:$infix-jsr310" + + // https://github.com/FasterXML/jackson-datatypes-collections/blob/2.19/guava + val guava = "$group:$infix-guava" + + // https://github.com/FasterXML/jackson-dataformats-binary/tree/2.19/protobuf + val protobuf = "$group:$infix-protobuf" + + // https://github.com/FasterXML/jackson-datatypes-misc/tree/2.19/javax-money + val javaXMoney = "$group:$infix-javax-money" + + // https://github.com/FasterXML/jackson-datatypes-misc/tree/2.19/moneta + val moneta = "$group:jackson-datatype-moneta" + + override val modules = listOf( + jdk8, + dateTime, + guava, + protobuf, + javaXMoney, + moneta + ) + } // https://github.com/FasterXML/jackson-jr - object Junior { - const val version = Jackson.version - const val group = "com.fasterxml.jackson.jr" - const val objects = "$group:jackson-jr-objects:$version" + object Junior : Dependency() { + override val version = Jackson.version + override val group = "com.fasterxml.jackson.jr" + + val objects = "$group:jackson-jr-objects" + + override val modules = listOf(objects) } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt index 7ea8cdf..e605a16 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt @@ -29,7 +29,7 @@ package io.spine.dependency.lib @Suppress("unused", "ConstPropertyName") object JavaX { // This artifact, which used to be a part of J2EE, moved under the Eclipse EE4J project. - // https://github.com/eclipse-ee4j/common-annotations-api + // https://github.com/jakartaee/common-annotations-api const val annotationGroup = "javax.annotation" const val annotations = "$annotationGroup:javax.annotation-api:1.3.2" 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 dc34b50..48694c5 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt @@ -26,23 +26,30 @@ package io.spine.dependency.lib +import io.spine.dependency.Dependency +import io.spine.dependency.DependencyWithBom + // https://github.com/JetBrains/kotlin // https://github.com/Kotlin -@Suppress("unused", "ConstPropertyName") -object Kotlin { +@Suppress("unused") +object Kotlin : DependencyWithBom() { /** * This is the version of Kotlin we use for writing code which does not * depend on Gradle and the version of embedded Kotlin. */ @Suppress("MemberVisibilityCanBePrivate") // used directly from the outside. - const val runtimeVersion = "2.1.10" + const val runtimeVersion = "2.1.21" + + override val version = runtimeVersion + override val group = "org.jetbrains.kotlin" + override val bom = "$group:kotlin-bom:$runtimeVersion" /** * This is the version of * [Kotlin embedded into Gradle](https://docs.gradle.org/current/userguide/compatibility.html#kotlin). */ - const val embeddedVersion = "2.0.21" + const val embeddedVersion = "2.1.21" /** * The version of the JetBrains annotations library, which is a transitive @@ -50,41 +57,64 @@ object Kotlin { * * @see Java Annotations */ - private const val annotationsVersion = "24.0.1" + private const val annotationsVersion = "26.0.2" + + val scriptRuntime = "$group:kotlin-script-runtime:$runtimeVersion" - private const val group = "org.jetbrains.kotlin" + object StdLib : Dependency() { + override val version = runtimeVersion + override val group = Kotlin.group + + private const val infix = "kotlin-stdlib" + val itself = "$group:$infix" + val common = "$group:$infix-common" + val jdk7 = "$group:$infix-jdk7" + val jdk8 = "$group:$infix-jdk8" + + override val modules = listOf(itself, common, jdk7, jdk8) + } - const val scriptRuntime = "$group:kotlin-script-runtime:$runtimeVersion" - const val stdLib = "$group:kotlin-stdlib:$runtimeVersion" - const val stdLibCommon = "$group:kotlin-stdlib-common:$runtimeVersion" + @Deprecated("Please use `StdLib.itself` instead.", ReplaceWith("StdLib.itself")) + val stdLib = StdLib.itself - const val toolingCore = "$group:kotlin-tooling-core:$runtimeVersion" + @Deprecated("Please use `StdLib.common` instead.", ReplaceWith("StdLib.common")) + val stdLibCommon = StdLib.common - @Deprecated("Please use `stdLib` instead.") - const val stdLibJdk7 = "$group:kotlin-stdlib-jdk7:$runtimeVersion" + @Deprecated("Please use `StdLib.jdk7` instead.", ReplaceWith("StdLib.jdk7")) + val stdLibJdk7 = StdLib.jdk7 - @Deprecated("Please use `stdLib` instead.") - const val stdLibJdk8 = "$group:kotlin-stdlib-jdk8:$runtimeVersion" + @Deprecated("Please use `StdLib.jdk8` instead.") + val stdLibJdk8 = StdLib.jdk8 - const val reflect = "$group:kotlin-reflect:$runtimeVersion" - const val testJUnit5 = "$group:kotlin-test-junit5:$runtimeVersion" + val toolingCore = "$group:kotlin-tooling-core" + val reflect = "$group:kotlin-reflect" + val testJUnit5 = "$group:kotlin-test-junit5" + + /** + * The modules our interest that do not belong to [StdLib]. + */ + override val modules = listOf(reflect, testJUnit5) @Deprecated(message = "Please use `GradlePlugin.api` instead.", ReplaceWith("GradlePlugin.api")) - const val gradlePluginApi = "$group:kotlin-gradle-plugin-api:$runtimeVersion" + val gradlePluginApi = "$group:kotlin-gradle-plugin-api" @Deprecated(message = "Please use `GradlePlugin.lib` instead.", ReplaceWith("GradlePlugin.lib")) - const val gradlePluginLib = "$group:kotlin-gradle-plugin:$runtimeVersion" + val gradlePluginLib = "$group:kotlin-gradle-plugin" const val jetbrainsAnnotations = "org.jetbrains:annotations:$annotationsVersion" object Compiler { - const val embeddable = "$group:kotlin-compiler-embeddable:$runtimeVersion" + val embeddable = "$group:kotlin-compiler-embeddable:$embeddedVersion" } - object GradlePlugin { - const val version = Kotlin.runtimeVersion - const val api = "$group:kotlin-gradle-plugin-api:$version" - const val lib = "$group:kotlin-gradle-plugin:$version" - const val model = "$group:kotlin-gradle-model:$version" + object GradlePlugin : Dependency() { + override val version = runtimeVersion + override val group = Kotlin.group + + val api = "$group:kotlin-gradle-plugin-api:$version" + val lib = "$group:kotlin-gradle-plugin:$version" + val model = "$group:kotlin-gradle-model:$version" + + override val modules = listOf(api, lib, model) } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt index 346c5d8..d7ece62 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt @@ -29,7 +29,7 @@ package io.spine.dependency.lib // https://github.com/square/kotlinpoet @Suppress("unused", "ConstPropertyName") object KotlinPoet { - private const val version = "2.0.0" + private const val version = "2.2.0" const val lib = "com.squareup:kotlinpoet:$version" const val ksp = "com.squareup:kotlinpoet-ksp:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt index 1525360..92a348d 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt @@ -29,6 +29,6 @@ package io.spine.dependency.lib // https://github.com/z4kn4fein/kotlin-semver @Suppress("unused", "ConstPropertyName") object KotlinSemver { - private const val version = "1.4.2" + private const val version = "2.0.0" const val lib = "io.github.z4kn4fein:semver:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt index a58dee3..ee521e3 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt @@ -27,18 +27,34 @@ package io.spine.dependency.lib @Suppress("unused", "ConstPropertyName") +@Deprecated( + message = "Please use `KotlinX` from `io.spine.dependency.kotlinx` package", + replaceWith = ReplaceWith( + expression = "KotlinX", + imports = ["io.spine.dependency.kotlinx.KotlinX"] + ) +) object KotlinX { const val group = "org.jetbrains.kotlinx" + @Deprecated( + message = "Please use `Coroutines` from the `io.spine.dependency.kotlinx` package", + replaceWith = ReplaceWith( + expression = "Coroutines", + imports = ["io.spine.dependency.kotlinx.Coroutines"] + ) + ) object Coroutines { // https://github.com/Kotlin/kotlinx.coroutines - const val version = "1.10.1" - const val bom = "$group:kotlinx-coroutines-bom:$version" - const val core = "$group:kotlinx-coroutines-core:$version" - const val coreJvm = "$group:kotlinx-coroutines-core-jvm:$version" - const val jdk8 = "$group:kotlinx-coroutines-jdk8:$version" - const val test = "$group:kotlinx-coroutines-test:$version" + val version = io.spine.dependency.kotlinx.Coroutines.version + val bom = "$group:kotlinx-coroutines-bom:$version" + val core = "$group:kotlinx-coroutines-core:$version" + val coreJvm = "$group:kotlinx-coroutines-core-jvm:$version" + val jdk8 = "$group:kotlinx-coroutines-jdk8:$version" + val debug = "$group:kotlinx-coroutines-debug:$version" + val test = "$group:kotlinx-coroutines-test:$version" + val testJvm = "$group:kotlinx-coroutines-test-jvm:$version" } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt index 98ce188..8eaf49a 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt @@ -33,7 +33,7 @@ package io.spine.dependency.lib ) object Protobuf { const val group = "com.google.protobuf" - const val version = "3.25.1" + const val version = "4.31.1" /** * The Java library with Protobuf data types. @@ -60,11 +60,11 @@ object Protobuf { object GradlePlugin { /** * The version of this plugin is already specified in `buildSrc/build.gradle.kts` file. - * Thus, when applying the plugin to projects build files, only the [id] should be used. + * Thus, when applying the plugin to project build files, only the [id] should be used. * * When changing the version, also change the version used in the `build.gradle.kts`. */ - const val version = "0.9.4" + const val version = "0.9.5" const val id = "com.google.protobuf" const val lib = "$group:protobuf-gradle-plugin:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt index e55420e..601be9a 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt @@ -37,7 +37,7 @@ object Roaster { * [2.29.0.Final](https://github.com/forge/roaster/releases/tag/2.29.0.Final), * Roaster requires Java 17. */ - private const val version = "2.28.0.Final" + private const val version = "2.29.0.Final" const val group = "org.jboss.forge.roaster" const val api = "$group:roaster-api:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ArtifactVersion.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ArtifactVersion.kt deleted file mode 100644 index 77497b2..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ArtifactVersion.kt +++ /dev/null @@ -1,137 +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.dependency.local - -/** - * Versions for published Spine SDK artifacts. - */ -@Suppress("ConstPropertyName") -object ArtifactVersion { - - /** - * The version of [Spine.base]. - * - * @see spine-base - */ - @Deprecated(message = "Please use `Base.version`.", ReplaceWith("Base.version")) - const val base = Base.version - - @Suppress("unused") - @Deprecated( - message = "Please use `Base.versionForBuildScript`.", - ReplaceWith("Base.versionForBuildScript") - ) - const val baseForBuildScript = Base.versionForBuildScript - - /** - * The version of [Spine.reflect]. - * - * @see spine-reflect - */ - @Deprecated(message = "Please use `Reflect.version`.", ReplaceWith("Reflect.version")) - const val reflect = Reflect.version - - /** - * The version of [Logging]. - */ - @Deprecated(message = "Please use `Logging.version`.", ReplaceWith("Logging.version")) - const val logging = Logging.version - - /** - * The version of [Spine.testlib]. - * - * @see spine-testlib - */ - @Deprecated(message = "Please use `TestLib.version`.", ReplaceWith("TestLib.version")) - const val testlib = TestLib.version - - /** - * The version of `core-java`. - */ - @Deprecated(message = "Please use `CoreJava.version`.", ReplaceWith("CoreJava.version")) - const val core = CoreJava.version - - /** - * The version of [Spine.modelCompiler]. - * - * @see spine-model-compiler - */ - @Suppress("unused") - @Deprecated( - message = "Please use `ModelCompiler.version` instead.", - ReplaceWith("ModelCompiler.version") - ) - const val mc = ModelCompiler.version - - /** - * The version of [Spine.baseTypes]. - * - * @see spine-base-types - */ - @Deprecated(message = "Please use `BaseTypes.version`.", ReplaceWith("BaseTypes.version")) - const val baseTypes = BaseTypes.version - - /** - * The version of [Spine.time]. - * - * @see spine-time - */ - @Deprecated(message = "Please use `Time.version`.", ReplaceWith("Time.version")) - const val time = Time.version - - /** - * The version of [Spine.change]. - * - * @see spine-change - */ - @Deprecated(message = "Please use `Change.version`.", ReplaceWith("Change.version")) - const val change = Change.version - - /** - * The version of [Spine.text]. - * - * @see spine-text - */ - @Deprecated(message = "Please use `Text.version`.", ReplaceWith("Text.version")) - const val text = Text.version - - /** - * The version of [Spine.toolBase]. - * - * @see spine-tool-base - */ - @Suppress("unused") - @Deprecated(message = "Please use `ToolBase.version`.", ReplaceWith("ToolBase.version")) - const val toolBase = ToolBase.version - - /** - * The version of [Spine.javadocFilter]. - * - * @see spine-javadoc-tools - */ - const val javadocTools = "2.0.0-SNAPSHOT.75" -} 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 bcc3530..65ac468 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt @@ -31,12 +31,14 @@ package io.spine.dependency.local * * @see spine-base */ -@Suppress("ConstPropertyName") +@Suppress("ConstPropertyName", "unused") object Base { - const val version = "2.0.0-SNAPSHOT.301" - const val versionForBuildScript = "2.0.0-SNAPSHOT.300" + const val version = "2.0.0-SNAPSHOT.360" + const val versionForBuildScript = "2.0.0-SNAPSHOT.360" const val group = Spine.group const val artifact = "spine-base" const val lib = "$group:$artifact:$version" + const val format = "$group:spine-format:$version" const val libForBuildScript = "$group:$artifact:$versionForBuildScript" + const val annotations = "$group:spine-annotations:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt index 988cab3..b0b534d 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt @@ -33,7 +33,7 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName") object BaseTypes { - const val version = "2.0.0-SNAPSHOT.126" + const val version = "2.0.0-SNAPSHOT.210" const val group = Spine.group const val artifact = "spine-base-types" const val lib = "$group:$artifact:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt index a5728f7..2436580 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt @@ -33,7 +33,7 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName") object Change { - const val version = "2.0.0-SNAPSHOT.118" + const val version = "2.0.0-SNAPSHOT.200" const val group = Spine.group const val artifact = "spine-change" const val lib = "$group:$artifact:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt index b1a00ab..3bb1140 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt @@ -33,7 +33,7 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName", "unused") object Logging { - const val version = "2.0.0-SNAPSHOT.242" + const val version = "2.0.0-SNAPSHOT.411" const val group = Spine.group const val loggingArtifact = "spine-logging" 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 1bb19a1..7a7336b 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt @@ -37,17 +37,17 @@ package io.spine.dependency.local "unused" ) object McJava { - const val group = Spine.toolsGroup + const val group = ToolBase.group /** * The version used to in the build classpath. */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.266" + const val dogfoodingVersion = "2.0.0-SNAPSHOT.320" /** * The version to be used for integration tests. */ - const val version = "2.0.0-SNAPSHOT.266" + const val version = "2.0.0-SNAPSHOT.320" /** * 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 d55e630..c4f06c8 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt @@ -55,7 +55,6 @@ package io.spine.dependency.local "unused" /* Some subprojects do not use ProtoData directly. */, "ConstPropertyName" /* We use custom convention for artifact properties. */, "MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */, - "KDocUnresolvedReference" /* Referencing private properties in constructor KDoc. */ ) object ProtoData { const val pluginGroup = Spine.group @@ -73,7 +72,7 @@ object ProtoData { * The version of ProtoData dependencies. */ val version: String - private const val fallbackVersion = "0.92.11" + private const val fallbackVersion = "0.96.4" /** * The distinct version of ProtoData used by other build tools. @@ -82,7 +81,7 @@ object ProtoData { * transitional dependencies, this is the version used to build the project itself. */ val dogfoodingVersion: String - private const val fallbackDfVersion = "0.92.11" + private const val fallbackDfVersion = "0.96.4" /** * The artifact for the ProtoData Gradle plugin. @@ -164,10 +163,10 @@ object ProtoData { ----------------------------------------- Regular version = v$version Dogfooding version = v$dogfoodingVersion - + ProtoData Gradle plugin can now be loaded from Maven Local. - - To reset the versions, erase the `$$VERSION_ENV` and `$$DF_VERSION_ENV` environment variables. + + To reset the versions, erase the `$$VERSION_ENV` and `$$DF_VERSION_ENV` environment variables. """.trimIndent()) } else { diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt index c811e58..813b4cc 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt @@ -38,7 +38,7 @@ package io.spine.dependency.local ) object ProtoTap { const val group = "io.spine.tools" - const val version = "0.9.1" + const val version = "0.13.0" const val gradlePluginId = "io.spine.prototap" const val api = "$group:prototap-api:$version" const val gradlePlugin = "$group:prototap-gradle-plugin:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt index fbf37f1..12f58a3 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt @@ -33,7 +33,7 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName") object Reflect { - const val version = "2.0.0-SNAPSHOT.191" + const val version = "2.0.0-SNAPSHOT.200" const val group = Spine.group const val artifact = "spine-reflect" const val lib = "$group:$artifact:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt index d7b6d0c..a5cce49 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt @@ -31,87 +31,6 @@ package io.spine.dependency.local */ @Suppress("unused", "ConstPropertyName") object Spine { - const val group = "io.spine" const val toolsGroup = "io.spine.tools" - - @Deprecated(message = "Please use `Base.lib`.", ReplaceWith("Base.lib")) - const val base = Base.lib - - @Deprecated( - message = "Please use `Base.libForBuildScript`.", - ReplaceWith("Base.libForBuildScript") - ) - const val baseForBuildScript = Base.libForBuildScript - - @Deprecated(message = "Please use `Reflect.lib`.", ReplaceWith("Reflect.lib")) - const val reflect = Reflect.lib - - @Deprecated(message = "Please use `BaseTypes.lib`.", ReplaceWith("BaseTypes.lib")) - const val baseTypes = BaseTypes.lib - - @Deprecated(message = "Please use `Time.lib`.", ReplaceWith("Time.lib")) - const val time = Time.lib - - @Deprecated(message = "Please use `Change.lib`.", ReplaceWith("Change.lib")) - const val change = Change.lib - - @Deprecated(message = "Please use `Text.lib`.", ReplaceWith("Text.lib")) - const val text = Text.lib - - @Deprecated(message = "Please use `TestLib.lib`.", ReplaceWith("TestLib.lib")) - const val testlib = TestLib.lib - - @Deprecated(message = "Please use `Time.testLib`.", ReplaceWith("Time.testLib")) - const val testUtilTime = Time.testLib - - @Deprecated(message = "Please use `ToolBase.psiJava` instead`.") - const val psiJava = "$toolsGroup:spine-psi-java:${ToolBase.version}" - - @Deprecated( - message = "Please use `ToolBase.psiJava` instead`.", - ReplaceWith("ToolBase.psiJava") - ) - const val psiJavaBundle = "$toolsGroup:spine-psi-java-bundle:${ToolBase.version}" - - @Deprecated(message = "Please use `ToolBase.lib` instead`.", ReplaceWith("ToolBase.lib")) - const val toolBase = "$toolsGroup:spine-tool-base:${ToolBase.version}" - - @Deprecated( - message = "Please use `ToolBase.pluginBase` instead`.", - ReplaceWith("ToolBase.pluginBase") - ) - const val pluginBase = "$toolsGroup:spine-plugin-base:${ToolBase.version}" - - @Deprecated( - message = "Please use `ToolBase.pluginTestlib` instead`.", - ReplaceWith("ToolBase.pluginTestlib") - ) - const val pluginTestlib = ToolBase.pluginTestlib - - @Deprecated( - message = "Please use `ModelCompiler.lib` instead.", - ReplaceWith("ModelCompiler.lib") - ) - const val modelCompiler = ModelCompiler.lib - - @Deprecated( - message = "Please use top level `McJava` object instead.", - ReplaceWith("McJava", "io.spine.dependency.local.McJava") - ) - val McJava = io.spine.dependency.local.McJava - - const val javadocFilter = "$toolsGroup:spine-javadoc-filter:${ArtifactVersion.javadocTools}" - - @Deprecated( - message = "Please use top level `CoreJava.client` object instead.", - ReplaceWith("CoreJava.client", "io.spine.dependency.local.CoreJava") - ) - const val client = CoreJava.client - - @Deprecated( - message = "Please use top level `CoreJava.server` object instead.", - ReplaceWith("CoreJava.server", "io.spine.dependency.local.CoreJava") - ) - const val server = CoreJava.server } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt index e7e6534..1f3ffc3 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt @@ -33,8 +33,8 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName") object TestLib { - const val version = "2.0.0-SNAPSHOT.185" - const val group = Spine.toolsGroup + const val version = "2.0.0-SNAPSHOT.210" + const val group = ToolBase.group const val artifact = "spine-testlib" const val lib = "$group:$artifact:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt index 56518ec..c10dae5 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt @@ -33,10 +33,10 @@ package io.spine.dependency.local */ @Suppress("ConstPropertyName") object Time { - const val version = "2.0.0-SNAPSHOT.136" + const val version = "2.0.0-SNAPSHOT.203" const val group = Spine.group const val artifact = "spine-time" const val lib = "$group:$artifact:$version" - const val testLib = "${Spine.toolsGroup}:spine-time-testlib:$version" + const val testLib = "${ToolBase.group}:spine-time-testlib:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt index 1227a32..3625a4b 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt @@ -29,18 +29,33 @@ package io.spine.dependency.local /** * Artifacts of the `tool-base` module. * - * @see spine-tool-base + * @see tool-base */ @Suppress("ConstPropertyName", "unused") object ToolBase { - const val group = Spine.toolsGroup - const val version = "2.0.0-SNAPSHOT.300" + const val group = "io.spine.tools" + const val version = "2.0.0-SNAPSHOT.355" - const val lib = "$group:spine-tool-base:$version" - const val pluginBase = "$group:spine-plugin-base:$version" - const val pluginTestlib = "$group:spine-plugin-testlib:$version" + const val lib = "$group:tool-base:$version" + const val pluginBase = "$group:plugin-base:$version" + const val pluginTestlib = "$group:plugin-testlib:$version" + const val intellijPlatform = "$group:intellij-platform:$version" const val intellijPlatformJava = "$group:intellij-platform-java:$version" - const val psiJava = "$group:spine-psi-java:$version" + const val psi = "$group:psi:$version" + const val psiJava = "$group:psi-java:$version" + + const val gradleRootPlugin = "$group:gradle-root-plugin:$version" + const val gradlePluginApi = "$group:gradle-plugin-api:$version" + const val gradlePluginApiTestFixtures = "$group:gradle-plugin-api-test-fixtures:$version" + + const val jvmTools = "$group:jvm-tools:$version" + const val jvmToolPlugins = "$group:jvm-tool-all-plugins:$version" + + object JavadocFilter { + const val group = ToolBase.group + const val version = "2.0.0-SNAPSHOT.75" + const val artifact = "$group:spine-javadoc-filter:$version" + } } 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 ce2ed04..e842283 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt @@ -36,14 +36,20 @@ object Validation { /** * The version of the Validation library artifacts. */ - const val version = "2.0.0-SNAPSHOT.301" + const val version = "2.0.0-SNAPSHOT.351" + + /** + * The last version of Validation compatible with ProtoData. + */ + const val pdCompatibleVersion = "2.0.0-SNAPSHOT.342" const val group = "io.spine.validation" private const val prefix = "spine-validation" const val runtimeModule = "$group:$prefix-java-runtime" const val runtime = "$runtimeModule:$version" - const val java = "$group:$prefix-java:$version" + const val javaModule = "$group:$prefix-java" + const val java = "$javaModule:$version" const val javaBundleModule = "$group:$prefix-java-bundle" @@ -53,5 +59,7 @@ object Validation { val javaBundle = javaBundle(version) const val model = "$group:$prefix-model:$version" - const val config = "$group:$prefix-configuration:$version" + + const val configModule = "$group:$prefix-configuration" + const val configuration = "$configModule:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt index b9a554b..760c116 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt @@ -34,6 +34,6 @@ package io.spine.dependency.test @Deprecated("Please use Kotest assertions instead.") @Suppress("unused", "ConstPropertyName") object AssertK { - private const val version = "0.26.1" + private const val version = "0.28.1" const val libJvm = "com.willowtreeapps.assertk:assertk-jvm:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt index c2dcfe2..e540c2c 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt @@ -35,6 +35,6 @@ package io.spine.dependency.test @Suppress("unused", "ConstPropertyName") object Hamcrest { // https://github.com/hamcrest/JavaHamcrest/releases - private const val version = "2.2" + private const val version = "3.0" const val core = "org.hamcrest:hamcrest-core:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt index c410b42..b07849f 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt @@ -26,39 +26,94 @@ package io.spine.dependency.test +import io.spine.dependency.Dependency +import io.spine.dependency.DependencyWithBom + // https://junit.org/junit5/ @Suppress("unused", "ConstPropertyName") -object JUnit { - const val version = "5.10.0" +object JUnit : DependencyWithBom() { + + override val version = "5.13.2" + override val group: String = "org.junit" + + /** + * The BOM of JUnit. + * + * This one should be forced in a project via: + * + * ```kotlin + * dependencies { + * testImplementation(enforcedPlatform(JUnit.bom)) + * } + * ``` + * The version of JUnit is forced automatically by + * the [BomsPlugin][io.spine.dependency.boms.BomsPlugin] + * when it is applied to the project. + */ + override val bom = "$group:junit-bom:$version" + private const val legacyVersion = "4.13.1" // https://github.com/apiguardian-team/apiguardian private const val apiGuardianVersion = "1.1.2" // https://github.com/junit-pioneer/junit-pioneer - private const val pioneerVersion = "2.0.1" + private const val pioneerVersion = "2.3.0" + const val pioneer = "org.junit-pioneer:junit-pioneer:$pioneerVersion" const val legacy = "junit:junit:$legacyVersion" + @Deprecated("Use JUnit.Jupiter.api instead", ReplaceWith("JUnit.Jupiter.api")) val api = listOf( "org.apiguardian:apiguardian-api:$apiGuardianVersion", "org.junit.jupiter:junit-jupiter-api:$version", "org.junit.jupiter:junit-jupiter-params:$version" ) - const val bom = "org.junit:junit-bom:$version" - const val runner = "org.junit.jupiter:junit-jupiter-engine:$version" - const val params = "org.junit.jupiter:junit-jupiter-params:$version" + @Deprecated("Use JUnit.Jupiter.engine instead", ReplaceWith("JUnit.Jupiter.engine")) + val runner = "org.junit.jupiter:junit-jupiter-engine:$version" - const val pioneer = "org.junit-pioneer:junit-pioneer:$pioneerVersion" + @Deprecated("Use JUnit.Jupiter.params instead", ReplaceWith("JUnit.Jupiter.params")) + val params = "org.junit.jupiter:junit-jupiter-params:$version" + + object Jupiter : Dependency() { + override val version = JUnit.version + override val group = "org.junit.jupiter" + private const val infix = "junit-jupiter" + + // We do not use versions because they are forced via BOM. + val api = "$group:$infix-api" + val params = "$group:$infix-params" + val engine = "$group:$infix-engine" + + @Deprecated("Please use `[Jupiter.run { artifacts[api] }` instead.") + val apiArtifact = "$api:$version" + + override val modules = listOf(api, params, engine) + } + + /** + * The same as [Jupiter.artifacts]. + */ + override val modules = Jupiter.modules + + object Platform : Dependency() { + + /** + * The version of the platform is defined by JUnit BOM. + * + * So when we use JUnit as a platform, this property should be picked up + * for the dependencies automatically. + */ + override val version: String = "1.13.2" + override val group = "org.junit.platform" + + private const val infix = "junit-platform" + val commons = "$group:$infix-commons" + val launcher = "$group:$infix-launcher" + val engine = "$group:$infix-engine" + val suiteApi = "$group:$infix-suite-api" - object Platform { - // https://junit.org/junit5/ - const val version = "1.10.0" - internal const val group = "org.junit.platform" - const val commons = "$group:junit-platform-commons:$version" - const val launcher = "$group:junit-platform-launcher:$version" - const val engine = "$group:junit-platform-engine:$version" - const val suiteApi = "$group:junit-platform-suite-api:$version" + override val modules = listOf(commons, launcher, engine, suiteApi) } } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt index b883928..5f007ec 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt @@ -33,5 +33,5 @@ package io.spine.dependency.test */ @Suppress("ConstPropertyName") object Jacoco { - const val version = "0.8.12" + const val version = "0.8.13" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt index 0e9110b..bde365a 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt @@ -33,7 +33,7 @@ package io.spine.dependency.test */ @Suppress("unused", "ConstPropertyName") object KotlinCompileTesting { - private const val version = "0.7.0" + private const val version = "0.7.1" private const val group = "dev.zacsweers.kctfork" const val libCore = "$group:core:$version" const val libKsp = "$group:ksp:$version" diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt index 759e21a..61897cc 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt @@ -29,7 +29,7 @@ package io.spine.dependency.test // https://github.com/Kotlin/kotlinx-kover @Suppress("unused", "ConstPropertyName") object Kover { - const val version = "0.7.6" + const val version = "0.9.1" const val id = "org.jetbrains.kotlinx.kover" const val classpath = "org.jetbrains.kotlinx:kover-gradle-plugin:$version" } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt index f9af032..cbfb4ad 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt @@ -29,7 +29,7 @@ package io.spine.dependency.test // https://github.com/google/truth @Suppress("unused", "ConstPropertyName") object Truth { - private const val version = "1.1.5" + private const val version = "1.4.4" val libs = listOf( "com.google.truth:truth:$version", "com.google.truth.extensions:truth-java8-extension:$version", diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/ConfigTester.kt b/buildSrc/src/main/kotlin/io/spine/gradle/ConfigTester.kt index 3de99c4..e5c3007 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/ConfigTester.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/ConfigTester.kt @@ -195,7 +195,7 @@ class GitRepository( * to the specified [destinationFolder]. * * The source code is put to the sub-folder named after the repository. - * E.g. for `https://github.com/acme-org/foobar` the code is placed under + * E.g., for `https://github.com/acme-org/foobar` the code is placed under * the `destinationFolder/foobar` folder. * * If the supplied folder does not exist, it is created. diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt index 3b43246..deda203 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt @@ -40,6 +40,15 @@ import org.gradle.kotlin.dsl.getByType * This file contains extension methods and properties for the Gradle `Project`. */ +/** + * Logs the result of the function using the project logger at `INFO` level. + */ +fun Project.log(message: () -> String) { + if (logger.isInfoEnabled) { + logger.info(message.invoke()) + } +} + /** * Obtains the Java plugin extension of the project. */ @@ -68,7 +77,7 @@ fun Project.applyPlugin(cls: Class>) { * the generic parameter `T`. */ @Suppress("UNCHECKED_CAST") /* See the method docs. */ -fun Project.findTask(name: String): T { +fun Project.getTask(name: String): T { val task = this.tasks.findByName(name) ?: error("Unable to find a task named `$name` in the project `${this.name}`.") return task as T diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/RepoSlug.kt b/buildSrc/src/main/kotlin/io/spine/gradle/RepoSlug.kt deleted file mode 100644 index 71fbac3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/RepoSlug.kt +++ /dev/null @@ -1,66 +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.gradle - -import org.gradle.api.GradleException - -/** - * A name of a repository. - */ -class RepoSlug(val value: String) { - - companion object { - - /** - * The name of the environment variable containing the repository slug, for which - * the Gradle build is performed. - */ - private const val environmentVariable = "REPO_SLUG" - - /** - * Reads `REPO_SLUG` environment variable and returns its value. - * - * In case it is not set, a [GradleException] is thrown. - */ - fun fromVar(): RepoSlug { - val envValue = System.getenv(environmentVariable) - if (envValue.isNullOrEmpty()) { - throw GradleException("`REPO_SLUG` environment variable is not set.") - } - return RepoSlug(envValue) - } - } - - override fun toString(): String = value - - /** - * Returns the GitHub URL to the project repository. - */ - fun gitHost(): String { - return "git@github.com-publish:${value}.git" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/Repositories.kt b/buildSrc/src/main/kotlin/io/spine/gradle/Repositories.kt deleted file mode 100644 index 8ec449e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/Repositories.kt +++ /dev/null @@ -1,370 +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. - */ - -@file:Suppress("TooManyFunctions") // Deprecated functions will be kept for a while. - -package io.spine.gradle - -import io.spine.gradle.publish.CloudRepo -import io.spine.gradle.publish.PublishingRepos -import io.spine.gradle.publish.PublishingRepos.gitHub -import java.io.File -import java.net.URI -import java.util.* -import org.gradle.api.Project -import org.gradle.api.artifacts.dsl.RepositoryHandler -import org.gradle.api.artifacts.repositories.MavenArtifactRepository -import org.gradle.kotlin.dsl.ScriptHandlerScope -import org.gradle.kotlin.dsl.maven - -/** - * Applies [standard][doApplyStandard] repositories to this [ScriptHandlerScope] - * optionally adding [gitHub] repositories for Spine-only components, if - * names of such repositories are given. - * - * @param buildscript - * a [ScriptHandlerScope] to work with. Pass `this` under `buildscript { }`. - * @param rootProject - * a root project where the `buildscript` is declared. - * @param gitHubRepo - * a list of short repository names, or empty list if only - * [standard repositories][doApplyStandard] are required. - */ -@Suppress("unused") -@Deprecated( - message = "Please use `standardSpineSdkRepositories()`.", - replaceWith = ReplaceWith("standardSpineSdkRepositories()") -) -fun applyWithStandard( - buildscript: ScriptHandlerScope, - rootProject: Project, - vararg gitHubRepo: String -) { - val repositories = buildscript.repositories - gitHubRepo.iterator().forEachRemaining { repo -> - repositories.applyGitHubPackages(repo, rootProject) - } - repositories.standardToSpineSdk() -} - -/** - * Registers the selected GitHub Packages repos as Maven repositories. - * - * To be used in `buildscript` clauses when a fully-qualified call must be made. - * - * @param repositories - * the handler to accept registration of the GitHub Packages repository - * @param shortRepositoryName - * the short name of the GitHub repository (e.g. "core-java") - * @param project - * the project which is going to consume artifacts from the repository - * @see applyGitHubPackages - */ -@Suppress("unused") -@Deprecated( - message = "Please use `standardSpineSdkRepositories()`.", - replaceWith = ReplaceWith("standardSpineSdkRepositories()") -) -fun doApplyGitHubPackages( - repositories: RepositoryHandler, - shortRepositoryName: String, - project: Project -) = repositories.applyGitHubPackages(shortRepositoryName, project) - -/** - * Registers the standard set of Maven repositories. - * - * To be used in `buildscript` clauses when a fully-qualified call must be made. - */ -@Suppress("unused") -@Deprecated( - message = "Please use `standardSpineSdkRepositories()`.", - replaceWith = ReplaceWith("standardSpineSdkRepositories()") -) -fun doApplyStandard(repositories: RepositoryHandler) = repositories.standardToSpineSdk() - -/** - * Applies the repository hosted at GitHub Packages, to which Spine artifacts were published. - * - * This method should be used by those wishing to have Spine artifacts published - * to GitHub Packages as dependencies. - * - * @param shortRepositoryName - * short names of the GitHub repository (e.g. "base", "core-java", "model-tools") - * @param project - * the project which is going to consume artifacts from repositories - */ -fun RepositoryHandler.applyGitHubPackages(shortRepositoryName: String, project: Project) { - val repository = gitHub(shortRepositoryName) - val credentials = repository.credentials(project) - - credentials?.let { - spineMavenRepo(it, repository.releases) - spineMavenRepo(it, repository.snapshots) - } -} - -/** - * Applies the repositories hosted at GitHub Packages, to which Spine artifacts were published. - * - * This method should be used by those wishing to have Spine artifacts published - * to GitHub Packages as dependencies. - * - * @param shortRepositoryName - * the short name of the GitHub repository (e.g. "core-java") - * @param project - * the project which is going to consume or publish artifacts from - * the registered repository - */ -fun RepositoryHandler.applyGitHubPackages(project: Project, vararg shortRepositoryName: String) { - for (name in shortRepositoryName) { - applyGitHubPackages(name, project) - } -} - -/** - * Applies [standard][applyStandard] repositories to this [RepositoryHandler] - * optionally adding [applyGitHubPackages] repositories for Spine-only components, if - * names of such repositories are given. - * - * @param project - * a project to which we add dependencies - * @param gitHubRepo - * a list of short repository names, or empty list if only - * [standard repositories][applyStandard] are required. - */ -@Suppress("unused") -@Deprecated( - message = "Please use `standardToSpineSdk()`.", - replaceWith = ReplaceWith("standardToSpineSdk()") -) -fun RepositoryHandler.applyStandardWithGitHub(project: Project, vararg gitHubRepo: String) { - gitHubRepo.iterator().forEachRemaining { repo -> - applyGitHubPackages(repo, project) - } - standardToSpineSdk() -} - -/** - * A scrambled version of PAT generated with the only "read:packages" scope. - * - * The scrambling around PAT is necessary because GitHub analyzes commits for the presence - * of tokens and invalidates them. - * - * @see - * How to make GitHub packages to the public - */ -object Pat { - private const val shade = "_phg->8YlN->MFRA->gxIk->HVkm->eO6g->FqHJ->z8MS->H4zC->ZEPq" - private const val separator = "->" - private val chunks: Int = shade.split(separator).size - 1 - - fun credentials(): Credentials { - val pass = shade.replace(separator, "").splitAndReverse(chunks, "") - return Credentials("public", pass) - } - - /** - * Splits this string to the chunks, reverses each chunk, and joins them - * back to a string using the [separator]. - */ - private fun String.splitAndReverse(numChunks: Int, separator: String): String { - check(length / numChunks >= 2) { - "The number of chunks is too big. Must be <= ${length / 2}." - } - val chunks = chunked(length / numChunks) - val reversedChunks = chunks.map { chunk -> chunk.reversed() } - return reversedChunks.joinToString(separator) - } -} - -/** - * Adds a read-only view to all artifacts of the SpineEventEngine - * GitHub organization. - */ -fun RepositoryHandler.spineArtifacts(): MavenArtifactRepository = maven { - url = URI("https://maven.pkg.github.com/SpineEventEngine/*") - includeSpineOnly() - val pat = Pat.credentials() - credentials { - username = pat.username - password = pat.password - } -} - -val RepositoryHandler.intellijReleases: MavenArtifactRepository - get() = maven("https://www.jetbrains.com/intellij-repository/releases") - -val RepositoryHandler.jetBrainsCacheRedirector: MavenArtifactRepository - get() = maven("https://cache-redirector.jetbrains.com/intellij-dependencies") - -/** - * Applies repositories commonly used by Spine Event Engine projects. - */ -fun RepositoryHandler.standardToSpineSdk() { - spineArtifacts() - - val spineRepos = listOf( - Repos.spine, - Repos.spineSnapshots, - Repos.artifactRegistry, - Repos.artifactRegistrySnapshots - ) - - spineRepos - .map { URI(it) } - .forEach { - maven { - url = it - includeSpineOnly() - } - } - - intellijReleases - jetBrainsCacheRedirector - - maven { - url = URI(Repos.sonatypeSnapshots) - } - - mavenCentral() - gradlePluginPortal() - mavenLocal().includeSpineOnly() -} - -@Deprecated( - message = "Please use `standardToSpineSdk() instead.", - replaceWith = ReplaceWith("standardToSpineSdk()") -) -fun RepositoryHandler.applyStandard() = this.standardToSpineSdk() - -/** - * A Maven repository. - */ -data class Repository( - val releases: String, - val snapshots: String, - private val credentialsFile: String? = null, - private val credentialValues: ((Project) -> Credentials?)? = null, - val name: String = "Maven repository `$releases`" -) { - - /** - * Obtains the publishing password credentials to this repository. - * - * If the credentials are represented by a `.properties` file, reads the file and parses - * the credentials. The file must have properties `user.name` and `user.password`, which store - * the username and the password for the Maven repository auth. - */ - fun credentials(project: Project): Credentials? = when { - credentialValues != null -> credentialValues.invoke(project) - credentialsFile != null -> credsFromFile(credentialsFile, project) - else -> throw IllegalArgumentException( - "Credentials file or a supplier function should be passed." - ) - } - - private fun credsFromFile(fileName: String, project: Project): Credentials? { - val file = project.rootProject.file(fileName) - if (file.exists().not()) { - return null - } - - val log = project.logger - log.info("Using credentials from `$fileName`.") - val creds = file.parseCredentials() - log.info("Publishing build as `${creds.username}`.") - return creds - } - - private fun File.parseCredentials(): Credentials { - val properties = Properties().apply { load(inputStream()) } - val username = properties.getProperty("user.name") - val password = properties.getProperty("user.password") - return Credentials(username, password) - } - - override fun toString(): String { - return name - } -} - -/** - * Password credentials for a Maven repository. - */ -data class Credentials( - val username: String?, - val password: String? -) - -/** - * Defines names of additional repositories commonly used in the Spine SDK projects. - * - * @see [applyStandard] - */ -private object Repos { - val spine = CloudRepo.published.releases - val spineSnapshots = CloudRepo.published.snapshots - val artifactRegistry = PublishingRepos.cloudArtifactRegistry.releases - val artifactRegistrySnapshots = PublishingRepos.cloudArtifactRegistry.snapshots - - @Suppress("unused") - @Deprecated( - message = "Sonatype release repository redirects to the Maven Central", - replaceWith = ReplaceWith("sonatypeSnapshots"), - level = DeprecationLevel.ERROR - ) - const val sonatypeReleases = "https://oss.sonatype.org/content/repositories/snapshots" - const val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots" -} - -/** - * Registers the Maven repository with the passed [repoCredentials] for authorization. - * - * Only includes the Spine-related artifact groups. - */ -private fun RepositoryHandler.spineMavenRepo( - repoCredentials: Credentials, - repoUrl: String -) { - maven { - url = URI(repoUrl) - includeSpineOnly() - credentials { - username = repoCredentials.username - password = repoCredentials.password - } - } -} - -/** - * Narrows down the search for this repository to Spine-related artifact groups. - */ -private fun MavenArtifactRepository.includeSpineOnly() { - content { - includeGroupByRegex("io\\.spine.*") - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/RunBuild.kt b/buildSrc/src/main/kotlin/io/spine/gradle/RunBuild.kt index 60a7207..aa2759d 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/RunBuild.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/RunBuild.kt @@ -32,6 +32,6 @@ package io.spine.gradle open class RunBuild : RunGradle() { init { - task("build") + task("clean", "build") } } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/RunGradle.kt b/buildSrc/src/main/kotlin/io/spine/gradle/RunGradle.kt index c1b883a..8942630 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/RunGradle.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/RunGradle.kt @@ -100,7 +100,7 @@ open class RunGradle : DefaultTask() { } @TaskAction - private fun execute() { + public fun execute() { // Ensure build error output log. // Since we're executing this task in another process, we redirect error output to // the file under the `_out` directory. Using the `build` directory for this purpose diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/Runtime.kt b/buildSrc/src/main/kotlin/io/spine/gradle/Runtime.kt index c5b5f54..0a32c33 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/Runtime.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/Runtime.kt @@ -24,6 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +@file:Suppress("unused") + package io.spine.gradle import java.io.File @@ -48,13 +50,14 @@ class Cli(private val workingFolder: File) { /** * Executes the given terminal command and retrieves the command output. * - *

{@link Runtime#exec(String[], String[], File) Executes} the given {@code String} array as - * a CLI command. If the execution is successful, returns the command output. Throws - * an {@link IllegalStateException} otherwise. + * [Executes][Runtime.exec] the given `String` array as a CLI command. + * + * If the execution is successful, returns the command output. + * Throws an [IllegalStateException] otherwise. * - * @param command the command to execute - * @return the command line output - * @throws IllegalStateException upon an execution error + * @param command the command to execute. + * @return the command line output. + * @throws IllegalStateException if the execution fails. */ fun execute(vararg command: String): String { val outWriter = StringWriter() diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt index ab67ffe..bb2a181 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt @@ -28,7 +28,6 @@ package io.spine.gradle.checkstyle import io.spine.dependency.build.CheckStyle import org.gradle.api.Project -import org.gradle.api.plugins.quality.Checkstyle import org.gradle.api.plugins.quality.CheckstyleExtension import org.gradle.api.plugins.quality.CheckstylePlugin import org.gradle.kotlin.dsl.the @@ -57,7 +56,7 @@ object CheckStyleConfig { plugin(CheckstylePlugin::class.java) } - val configDir = project.rootDir.resolve("config/quality/") + val configDir = project.rootDir.resolve("buildSrc/quality/") with(project.the()) { toolVersion = CheckStyle.version @@ -65,9 +64,13 @@ object CheckStyleConfig { } project.afterEvaluate { - // Disables checking the test sources. - val checkstyleTest = project.tasks.findByName("checkstyleTest") as Checkstyle - checkstyleTest.enabled = false + // Disables checking the test sources and test fixtures. + arrayOf( + "checkstyleTest", + "checkstyleTestFixtures" + ).forEach { + task -> tasks.findByName(task)?.enabled = false + } } } } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt index 94ab6ac..ef67c71 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt @@ -26,10 +26,10 @@ package io.spine.gradle.github.pages -import io.spine.gradle.RepoSlug import io.spine.gradle.git.Branch import io.spine.gradle.git.Repository import io.spine.gradle.git.UserInfo +import io.spine.gradle.repo.RepoSlug /** * Clones the current project repository with the branch dedicated to publishing diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt index e46a565..e339dd4 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt @@ -159,7 +159,7 @@ class UpdateGitHubPages : Plugin { includedInputs = extension.includedInputs() if (!allowInternalJavadoc) { - val doclet = ExcludeInternalDoclet(extension.excludeInternalDocletVersion) + val doclet = ExcludeInternalDoclet() doclet.registerTaskIn(this) } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt index 541504c..c42c65c 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt @@ -26,8 +26,7 @@ package io.spine.gradle.javadoc -import io.spine.dependency.local.ArtifactVersion -import io.spine.dependency.local.Spine +import io.spine.dependency.local.ToolBase import io.spine.gradle.javadoc.ExcludeInternalDoclet.Companion.taskName import io.spine.gradle.sourceSets import org.gradle.api.Project @@ -39,12 +38,9 @@ import org.gradle.external.javadoc.StandardJavadocDocletOptions * The doclet which removes Javadoc for `@Internal` things in the Java code. */ @Suppress("ConstPropertyName") -class ExcludeInternalDoclet( - @Deprecated("`Spine.ArtifactVersion.javadocTools` is used instead.") - val version: String = ArtifactVersion.javadocTools -) { +class ExcludeInternalDoclet { - private val dependency = Spine.javadocFilter + private val dependency = ToolBase.JavadocFilter.artifact companion object { diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt index d2e4c90..9616e99 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt @@ -26,11 +26,24 @@ package io.spine.gradle.javadoc +import io.spine.gradle.javadoc.JavadocConfig.tags import java.io.File import org.gradle.api.JavaVersion import org.gradle.api.Project +import org.gradle.api.tasks.TaskContainer import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.external.javadoc.StandardJavadocDocletOptions +import productionModules + +/** + * Finds a [Javadoc] Gradle task by the passed name. + */ +fun TaskContainer.javadocTask(named: String) = this.getByName(named) as Javadoc + +/** + * Finds a default [Javadoc] Gradle task. + */ +fun TaskContainer.javadocTask() = this.getByName("javadoc") as Javadoc /** * Javadoc processing settings. @@ -58,17 +71,25 @@ object JavadocConfig { fun applyTo(project: Project) { val javadocTask = project.tasks.javadocTask() + if (!isProductionModule(project)) { + javadocTask.enabled = false + return + } discardJavaModulesInLinks(javadocTask) val docletOptions = javadocTask.options as StandardJavadocDocletOptions configureDoclet(docletOptions) } + private fun isProductionModule(project: Project) = project.run { + rootProject.productionModules.contains(this) + } + /** - * Discards using of Java 9 modules in URL links generated by javadoc for our codebase. + * Discards using of Java 9 modules in URL links generated by Javadoc for our codebase. * * This fixes navigation to classes through the search results. * - * The issue appeared after migration to Java 11. When javadoc is generated for a project + * The issue appeared after migration to Java 11. When Javadoc is generated for a project * that does not declare Java 9 modules, search results contain broken links with appended * `undefined` prefix to the URL. This `undefined` was meant to be a name of a Java 9 module. * @@ -78,9 +99,9 @@ object JavadocConfig { // We ask `Javadoc` task to modify "search.js" and override a method, responsible for // the formation of URL prefixes. We can't specify the option "--no-module-directories", - // because it leads to discarding of all module prefixes in generated links. That means, - // links to the types from the standard library would not work, as they are declared - // within modules since Java 9. + // because it leads to discarding of all module prefixes in generated links. + // That means links to the types from the standard library would not work, + // as they are declared within modules since Java 9. val discardModulePrefix = """ diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/TaskContainerExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/TaskContainerExtensions.kt deleted file mode 100644 index 7e5b517..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/TaskContainerExtensions.kt +++ /dev/null @@ -1,40 +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.gradle.javadoc - -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.javadoc.Javadoc - -/** - * Finds a [Javadoc] Gradle task by the passed name. - */ -fun TaskContainer.javadocTask(named: String) = this.getByName(named) as Javadoc - -/** - * Finds a default [Javadoc] Gradle task. - */ -fun TaskContainer.javadocTask() = this.getByName("javadoc") as Javadoc diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt index 65cdebd..ea47967 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt @@ -27,7 +27,7 @@ package io.spine.gradle.kotlin import org.gradle.jvm.toolchain.JavaLanguageVersion -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions +import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension /** @@ -52,12 +52,14 @@ fun KotlinJvmProjectExtension.applyJvmToolchain(version: String) = * Opts-in to experimental features that we use in our codebase. */ @Suppress("unused") -fun KotlinJvmCompilerOptions.setFreeCompilerArgs() { +fun KotlinCommonCompilerOptions.setFreeCompilerArgs() { freeCompilerArgs.addAll( listOf( "-Xskip-prerelease-check", "-Xjvm-default=all", "-Xinline-classes", + "-Xexpect-actual-classes", + "-Xcontext-receivers", "-opt-in=" + "kotlin.contracts.ExperimentalContracts," + "kotlin.io.path.ExperimentalPathApi," + diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt index 6816669..b8439a0 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt @@ -24,6 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +@file:Suppress("unused", "UnusedReceiverParameter") /* Extensions declared in this file + are used in the modules that build proto files without using the Spine Compiler. */ + package io.spine.gradle.protobuf import com.google.protobuf.gradle.GenerateProtoTask @@ -34,6 +37,7 @@ import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardOpenOption.TRUNCATE_EXISTING +import kotlin.io.path.Path import org.gradle.api.Project import org.gradle.api.file.SourceDirectorySet import org.gradle.api.tasks.SourceSet @@ -105,10 +109,10 @@ private fun GenerateProtoTask.generatedDir(language: String = ""): File { fun GenerateProtoTask.setup() { builtins.maybeCreate("kotlin") setupDescriptorSetFileCreation() + excludeProtocOutput() doLast { copyGeneratedFiles() } - excludeProtocOutput() setupKotlinCompile() dependOnProcessResourcesTask() makeDirsForIdeaModule() @@ -225,22 +229,35 @@ private fun GenerateProtoTask.deleteComGoogle(language: String) { */ fun GenerateProtoTask.excludeProtocOutput() { val protocOutputDir = File(outputBaseDir).parentFile - val java: SourceDirectorySet = sourceSet.java - // Filter out directories belonging to `build/generated/source/proto`. - val newSourceDirectories = java.sourceDirectories - .filter { !it.residesIn(protocOutputDir) } - .toSet() - // Make sure we start from scratch. - // Not doing this failed the following, real, assignment sometimes. - java.setSrcDirs(listOf()) - java.srcDirs(newSourceDirectories) + /** + * Filter out directories belonging to `build/generated/source/proto`. + */ + fun filterFor(directorySet: SourceDirectorySet) { + val newSourceDirectories = directorySet.sourceDirectories + .filter { !it.residesIn(protocOutputDir) } + .toSet() + // Make sure we start from scratch. + // Not doing this failed the following, real, assignment sometimes. + directorySet.setSrcDirs(listOf()) + directorySet.srcDirs(newSourceDirectories) + } + val java: SourceDirectorySet = sourceSet.java + filterFor(java) // Add copied files to the Java source set. java.srcDir(generatedDir("java")) - java.srcDir(generatedDir("kotlin")) + + val kotlin = sourceSet.kotlin + filterFor(kotlin) + // Add copied files to the Kotlin source set. + kotlin.srcDir(generatedDir("kotlin")) } +private val SourceSet.kotlin: SourceDirectorySet get() = + (this as org.gradle.api.plugins.ExtensionAware).extensions.getByName("kotlin") + as SourceDirectorySet + /** * Make sure Kotlin compilation explicitly depends on this `GenerateProtoTask` to avoid racing. */ @@ -325,18 +342,42 @@ fun IdeaModule.printSourceDirectories() { excludeDirs.forEach { println(it) } } +/** + * Obtains the extension of Protobuf Gradle Plugin in the given project. + */ +val Project.protobufExtension: ProtobufExtension? + get() = extensions.findByType(ProtobufExtension::class.java) + /** * Obtains the directory where the Protobuf Gradle Plugin should place the generated code. * - * The directory is fixed to be `$buildDir/generated/source/proto` and cannot be - * changed by the settings of the plugin. Even though [ProtobufExtension] has a property + * The directory is fixed to be `$buildDir/generated/source/proto` in versions pre v0.9.5 + * and cannot be changed by the settings of the plugin. + * In the v0.9.5 the path was changed to + * [`$buildDir/generated/sources/proto`](https://github.com/google/protobuf-gradle-plugin/releases/tag/v0.9.5). + * + * Even though [ProtobufExtension] has a property * [generatedFilesBaseDir][ProtobufExtension.getGeneratedFilesBaseDir], which is supposed - * to be used for this purpose, it is declared with `@PackageScope` and thus cannot be - * accessed from outside the plugin. The Protobuf Gradle Plugin (at v0.9.2) does not - * modify the value of the property either. + * to be used for this purpose, it is declared with `@PackageScope` (again in earlier versions) + * and thus cannot be accessed from outside the plugin. + * The Protobuf Gradle Plugin (at v0.9.2) does not modify the value of the property either. + * Therefore, we try getting the path using the newer version API and resort to the "legacy" + * convention if the call fails. */ val Project.generatedSourceProtoDir: Path - get() = layout.buildDirectory.dir("generated/source/proto").get().asFile.toPath() + get() { + val legacyPath = layout.buildDirectory.dir("generated/source/proto").get().asFile.toPath() + protobufExtension?.let { + return try { + it.generatedFilesBaseDir.let { Path(it) } + } catch (_: Throwable) { + // Probably we're running on an older version of the Protobuf Gradle Plugin + // which has `package-access` for the `getGeneratedFilesDir()` method. + legacyPath + } + } + return legacyPath + } /** * Ensures that the sources generated by Protobuf Gradle Plugin diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt index 9e38068..1492075 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt @@ -28,8 +28,9 @@ package io.spine.gradle.publish import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES import com.fasterxml.jackson.dataformat.xml.XmlMapper -import io.spine.gradle.Repository +import io.spine.gradle.repo.Repository import java.io.FileNotFoundException +import java.net.URI import java.net.URL import org.gradle.api.DefaultTask import org.gradle.api.GradleException @@ -58,10 +59,11 @@ open class CheckVersionIncrement : DefaultTask() { @TaskAction fun fetchAndCheck() { val artifact = "${project.artifactPath()}/${MavenMetadata.FILE_NAME}" - checkInRepo(repository.snapshots, artifact) + val snapshots = repository.target(snapshots = true) + checkInRepo(snapshots, artifact) - if (repository.releases != repository.snapshots) { - checkInRepo(repository.releases, artifact) + if (!repository.hasOneTarget()) { + checkInRepo(repository.target(snapshots = false), artifact) } } @@ -74,16 +76,16 @@ open class CheckVersionIncrement : DefaultTask() { """ The version `$version` is already published to the Maven repository `$repoUrl`. Try incrementing the library version. - All available versions are: ${versions?.joinToString(separator = ", ")}. - - To disable this check, run Gradle with `-x $name`. + All available versions are: ${versions?.joinToString(separator = ", ")}. + + To disable this check, run Gradle with `-x $name`. """.trimIndent() ) } } private fun fetch(repository: String, artifact: String): MavenMetadata? { - val url = URL("$repository/$artifact") + val url = URI("$repository/$artifact").toURL() return MavenMetadata.fetchAndParse(url) } @@ -135,7 +137,7 @@ private data class MavenMetadata(var versioning: Versioning = Versioning()) { return try { val metadata = mapper.readValue(url, MavenMetadata::class.java) metadata - } catch (ignored: FileNotFoundException) { + } catch (_: FileNotFoundException) { null } } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt index 1cfa7c2..67716d8 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudArtifactRegistry.kt @@ -28,8 +28,8 @@ package io.spine.gradle.publish import com.google.auth.oauth2.GoogleCredentials import com.google.cloud.artifactregistry.auth.DefaultCredentialProvider -import io.spine.gradle.Credentials -import io.spine.gradle.Repository +import io.spine.gradle.repo.Credentials +import io.spine.gradle.repo.Repository import java.io.IOException import org.gradle.api.Project @@ -51,13 +51,15 @@ import org.gradle.api.Project * Ordering said hooks is a non-trivial operation and the result is usually quite fragile. * Thus, we choose to do this small piece of configuration manually. */ +@Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names internal object CloudArtifactRegistry { private const val spineRepoLocation = "https://europe-maven.pkg.dev/spine-event-engine" val repository = Repository( - releases = "${spineRepoLocation}/releases", - snapshots = "${spineRepoLocation}/snapshots", + name = "CloudArtifactRegistry", + releases = "$spineRepoLocation/releases", + snapshots = "$spineRepoLocation/snapshots", credentialValues = this::fetchGoogleCredentials ) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt index 7db15aa..624f5cb 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt @@ -26,15 +26,16 @@ package io.spine.gradle.publish -import io.spine.gradle.Repository +import io.spine.gradle.repo.Repository /** * CloudRepo Maven repository. * * There is a special treatment for this repository. Usually, fetching and publishing of artifacts * is performed via the same URL. But it is not true for CloudRepo. Fetching is performed via - * the public repository, and publishing via the private one. Their URLs differ in `/public` infix. + * the public repository and publishing via the private one. Their URLs differ in `/public` infix. */ +@Deprecated(message = "Please use `PublishingRepos.cloudArtifactRegistry` instead.") internal object CloudRepo { private const val name = "CloudRepo" diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/GitHubPackages.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/GitHubPackages.kt index 1072139..df326b8 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/GitHubPackages.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/GitHubPackages.kt @@ -26,8 +26,8 @@ package io.spine.gradle.publish -import io.spine.gradle.Credentials -import io.spine.gradle.Repository +import io.spine.gradle.repo.Credentials +import io.spine.gradle.repo.Repository import io.spine.gradle.buildDirectory import net.lingala.zip4j.ZipFile import org.gradle.api.Project @@ -42,12 +42,12 @@ internal object GitHubPackages { */ fun repository(repoName: String): Repository { val githubActor: String = actor() + val url = "https://maven.pkg.github.com/SpineEventEngine/$repoName" return Repository( - name = "GitHub Packages", - releases = "https://maven.pkg.github.com/SpineEventEngine/$repoName", - snapshots = "https://maven.pkg.github.com/SpineEventEngine/$repoName", - credentialValues = { project -> project.credentialsWithToken(githubActor) } - ) + name = "GitHub-Packages", + releases = url, + snapshots = url + ) { project -> project.credentialsWithToken(githubActor) } } private fun actor(): String { diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/Publications.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/Publications.kt deleted file mode 100644 index c9acef8..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/Publications.kt +++ /dev/null @@ -1,234 +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.gradle.publish - -import io.spine.gradle.Repository -import io.spine.gradle.isSnapshot -import org.gradle.api.Project -import org.gradle.api.artifacts.dsl.RepositoryHandler -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Jar -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.create - -/** - * The name of the Maven Publishing Gradle plugin. - */ -private const val MAVEN_PUBLISH = "maven-publish" - -/** - * Abstract base for handlers of publications in a project - * with [spinePublishing] settings declared. - */ -internal sealed class PublicationHandler( - protected val project: Project, - private val destinations: Set -) { - - fun apply() = with(project) { - if (!hasCustomPublishing) { - apply(plugin = MAVEN_PUBLISH) - } - - pluginManager.withPlugin(MAVEN_PUBLISH) { - handlePublications() - registerDestinations() - configurePublishTask(destinations) - } - } - - /** - * Either handles publications already declared in the given project, - * or creates new ones. - */ - abstract fun handlePublications() - - /** - * Goes through the [destinations] and registers each as a repository for publishing - * in the given Gradle project. - */ - private fun registerDestinations() { - val repositories = project.publishingExtension.repositories - destinations.forEach { destination -> - repositories.register(project, destination) - } - } - - /** - * Copies the attributes of Gradle [Project] to this [MavenPublication]. - * - * The following project attributes are copied: - * * [group][Project.getGroup]; - * * [version][Project.getVersion]; - * * [description][Project.getDescription]. - * - * Also, this function adds the [artifactPrefix][SpinePublishing.artifactPrefix] to - * the [artifactId][MavenPublication.setArtifactId] of this publication, - * if the prefix is not added yet. - * - * Finally, the Apache Software License 2.0 is set as the only license - * under which the published artifact is distributed. - */ - protected fun MavenPublication.copyProjectAttributes() { - groupId = project.group.toString() - val prefix = project.spinePublishing.artifactPrefix - if (!artifactId.startsWith(prefix)) { - artifactId = prefix + artifactId - } - version = project.version.toString() - pom.description.set(project.description) - - pom.licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - } -} - -/** - * Adds a Maven repository to the project specifying credentials, if they are - * [available][Repository.credentials] from the root project. - */ -private fun RepositoryHandler.register(project: Project, repository: Repository) { - val isSnapshot = project.version.toString().isSnapshot() - val target = if (isSnapshot) repository.snapshots else repository.releases - val credentials = repository.credentials(project.rootProject) - maven { - url = project.uri(target) - credentials { - username = credentials?.username - password = credentials?.password - } - } -} - -/** - * A publication for a typical Java project. - * - * In Gradle, to publish something, one should create a publication. - * A publication has a name and consists of one or more artifacts plus information about - * those artifacts – the metadata. - * - * An instance of this class represents [MavenPublication] named "mavenJava". It is generally - * accepted that a publication with this name contains a Java project published to one or - * more Maven repositories. - * - * By default, only a jar with the compilation output of `main` source set and its - * metadata files are published. Other artifacts are specified through the - * [constructor parameter][jarFlags]. Please, take a look on [specifyArtifacts] for additional info. - * - * @param jarFlags - * flags for additional JARs published along with the compilation output. - * @param destinations - * Maven repositories to which the produced artifacts will be sent. - * @see - * Maven Publish Plugin | Publications - */ -internal class StandardJavaPublicationHandler( - project: Project, - private val jarFlags: JarFlags, - destinations: Set, -) : PublicationHandler(project, destinations) { - - /** - * Creates a new "mavenJava" [MavenPublication] in the given project. - */ - override fun handlePublications() { - val jars = project.artifacts(jarFlags) - val publications = project.publications - publications.create("mavenJava") { - copyProjectAttributes() - specifyArtifacts(jars) - } - } - - /** - * Specifies which artifacts this [MavenPublication] will contain. - * - * A typical Maven publication contains: - * - * 1. Jar archives. For example, compilation output, sources, javadoc, etc. - * 2. Maven metadata file that has the ".pom" extension. - * 3. Gradle's metadata file that has the ".module" extension. - * - * Metadata files contain information about a publication itself, its artifacts, and their - * dependencies. Presence of ".pom" file is mandatory for publication to be consumed by - * `mvn` build tool itself or other build tools that understand Maven notation (Gradle, Ivy). - * The presence of ".module" is optional, but useful when a publication is consumed by Gradle. - * - * @see Maven – POM Reference - * @see - * Understanding Gradle Module Metadata - */ - private fun MavenPublication.specifyArtifacts(jars: Set>) { - - /* "java" component provides a jar with compilation output of "main" source set. - It is NOT defined as another `Jar` task intentionally. Doing that will leave the - publication without correct ".pom" and ".module" metadata files generated. - */ - val javaComponent = project.components.findByName("java") - javaComponent?.let { - from(it) - } - - /* Other artifacts are represented by `Jar` tasks. Those artifacts don't bring any other - metadata in comparison with `Component` (such as dependencies notation). - */ - jars.forEach { - artifact(it) - } - } -} - -/** - * A handler for custom publications, which are declared under the [publications] - * section of a module. - * - * Such publications should be treated differently than [StandardJavaPublicationHandler], - * which is created for a module. Instead, since the publications are already declared, - * this class only [assigns maven coordinates][copyProjectAttributes]. - * - * A module which declares custom publications must be specified in - * the [SpinePublishing.modulesWithCustomPublishing] property. - * - * If a module with [publications] declared locally is not specified as one with custom publishing, - * it may cause a name clash between an artifact produced by the [standard][MavenPublication] - * publication, and custom ones. To have both standard and custom publications, - * please specify custom artifact IDs or classifiers for each custom publication. - */ -internal class CustomPublicationHandler(project: Project, destinations: Set) : - PublicationHandler(project, destinations) { - - override fun handlePublications() { - project.publications.forEach { - (it as MavenPublication).copyProjectAttributes() - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt index 62c639b..0a24b56 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt @@ -27,7 +27,8 @@ package io.spine.gradle.publish import dokkaKotlinJar -import io.spine.gradle.Repository +import io.spine.gradle.isSnapshot +import io.spine.gradle.repo.Repository import io.spine.gradle.sourceSets import java.util.* import org.gradle.api.InvalidUserDataException @@ -57,6 +58,13 @@ internal val Project.publishingExtension: PublishingExtension internal val Project.publications: PublicationContainer get() = publishingExtension.publications +/** + * Obtains an instance, if available, of [SpinePublishing] extension + * applied to this project. + */ +internal val Project.localSpinePublishing: SpinePublishing? + get() = extensions.findByType() + /** * Obtains [SpinePublishing] extension from this [Project]. * @@ -65,7 +73,7 @@ internal val Project.publications: PublicationContainer */ internal val Project.spinePublishing: SpinePublishing get() { - val local = this.extensions.findByType() + val local = localSpinePublishing if (local != null) { return local } @@ -78,9 +86,16 @@ internal val Project.spinePublishing: SpinePublishing /** * Tells if this project has custom publishing. + * + * For a multi-module project this is checked by presence of this project + * in the list of [SpinePublishing.modulesWithCustomPublishing] of the root project. + * + * In a single-module project, the value of the [SpinePublishing.customPublishing] + * property is returned. */ internal val Project.hasCustomPublishing: Boolean - get() = spinePublishing.modulesWithCustomPublishing.contains(name) + get() = rootProject.spinePublishing.modulesWithCustomPublishing.contains(name) + || spinePublishing.customPublishing private const val PUBLISH_TASK = "publish" @@ -93,7 +108,7 @@ private const val PUBLISH_TASK = "publish" * Please note, task execution would not copy publications to the local Maven cache. * * @see - * Tasks | Maven Publish Plugin + * Tasks | The Maven Publish Plugin */ internal val TaskContainer.publish: TaskProvider get() = named(PUBLISH_TASK) @@ -140,14 +155,45 @@ private fun TaskContainer.getOrCreatePublishTask(): TaskProvider = register(PUBLISH_TASK) } +@Suppress( + /* Several types of exceptions may be thrown, + and Kotlin does not have a multi-catch support yet. */ + "TooGenericExceptionCaught" +) private fun TaskContainer.registerCheckCredentialsTask( - destinations: Set -): TaskProvider = - register("checkCredentials") { - doLast { - destinations.forEach { it.ensureCredentials(project) } + destinations: Set, +): TaskProvider { + val checkCredentials = "checkCredentials" + try { + // The result of this call is ignored intentionally. + // + // We expect this line to fail with the exception + // in case the task with this name is NOT registered. + // + // Otherwise, we need to replace the existing task + // to avoid checking the credentials + // for some previously asked `destinations`. + named(checkCredentials) + val toConfigure = replace(checkCredentials) + toConfigure.doLastCredentialsCheck(destinations) + return named(checkCredentials) + } catch (_: Exception) { + return register(checkCredentials) { doLastCredentialsCheck(destinations) } + } +} + +private fun Task.doLastCredentialsCheck(destinations: Set) { + doLast { + if (logger.isDebugEnabled) { + val isSnapshot = project.version.toString().isSnapshot() + val destinationsStr = destinations.joinToString(", ") { it.target(isSnapshot) } + logger.debug( + "Project '${project.name}': checking the credentials for repos: $destinationsStr." + ) } + destinations.forEach { it.ensureCredentials(project) } } +} private fun Repository.ensureCredentials(project: Project) { val credentials = credentials(project) @@ -175,8 +221,8 @@ fun TaskContainer.excludeGoogleProtoFromArtifacts() { * Locates or creates `sourcesJar` task in this [Project]. * * The output of this task is a `jar` archive. The archive contains sources from `main` source set. - * The task makes sure that sources from the directories below will be included into - * a resulted archive: + * The task makes sure that sources from the directories below will be included + * in the resulting archive: * * - Kotlin * - Java @@ -220,8 +266,8 @@ internal fun Project.testJar(): TaskProvider = tasks.getOrCreate("testJar") * Locates or creates `javadocJar` task in this [Project]. * * The output of this task is a `jar` archive. The archive contains Javadoc, - * generated upon Java sources from `main` source set. If javadoc for Kotlin is also needed, - * apply Dokka plugin. It tunes `javadoc` task to generate docs upon Kotlin sources as well. + * generated upon Java sources from `main` source set. If Javadoc for Kotlin is also needed, + * apply the Dokka plugin. It tunes `javadoc` task to generate docs upon Kotlin sources as well. */ fun Project.javadocJar(): TaskProvider = tasks.getOrCreate("javadocJar") { archiveClassifier.set("javadoc") @@ -275,4 +321,3 @@ internal fun Project.artifacts(jarFlags: JarFlags): Set> { return tasks } - diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingRepos.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingRepos.kt index f383e68..eea6dc1 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingRepos.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingRepos.kt @@ -26,7 +26,7 @@ package io.spine.gradle.publish -import io.spine.gradle.Repository +import io.spine.gradle.repo.Repository /** * Repositories to which we may publish. diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt index 2f74536..9dc7d7c 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt @@ -28,9 +28,7 @@ package io.spine.gradle.publish -import dokkaJavaJar -import dokkaKotlinJar -import io.spine.gradle.Repository +import io.spine.gradle.repo.Repository import org.gradle.api.Project import org.gradle.api.publish.maven.plugins.MavenPublishPlugin import org.gradle.kotlin.dsl.apply @@ -44,75 +42,112 @@ import org.gradle.kotlin.dsl.findByType * * The extension can be configured for single- and multi-module projects. * + * ## Using in a multi-module project + * * When used with a multi-module project, the extension should be opened in a root project's * build file. The published modules are specified explicitly by their names: * - * ``` + * ```kotlin * spinePublishing { * modules = setOf( * "subprojectA", * "subprojectB", * ) - * destinations = setOf( - * PublishingRepos.cloudRepo, - * PublishingRepos.cloudArtifactRegistry, + * destinations = PublishingRepos.run { setOf( + * cloudArtifactRegistry, + * gitHub("") // The name of the GitHub repository of the project. + * )} + * } + * ``` + * + * ### Filtering out test-only modules + * + * Sometimes a functional or an integration test requires a significant amount of + * configuration code which is better understood when isolated into a separate module. + * Conventionally, we use the `-tests` suffix for naming such modules. + * + * In order to avoid publishing of such a test-only module, we use the following extensions + * for the Gradle [Project] class: [productionModules], [productionModuleNames]. + * So the above code for specifying the modules to publish could be rewritten as follows: + * + * ```kotlin + * spinePublishing { + * modules = productionModuleNames.toSet() + * } + * ``` + * This code works for most of the projects. + * + * ### Arranging custom publishing for a module + * ```kotlin + * + * 1. Modify the list of standardly published modules in the root project like this: + * + * ```kotlin + * spinePublishing { + * modules = productionModuleNames + * .minus("my-custom-module") + * .toSet() + * + * modulesWithCustomPublishing = setOf( + * "my-custom-module" * ) + * + * // ... * } * ``` + * 2. Arrange the custom publishing in the `my-custom-module` project. + * + * ## Using in a single-module project * * When used with a single-module project, the extension should be opened in a project's build file. * Only destinations should be specified: * - * ``` + * ```kotlin * spinePublishing { - * destinations = setOf( - * PublishingRepos.cloudRepo, - * PublishingRepos.cloudArtifactRegistry, - * ) + * destinations = PublishingRepos.run { setOf( + * cloudArtifactRegistry, + * gitHub("") + * )} * } * ``` * - * It is worth to mention, that publishing of a module can be configured only from a single place. + * ## Publishing modules + * + * It is worth mentioning that publishing of a module can be configured only from a single place. * For example, declaring `subprojectA` as published in a root project and opening * `spinePublishing` extension within `subprojectA` itself would lead to an exception. * - * In Gradle, in order to publish something somewhere one should create a publication. In each + * In Gradle, in order to publish something somewhere, one should create a publication. In each * of published modules, the extension will create a [publication][StandardJavaPublicationHandler] - * named "mavenJava". All artifacts, published by this extension belong to this publication. + * named "mavenJava". All artifacts published by this extension belong to this publication. * - * By default, along with the compilation output of "main" source set, the extension publishes + * ## Published artifacts + * + * By default, along with the compilation output of the `main` source set, the extension publishes * the following artifacts: * - * 1. [sourcesJar] – sources from "main" source set. Includes "hand-made" Java, - * Kotlin and Proto files. In order to include the generated code into this artifact, a module - * should specify those files as a part of "main" source set. - * - * Here's an example of how to do that: - * - * ``` - * sourceSets { - * val generatedDir by extra("$projectDir/generated") - * val generatedSpineDir by extra("$generatedDir/main/java") - * main { - * java.srcDir(generatedSpineDir) - * } - * } - * ``` - * 2. [protoJar] – only Proto sources from "main" source set. It's published only if + * 1. [sourcesJar] — sources from the `main` source set. Includes handcrafted and generated + * code in Java, Kotlin, and `.proto` files. + * + * 2. [protoJar] – only `.proto` sources from the `main` source set. It's published only if * Proto files are actually present in the source set. Publication of this artifact is optional * and can be disabled via [SpinePublishing.protoJar]. - * 3. [javadocJar] - javadoc, generated upon Java sources from "main" source set. - * If javadoc for Kotlin is also needed, apply Dokka plugin. It tunes `javadoc` task to generate - * docs upon Kotlin sources as well. - * 4. [dokkaKotlinJar] - documentation generated by Dokka for Kotlin and Java sources + * + * 3. [javadocJar] — Javadoc, generated upon Java sources from the `main` source set. + * If Javadoc for Kotlin is also needed, apply the Dokka plugin. + * It tunes the `javadoc` task to generate docs upon Kotlin sources as well. + * + * 4. [dokkaKotlinJar] — documentation generated by Dokka for Kotlin and Java sources * using the Kotlin API mode. - * 5. [dokkaJavaJar] - documentation generated by Dokka for Kotlin and Java sources - * * using the Java API mode. + * + * 5. [dokkaJavaJar] — documentation generated by Dokka for Kotlin and Java sources + * using the Java API mode. * * Additionally, [testJar] artifact can be published. This artifact contains compilation output - * of "test" source set. Use [SpinePublishing.testJar] to enable its publishing. + * of the `test` source set. Use [SpinePublishing.testJar] to enable its publishing. * * @see [artifacts] + * @see SpinePublishing */ fun Project.spinePublishing(block: SpinePublishing.() -> Unit) { apply() @@ -127,11 +162,19 @@ fun Project.spinePublishing(block: SpinePublishing.() -> Unit) { } /** - * A Gradle extension for setting up publishing of spine modules using `maven-publish` plugin. + * A Gradle extension for setting up publishing of modules of Spine SDK modules + * using `maven-publish` plugin. + * + * ### Implementation Note + * + * This extension is overloaded with responsibilities. + * It basically does what an extension AND a Gradle plugin would normally do. + * + * We [should introduce a plugin class](https://github.com/SpineEventEngine/config/issues/562) + * and move the code related to creating tasks or setting dependencies between them into the plugin. * - * @param project - * a project in which the extension is opened. By default, this project will be - * published as long as a [set][modules] of modules to publish is not specified explicitly. + * @param project The project in which the extension is opened. By default, this project will be + * published as long as a [set][modules] of modules to publish is not specified explicitly. * * @see spinePublishing */ @@ -163,18 +206,27 @@ open class SpinePublishing(private val project: Project) { var modules: Set = emptySet() /** - * Controls whether the published module needs standard publications. + * Controls whether the [module][project] needs standard publications. * - * If `true`, the module should configure publications on its own. - * Otherwise, the extension will configure standard [ones][StandardJavaPublicationHandler]. + * Default value is `false`. + * + * In a single module [project], settings this property to `true` it tells + * that the project configures the publication in a specific way and + * [CustomPublicationHandler] should be used. + * Otherwise, the extension will configure the + * [standard publication][StandardJavaPublicationHandler]. * - * This property is analogue of [modulesWithCustomPublishing] for projects, + * This property is an analogue of [modulesWithCustomPublishing] in + * [multi-module][Project.getSubprojects] projects, * for which [spinePublishing] is configured individually. * - * Setting of this property and having a non-empty [modules] will lead - * to an exception. + * Setting of this property to `true` and having a non-empty [modules] property + * in the project to which the extension is applied will lead to [IllegalStateException]. * - * Default value is `false`. + * Settings this property to `true` in a subproject serves only the documentation purposes. + * This subproject still must be listed in the [modulesWithCustomPublishing] property in + * the extension of the [rootProject][Project.getRootProject], so that its publication + * can be configured in a specific way. */ var customPublishing = false @@ -191,17 +243,17 @@ open class SpinePublishing(private val project: Project) { * Usually, Spine-related projects are published to one or more repositories, * declared in [PublishingRepos]: * - * ``` - * destinations = setOf( - * PublishingRepos.cloudRepo, - * PublishingRepos.cloudArtifactRegistry, - * PublishingRepos.gitHub("base"), - * ) + * ```kotlin + * destinations = PublishingRepos.run { setOf( + * cloudArtifactRegistry, + * gitHub("") // The name of the GitHub repository of the project. + * )} * ``` * - * Empty by default. + * If the property is not initialized, the destinations will be taken from + * the parent project. */ - var destinations: Set = emptySet() + lateinit var destinations: Set /** * A prefix to be added before the name of each artifact. @@ -214,7 +266,7 @@ open class SpinePublishing(private val project: Project) { * * Here's an example of how to disable it for some of the published modules: * - * ``` + * ```kotlin * spinePublishing { * modules = setOf( * "subprojectA", @@ -238,7 +290,7 @@ open class SpinePublishing(private val project: Project) { * } * ``` * - * The resulting artifact is available under "proto" classifier. + * The resulting artifact is available under the "proto" classifier. * For example, in Gradle 7+, one could depend on it like this: * * ``` @@ -277,8 +329,8 @@ open class SpinePublishing(private val project: Project) { * } * ``` * - * The resulting artifact is available under "test" classifier. For example, - * in Gradle 7+, one could depend on it like this: + * The resulting artifact is available under the "test" classifier. + * For example, in Gradle 7+, one could depend on it like this: * * ``` * implementation("io.spine:spine-client:$version@test") @@ -310,7 +362,7 @@ open class SpinePublishing(private val project: Project) { * } * ``` * - * The resulting artifact is available under "dokka" classifier. + * The resulting artifact is available under the "dokka" classifier. */ fun dokkaJar(block: DokkaJar.() -> Unit) = dokkaJar.run(block) @@ -367,27 +419,47 @@ open class SpinePublishing(private val project: Project) { * * We selected to use [Project.afterEvaluate] so that we can configure publishing of multiple * modules from a root project. When we do this, we configure publishing for a module, - * build file of which has not been even evaluated yet. + * a build file of which has not been even evaluated yet. * * The simplest example here is specifying of `version` and `group` for Maven coordinates. - * Let's suppose, they are declared in a module's build file. It is a common practice. - * But publishing of the module is configured from a root project's build file. By the time, - * when we need to specify them, we just don't know them. As a result, we have to use - * [Project.afterEvaluate] in order to guarantee that a module will be configured by the time - * we configure publishing for it. + * Let's suppose they are declared in a module's build file. It is a common practice. + * But publishing of the module is configured from a root project's build file. + * By the time when we need to specify them, we just don't know them. + * As the result, we have to use [Project.afterEvaluate] in order to guarantee that + * the module will be configured by the time we configure publishing for it. */ private fun Project.setUpPublishing(jarFlags: JarFlags) { val customPublishing = modulesWithCustomPublishing.contains(name) || customPublishing + val destinations = project.publishTo() val handler = if (customPublishing) { - CustomPublicationHandler(project, destinations) + CustomPublicationHandler.serving(project, destinations) } else { - StandardJavaPublicationHandler(project, jarFlags, destinations) + StandardJavaPublicationHandler.serving(project, destinations, jarFlags) } afterEvaluate { handler.apply() } } + /** + * Obtains the set of repositories for publishing. + * + * If there is a local instance of [io.spine.gradle.publish.SpinePublishing] extension, + * the [destinations] are obtained from this instance. + * Otherwise, the function attempts to obtain it from a [parent project][Project.getParent]. + * If there is no a parent project, an empty set is returned. + * + * The normal execution should end up at the root project of a multi-module project + * if there are no custom destinations specified by the local extension. + */ + private fun Project.publishTo(): Set { + val ext = localSpinePublishing + if (ext != null && ext::destinations.isInitialized) { + return destinations + } + return parent?.publishTo() ?: emptySet() + } + /** * Obtains an artifact ID for the given project. * @@ -406,8 +478,11 @@ open class SpinePublishing(private val project: Project) { private fun ensureProtoJarExclusionsArePublished() { val nonPublishedExclusions = protoJar.exclusions.minus(modules) if (nonPublishedExclusions.isNotEmpty()) { - throw IllegalStateException("One or more modules are marked as `excluded from proto " + - "JAR publication`, but they are not even published: $nonPublishedExclusions") + error( + "One or more modules are marked as" + + " `excluded from proto JAR publication`," + + " but they are not even published: $nonPublishedExclusions." + ) } } @@ -431,7 +506,7 @@ open class SpinePublishing(private val project: Project) { /** * Ensures that publishing of a module is configured only from a single place. * - * We allow configuration of publishing from two places - a root project and module itself. + * We allow configuration of publishing from two places - a root project and the module itself. * Here we verify that publishing of a module is not configured in both places simultaneously. */ private fun ensureModulesNotDuplicated() { diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt index a5b9e72..efdf605 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt @@ -29,7 +29,6 @@ package io.spine.gradle.report.coverage import com.google.errorprone.annotations.CanIgnoreReturnValue import io.spine.gradle.report.coverage.FileFilter.generatedOnly import java.io.File -import kotlin.streams.toList import org.gradle.api.Project import org.gradle.api.file.ConfigurableFileTree import org.gradle.api.file.FileTree diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt index de5d00b..5114add 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt @@ -28,7 +28,7 @@ package io.spine.gradle.report.coverage import io.spine.dependency.test.Jacoco import io.spine.gradle.applyPlugin -import io.spine.gradle.findTask +import io.spine.gradle.getTask import io.spine.gradle.report.coverage.TaskName.check import io.spine.gradle.report.coverage.TaskName.copyReports import io.spine.gradle.report.coverage.TaskName.jacocoRootReport @@ -181,7 +181,7 @@ class JacocoConfig( private fun registerCopy(tasks: TaskContainer): TaskProvider { val everyExecData = mutableListOf() projects.forEach { project -> - val jacocoTestReport = project.findTask(jacocoTestReport.name) + val jacocoTestReport = project.getTask(jacocoTestReport.name) val executionData = jacocoTestReport.executionData everyExecData.add(executionData) } @@ -194,7 +194,7 @@ class JacocoConfig( rename { "${UUID.randomUUID()}.exec" } - dependsOn(projects.map { it.findTask(jacocoTestReport.name) }) + dependsOn(projects.map { it.getTask(jacocoTestReport.name) }) } return copyReports } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt index 9b7a57f..ec86eb5 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt @@ -30,7 +30,7 @@ import com.github.jk1.license.LicenseReportExtension import com.github.jk1.license.LicenseReportExtension.ALL import com.github.jk1.license.LicenseReportPlugin import io.spine.gradle.applyPlugin -import io.spine.gradle.findTask +import io.spine.gradle.getTask import java.io.File import org.gradle.api.Project import org.gradle.api.Task @@ -98,7 +98,7 @@ object LicenseReporter { } /** - * Tells to merge all per-project reports which were previously [generated][generateReportIn] + * Tells to merge all per-project reports that were previously [generated][generateReportIn] * for each of the subprojects of the root Gradle project. * * The merge result is placed according to [Paths]. @@ -109,10 +109,10 @@ object LicenseReporter { val rootProject = project.rootProject val mergeTask = rootProject.tasks.register(mergeTaskName) { val consolidationTask = this - val assembleTask = project.findTask("assemble") + val assembleTask = project.getTask("assemble") val sourceProjects: Iterable = sourceProjects(rootProject) sourceProjects.forEach { - val perProjectTask = it.findTask(projectTaskName) + val perProjectTask = it.getTask(projectTaskName) consolidationTask.dependsOn(perProjectTask) perProjectTask.dependsOn(assembleTask) } @@ -121,7 +121,7 @@ object LicenseReporter { } dependsOn(assembleTask) } - project.findTask("build") + project.getTask("build") .finalizedBy(mergeTask) } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt index 0aca30f..91247e2 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt @@ -91,7 +91,6 @@ private fun MarkdownDocument.print( return this } - /** * Prints the URL to the project which provides the dependency. * diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt index adda37b..15bd24d 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt @@ -28,7 +28,7 @@ package io.spine.gradle.report.license import io.spine.docs.MarkdownDocument import io.spine.gradle.artifactId -import java.util.* +import java.util.Date import org.gradle.api.Project /** @@ -40,32 +40,33 @@ internal class Template( ) { private companion object { + @Suppress("ConstPropertyName") private const val longBreak = "\n\n" } - internal fun writeHeader() { + internal fun writeHeader() = with(project) { out.nl() - .h1( - "Dependencies of " + - "`${project.group}:${project.artifactId}:${project.version}`" - ) - .nl() + .h1("Dependencies of `$group:$artifactId:$version`") + .nl() } internal fun writeFooter() { + val currentTime = Date() out.text(longBreak) .text("The dependencies distributed under several licenses, ") .text("are used according their commercial-use-friendly license.") .text(longBreak) .text("This report was generated on ") - .bold("${Date()}") + .bold("$currentTime") .text(" using ") + .nl() .link( "Gradle-License-Report plugin", "https://github.com/jk1/Gradle-License-Report" ) .text(" by Evgeny Naumenko, ") .text("licensed under ") + .nl() .link( "Apache 2.0 License", "https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE" diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt index af3873c..eda2493 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt @@ -182,8 +182,8 @@ private fun Project.deduplicate(dependencies: Set): List - group.value.maxByOrNull { dep -> dep.version }!! - } + group.value.maxByOrNull { dep -> dep.version ?: "" } + }.filterNotNull() return filtered } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt index 13d4177..3d72de1 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt @@ -40,7 +40,7 @@ internal class ModuleDependency( val project: Project, val configuration: Configuration, private val dependency: Dependency, - private val factualVersion: String = dependency.version!! + private val factualVersion: String? = dependency.version ) : Dependency by dependency, Comparable { @@ -52,7 +52,7 @@ internal class ModuleDependency( .thenBy { it.factualVersion } } - override fun getVersion(): String = factualVersion + override fun getVersion(): String? = factualVersion /** * A project dependency with its [scope][DependencyScope]. diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt index ba673bb..15059ea 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt @@ -92,7 +92,7 @@ internal object PomFormatting { * Writes the specified lines using the specified [destination], dividing them * by platform-specific line separator. * - * The written lines are also padded with platform's line separator from both sides + * Each written line is followed by two platform-specific line separators. */ internal fun writeBlocks(destination: StringWriter, vararg lines: String) { lines.iterator().forEach { 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 9144e2f..6e986e1 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 @@ -57,7 +57,8 @@ import org.gradle.api.plugins.BasePlugin * * By default, those values are taken from the `project` object, which may or may not include * them. If the project does not have these values, and they are not specified in the `ext` - * block, the resulting `pom.xml` file is going to contain empty blocks, e.g. ``. + * block, the resulting `pom.xml` file is going to contain empty blocks, + * e.g., ``. */ @Suppress("unused") object PomGenerator { @@ -68,8 +69,11 @@ object PomGenerator { fun applyTo(project: Project) { /** - * In some cases, the `base` plugin, which is by default is added by e.g. `java`, - * is not yet added. `base` plugin defines the `build` task. This generator needs it. + * In some cases, the `base` plugin, which by default is added by e.g. `java`, + * is not yet added. + * + * The `base` plugin defines the `build` task. + * This generator needs it. */ project.apply { plugin(BasePlugin::class.java) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt index 5312219..a0b1ade 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt @@ -35,9 +35,9 @@ import java.io.StringWriter /** * Writes the dependencies of a Gradle project and its subprojects as a `pom.xml` file. * - * The resulting file is not usable for `maven` build tasks, but serves rather as a description - * of the first-level dependencies for each project/subproject. Their transitive dependencies - * are not included into the result. + * The resulting file is not usable for `maven` build tasks but serves as a description + * of the first-level dependencies for each project or subproject. + * Their transitive dependencies are not included in the result. */ internal class PomXmlWriter internal constructor( @@ -51,12 +51,10 @@ internal constructor( *

If a file with the specified location exists, its contents will be substituted * with a new `pom.xml`. * - * @param file a file to write `pom.xml` contents to + * @param file a file to write `pom.xml` contents to. */ fun writeTo(file: File) { - val fileWriter = FileWriter(file) val out = StringWriter() - writeStart(out) writeBlocks( out, @@ -67,8 +65,9 @@ internal constructor( ) PomFormatting.writeEnd(out) - fileWriter.write(out.toString()) - fileWriter.close() + FileWriter(file).use { + it.write(out.toString()) + } } /** @@ -83,4 +82,3 @@ internal constructor( return destination.toString() } } - diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt index 971c4b4..30ac810 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt @@ -29,6 +29,7 @@ package io.spine.gradle.testing import org.gradle.api.tasks.TaskContainer import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.withType /** * Registers [slowTest][SlowTest] and [fastTest][FastTest] tasks in this [TaskContainer]. @@ -45,10 +46,10 @@ import org.gradle.kotlin.dsl.register */ @Suppress("unused") fun TaskContainer.registerTestTasks() { - withType(Test::class.java).configureEach { + withType().configureEach { filter { - // There could be cases with no matching tests. E.g. tests could be based on Kotest, - // which has custom task types and names. + // There could be cases with no matching tests. + // E.g., tests could be based on Kotest, which has custom task types and names. isFailOnNoMatchingTests = false includeTestsMatching("*Test") includeTestsMatching("*Spec") diff --git a/settings.gradle.kts.template b/settings.gradle.kts.template index 24b63a2..9634f5f 100644 --- a/settings.gradle.kts.template +++ b/settings.gradle.kts.template @@ -27,12 +27,13 @@ @file:Suppress("UnstableApiUsage") /** - * This version of `settings.gradle.kts` is used when `BuildPerformance` is build in a CI job. + * This version of `settings.gradle.kts` is used when `BuildSpeed` is build in a CI job. * * The version of Spine dependencies must be supplied as environment variables: - * - `MC_JAVA_VERSION` - the version of the McJava plugin; - * - `PROTO_DATA_VERSION` - the version of the ProtoData; - * - `VALIDATION_VERSION` - the version of the Validation extension of ProtoData. + * - `COMPILER_VERSION` - the version of the Spine Compiler; + * - `VALIDATION_VERSION` - the version of the Validation plugin to the Spine Compiler; + * - `CORE_JVM_VERSION` — the version of the CoreJvm library; + * - `CORE_JVM_COMPILER_VERSION` - the version of the CoreJvm Compiler plugin. * * See `settings.gradle.kts` for the version of the file used for local builds. */ @@ -43,40 +44,40 @@ dependencyResolutionManagement { // String interpolation can break because of environment variable substitution. @Suppress("ConvertToStringTemplate") create("spine") { - val mcJava = version("mcJava", "$MC_JAVA_VERSION") - val core = version("core", "$CORE_VERSION") - val protoData = version("protoData", "$PROTO_DATA_VERSION") + val compiler = version("spineCompiler", "$COMPILER_VERSION") val validation = version("validation", "$VALIDATION_VERSION") + val coreJvm = version("coreJvm", "$CORE_JVM_VERSION") + val coreJvmCompiler = version("coreJvmCompiler", "$CORE_JVM_COMPILER_VERSION") val baseGroup = "io.spine" val toolsGroup = baseGroup + ".tools" - val protoDataGroup = baseGroup + ".protodata" + val compilerGroup = toolsGroup val validationGroup = baseGroup + ".validation" library( - "mcJava", - toolsGroup, "spine-mc-java-plugins" - ).versionRef(mcJava) + "coreJvmCompiler", + toolsGroup, "core-jvm-plugins" + ).versionRef(coreJvmCompiler) library( "server", baseGroup, "spine-server" - ).versionRef(core) + ).versionRef(coreJvm) library( - "protoData.plugin", - baseGroup, "protodata" - ).versionRef(protoData) + "spineCompiler.plugin", + compilerGroup, "compiler-gradle-plugin" + ).versionRef(compiler) library( - "protoData.compiler", - protoDataGroup, "protodata-compiler" - ).versionRef(protoData) + "spineCompiler.compiler", + compilerGroup, "compiler-backend" + ).versionRef(compiler) library( - "protoData.codegenJava", - protoDataGroup, "protodata-codegen-java" - ).versionRef(protoData) + "compiler.jvm", + compilerGroup, "compiler-jvm" + ).versionRef(compiler) library( "validation.codegenJava", From e6db0fd12fb309286833c12f8e15088cd255a17b Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Fri, 26 Sep 2025 23:11:33 +0100 Subject: [PATCH 02/25] Update `config` --- .../kotlin/io/spine/dependency/Dependency.kt | 132 +++++++++ .../kotlin/io/spine/dependency/boms/Boms.kt | 66 +++++ .../io/spine/dependency/boms/BomsPlugin.kt | 185 +++++++++++++ .../io/spine/dependency/build/JSpecify.kt | 40 +++ .../dependency/build/PluginPublishPlugin.kt | 42 +++ .../io/spine/dependency/kotlinx/AtomicFu.kt | 54 ++++ .../io/spine/dependency/kotlinx/Coroutines.kt | 54 ++++ .../io/spine/dependency/kotlinx/DateTime.kt | 34 +++ .../io/spine/dependency/kotlinx/KotlinX.kt | 32 +++ .../spine/dependency/kotlinx/Serialization.kt | 73 +++++ .../io/spine/dependency/local/Compiler.kt | 176 ++++++++++++ .../io/spine/dependency/local/CoreJvm.kt | 51 ++++ .../spine/dependency/local/CoreJvmCompiler.kt | 83 ++++++ .../kotlin/io/spine/gradle/java/Linters.kt | 61 +++++ .../publish/CustomPublicationHandler.kt | 70 +++++ .../gradle/publish/PublicationHandler.kt | 250 ++++++++++++++++++ .../io/spine/gradle/publish/ShadowJarExts.kt | 77 ++++++ .../publish/StandardJavaPublicationHandler.kt | 133 ++++++++++ .../io/spine/gradle/repo/Credentials.kt | 35 +++ .../kotlin/io/spine/gradle/repo/RepoSlug.kt | 67 +++++ .../io/spine/gradle/repo/Repositories.kt | 172 ++++++++++++ .../kotlin/io/spine/gradle/repo/Repository.kt | 138 ++++++++++ 22 files changed, 2025 insertions(+) create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/repo/Credentials.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/repo/RepoSlug.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt create mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/repo/Repository.kt diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt b/buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt new file mode 100644 index 0000000..80c79f4 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt @@ -0,0 +1,132 @@ +/* + * 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.dependency + +import io.spine.gradle.log +import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.ResolutionStrategy + +/** + * A dependency is a software component we use in a project. + * + * It could be a library, a set of libraries, or a development tool + * that participates in a build. + */ +abstract class Dependency { + + /** + * The version of the dependency in terms of Maven coordinates. + */ + abstract val version: String + + /** + * The group of the dependency in terms of Maven coordinates. + */ + abstract val group: String + + /** + * The modules of the dependency that we use directly or + * transitively in our projects. + */ + abstract val modules: List + + /** + * The [modules] given with the [version]. + */ + final val artifacts: Map by lazy { + modules.associateWith { "$it:$version" } + } + + /** + * Obtains full Maven coordinates for the requested [module]. + */ + fun artifact(module: String): String = artifacts[module] ?: error( + "The dependency `${this::class.simpleName}` does not declare a module `$module`." + ) + + /** + * Forces all artifacts of this dependency using the given resolution strategy. + * + * @param project The project in which the artifacts are forced. Used for logging. + * @param cfg The configuration for which the artifacts are forced. Used for logging. + * @param rs The resolution strategy which forces the artifacts. + */ + fun forceArtifacts(project: Project, cfg: Configuration, rs: ResolutionStrategy) { + artifacts.values.forEach { + rs.forceWithLogging(project, cfg, it) + } + } +} + +/** + * A dependency which declares a Maven Bill of Materials (BOM). + * + * @see + * Maven Bill of Materials + * @see io.spine.dependency.boms.Boms + * @see io.spine.dependency.boms.BomsPlugin + */ +abstract class DependencyWithBom : Dependency() { + + /** + * Maven coordinates of the dependency BOM. + */ + abstract val bom: String +} + +/** + * Returns the suffix of diagnostic messages for this configuration in the given project. + */ +fun Configuration.diagSuffix(project: Project): String = + "the configuration `$name` in the project: `${project.path}`." + + +private fun ResolutionStrategy.forceWithLogging( + project: Project, + configuration: Configuration, + artifact: String +) { + force(artifact) + project.log { "Forced the version of `$artifact` in " + configuration.diagSuffix(project) } +} + +/** + * Obtains full Maven coordinates for the requested [module]. + * + * This extension allows referencing properties of the [Dependency], + * upon which it is invoked. + * + * An example usage: + * + * ``` + * // Supposing there is `Ksp.symbolProcessingApi: String` property declared. + * Ksp.artifact { symbolProcessingApi } + * ``` + */ +fun T.artifact(module: T.() -> String): String = + artifact(module()) diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt b/buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt new file mode 100644 index 0000000..df1751b --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt @@ -0,0 +1,66 @@ +/* + * 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.dependency.boms + +import io.spine.dependency.DependencyWithBom +import io.spine.dependency.kotlinx.Coroutines +import io.spine.dependency.lib.Jackson +import io.spine.dependency.lib.Kotlin +import io.spine.dependency.lib.Grpc +import io.spine.dependency.test.JUnit + +/** + * The collection of references to BOMs applied by [BomsPlugin]. + * + * @see + * Maven Bill of Materials + */ +object Boms { + + /** + * The base production BOMs. + */ + val core: List = listOf( + Kotlin, + Coroutines + ) + + /** + * The BOMs for testing dependencies. + */ + val testing: List = listOf( + JUnit + ) + + /** + * Technology-based BOMs. + */ + object Optional { + val jackson = Jackson.bom + val grpc = Grpc.bom + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt new file mode 100644 index 0000000..2724dda --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt @@ -0,0 +1,185 @@ +/* + * 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.dependency.boms + +import io.gitlab.arturbosch.detekt.getSupportedKotlinVersion +import io.spine.dependency.DependencyWithBom +import io.spine.dependency.diagSuffix +import io.spine.dependency.kotlinx.Coroutines +import io.spine.dependency.lib.Kotlin +import io.spine.dependency.test.JUnit +import io.spine.gradle.log +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.artifacts.Configuration +import org.gradle.api.artifacts.ConfigurationContainer + +/** + * The plugin which forces versions of platforms declared in the [Boms] object. + * + * Versions are enforced via the + * [org.gradle.api.artifacts.dsl.DependencyHandler.enforcedPlatform] call + * for configurations of the project to which the plugin is applied. + * + * The configurations are selected by the "kind" of BOM. + * + * [Boms.core] are applied to: + * 1. Production configurations, such as `api` or `implementation`. + * 2. Compilation configurations. + * 3. All `ksp` configurations. + * + * [Boms.testing] are applied to all testing configurations. + * + * In addition to forcing BOM-based dependencies, + * the plugin [forces][org.gradle.api.artifacts.ResolutionStrategy.force] the versions + * of [Kotlin.StdLib.artifacts] for all configurations because even through Kotlin + * artifacts are forced with BOM, the `variants` in the dependencies cannot be + * picked by Gradle. + * + * Run Gradle with the [INFO][org.gradle.api.logging.Logger.isInfoEnabled] logging level + * to see the dependencies forced by this plugin. + */ +class BomsPlugin : Plugin { + + private val productionConfigs = listOf( + "api", + "implementation", + "compileOnly", + "runtimeOnly" + ) + + override fun apply(project: Project) = with(project) { + + configurations.run { + matching { isCompilationConfig(it.name) }.all { + applyBoms(project, Boms.core) + } + matching { isKspConfig(it.name) }.all { + applyBoms(project, Boms.core) + } + matching { it.name in productionConfigs }.all { + applyBoms(project, Boms.core) + } + matching { isTestConfig(it.name) }.all { + applyBoms(project, Boms.core + Boms.testing) + } + + matching { !supportsBom(it.name) }.all { + resolutionStrategy.eachDependency { + if (requested.group == Kotlin.group) { + val kotlinVersion = Kotlin.runtimeVersion + useVersion(kotlinVersion) + val suffix = this@all.diagSuffix(project) + log { "Forced Kotlin version `$kotlinVersion` in $suffix" } + } + } + } + + selectKotlinCompilerForDetekt() + project.forceArtifacts() + } + } +} + +private fun Configuration.applyBoms(project: Project, deps: List) { + deps.forEach { dep -> + withDependencies { + val platform = project.dependencies.platform(dep.bom) + addLater(project.provider { platform }) + project.log { + "Applied BOM: `${dep.bom}` to the configuration: `${this@applyBoms.name}`." + } + } + } +} + +private val Configuration.isDetekt: Boolean + get() = name.contains("detekt", ignoreCase = true) + +@Suppress("UnstableApiUsage") // `io.gitlab.arturbosch.detekt.getSupportedKotlinVersion` +private fun ConfigurationContainer.selectKotlinCompilerForDetekt() = + matching { it.isDetekt } + .configureEach { + resolutionStrategy.eachDependency { + if (requested.group == Kotlin.group) { + val supportedVersion = getSupportedKotlinVersion() + useVersion(supportedVersion) + because("Force Kotlin version $supportedVersion in Detekt configurations.") + } + } + } + +private fun isCompilationConfig(name: String) = + name.contains("compile", ignoreCase = true) && + // `compileProtoPath` or `compileTestProtoPath`. + !name.contains("ProtoPath", ignoreCase = true) + +private fun isKspConfig(name: String) = + name.startsWith("ksp", ignoreCase = true) + +private fun isTestConfig(name: String) = + name.startsWith("test", ignoreCase = true) + +/** + * Tells if the configuration with the given [name] supports forcing + * versions via the BOM mechanism. + * + * Not all configurations support forcing via BOM. E.g., the configurations created + * by Protobuf Gradle Plugin such as `compileProtoPath` or `extractIncludeProto` do + * not pick up versions of dependencies set via `enforcedPlatform(myBom)`. + */ +private fun supportsBom(name: String) = + (isCompilationConfig(name) || isKspConfig(name) || isTestConfig(name)) + +/** + * Forces the versions of the artifacts that are even being correctly selected by BOMs + * are not guaranteed to be handled correctly when Gradle picks up a `variant`. + * + * The function forces the versions for all configurations but [detekt][isDetekt], because + * it requires a compatible version of the Kotlin compiler. + * + * @see Kotlin.artifacts + * @see Kotlin.StdLib.artifacts + * @see Coroutines.artifacts + * @see selectKotlinCompilerForDetekt + */ +private fun Project.forceArtifacts() = + configurations.all { + resolutionStrategy { + if (!isDetekt) { + val rs = this@resolutionStrategy + val project = this@forceArtifacts + val cfg = this@all + Kotlin.forceArtifacts(project, cfg, rs) + Kotlin.StdLib.forceArtifacts(project, cfg, rs) + Coroutines.forceArtifacts(project, cfg, rs) + JUnit.Jupiter.forceArtifacts(project, cfg, rs) /* + for configurations like `testFixturesCompileProtoPath`. + */ + } + } + } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt new file mode 100644 index 0000000..d884ffb --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt @@ -0,0 +1,40 @@ +/* + * 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.dependency.build + +/** + * An artifact of well-specified annotations to power static analysis + * checks and JVM language interop. Developed by consensus of the partner + * organizations listed at [the project site](https://jspecify.org). + * + * @see JSpecify at GitHub + */ +@Suppress("ConstPropertyName") +object JSpecify { + const val version = "1.0.0" + const val annotations = "org.jspecify:jspecify:$version" +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt new file mode 100644 index 0000000..12c28f8 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt @@ -0,0 +1,42 @@ +/* + * 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. + */ + +@file:Suppress("unused") + +package io.spine.dependency.build + +/** + * The Gradle plugin for publishing Gradle plugins to the Gradle Plugin Portal. + * + * @see + * The plugin page at the Portal + * @see Publishing Rules + */ +@Suppress("ConstPropertyName") +object PluginPublishPlugin { + const val version = "1.3.1" + const val id = "com.gradle.plugin-publish" +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt new file mode 100644 index 0000000..a245bcb --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt @@ -0,0 +1,54 @@ +/* + * 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.dependency.kotlinx + +import io.spine.dependency.Dependency + +/** + * Kotlin/Multiplatform AtomicFU library. + * + * https://github.com/Kotlin/kotlinx.atomicfu + */ +object AtomicFu : Dependency() { + + override val version: String = "0.29.0" + + override val group: String = KotlinX.group + + @Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names + const val module = "atomicfu" + + /** + * The base artifact without platform classifier. + */ + val std = "$group:$module" + + override val modules: List = listOf(std) + + /** Convenience: full coordinates with the version for the standard artifact. */ + val lib: String get() = artifact(std) +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt new file mode 100644 index 0000000..7fa3bd8 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt @@ -0,0 +1,54 @@ +/* + * 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.dependency.kotlinx + +import io.spine.dependency.DependencyWithBom + +/** + * Kotlin Coroutines. + * + * @see GitHub project + */ +object Coroutines : DependencyWithBom() { + override val group = KotlinX.group + override val version = "1.10.2" + + @Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names + const val infix = "kotlinx-coroutines" + + override val bom = "$group:$infix-bom:$version" + + val core = "$group:$infix-core" + val coreJvm = "$group:$infix-core-jvm" + val jdk7 = "$group:$infix-jdk7" + val jdk8 = "$group:$infix-jdk8" + val debug = "$group:$infix-debug" + val test = "$group:$infix-test" + val testJvm = "$group:$infix-test-jvm" + + override val modules = listOf(core, coreJvm, jdk7, jdk8, debug, test, testJvm) +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt new file mode 100644 index 0000000..bb267d8 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt @@ -0,0 +1,34 @@ +/* + * 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.dependency.kotlinx + +// https://github.com/Kotlin/kotlinx-datetime +@Suppress("ConstPropertyName", "unused") +object DateTime { + const val group = KotlinX.group + const val lib = "$group:kotlinx-datetime:0.7.1" +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt new file mode 100644 index 0000000..097b916 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt @@ -0,0 +1,32 @@ +/* + * 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.dependency.kotlinx + +@Suppress("ConstPropertyName", "unused") // https://bit.ly/kotlin-prop-names +object KotlinX { + const val group = "org.jetbrains.kotlinx" +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt new file mode 100644 index 0000000..08e436d --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt @@ -0,0 +1,73 @@ +/* + * 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.dependency.kotlinx + +/** + * The [KotlinX Serialization](https://github.com/Kotlin/kotlinx.serialization) library. + */ +@Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names +object Serialization { + + const val group = KotlinX.group + + /** + * The version of the library. + * + * @see Releases + */ + const val version = "1.8.1" + + private const val infix = "kotlinx-serialization" + const val bom = "$group:$infix-bom:$version" + const val coreJvm = "$group:$infix-core-jvm" + const val json = "$group:$infix-json" + + /** + * The [Gradle plugin](https://github.com/Kotlin/kotlinx.serialization/tree/master?tab=readme-ov-file#gradle) + * for using the serialization library. + * + * Usage: + * ```kotlin + * plugins { + * // ... + * kotlin(Serialization.GradlePlugin.shortId) version Kotlin.version + * } + * ``` + */ + object GradlePlugin { + + /** + * The ID to be used with the `kotlin(shortId)` DSL under the`plugins { }` block. + */ + const val shortId = "plugin.serialization" + + /** + * The full ID of the plugin. + */ + const val id = "org.jetbrains.kotlin.$shortId" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt new file mode 100644 index 0000000..b88f342 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt @@ -0,0 +1,176 @@ +/* + * 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.dependency.local + +/** + * Dependencies on the Spine Compiler modules. + * + * To use a locally published ProtoData version instead of the version from a public plugin + * registry, set the `COMPILER_VERSION` and/or the `COMPILER_DF_VERSION` environment variables + * and stop the Gradle daemons so that Gradle observes the env change: + * ``` + * export COMPILER_VERSION=0.43.0-local + * export COMPILER_DF_VERSION=0.41.0 + * + * ./gradle --stop + * ./gradle build # Conduct the intended checks. + * ``` + * + * Then, to reset the console to run the usual versions again, remove the values of + * the environment variables and stop the daemon: + * ``` + * export COMPILER_VERSION="" + * export COMPILER_DF_VERSION="" + * + * ./gradle --stop + * ``` + * + * See [`SpineEventEngine/compiler`](https://github.com/SpineEventEngine/compiler/). + */ +@Suppress( + "unused" /* Some subprojects do not use the Compiler directly. */, + "ConstPropertyName" /* We use custom convention for artifact properties. */, + "MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */, +) +object Compiler { + const val pluginGroup = Spine.group + const val group = "io.spine.tools" + const val pluginId = "io.spine.compiler" + + /** + * Identifies the Compiler as a `classpath` dependency under `buildScript` block. + */ + const val module = "io.spine.tools:compiler" + + /** + * The version of ProtoData dependencies. + */ + val version: String + private const val fallbackVersion = "2.0.0-SNAPSHOT.016" + + /** + * The distinct version of ProtoData used by other build tools. + * + * When ProtoData is used both for building the project and as a part of the Project's + * transitional dependencies, this is the version used to build the project itself. + */ + val dogfoodingVersion: String + private const val fallbackDfVersion = "2.0.0-SNAPSHOT.016" + + /** + * The artifact for the ProtoData Gradle plugin. + */ + val pluginLib: String + + /** + * The artifact to be used during experiments when publishing locally. + * + * @see Compiler + */ + fun pluginLib(version: String): String = + "$group:compiler-gradle-plugin:$version" + + fun api(version: String): String = + "$group:compiler-api:$version" + + val api + get() = api(version) + + val backend + get() = "$group:compiler-backend:$version" + + val params + get() = "$group:compiler-params:$version" + + val protocPlugin + get() = "$group:compiler-protoc-plugin:$version" + + val gradleApi + get() = "$group:compiler-gradle-api:$version" + + val cliApi + get() = "$group:compiler-cli-api:$version" + + val jvmModule = "$group:compiler-jvm" + + fun jvm(version: String): String = + "$jvmModule:$version" + + val jvm + get() = jvm(version) + + val fatCli + get() = "$group:compiler-fat-cli:$version" + + val testlib + get() = "$group:compiler-testlib:$version" + + /** + * An env variable storing a custom [version]. + */ + private const val VERSION_ENV = "COMPILER_VERSION" + + /** + * An env variable storing a custom [dogfoodingVersion]. + */ + private const val DF_VERSION_ENV = "COMPILER_DF_VERSION" + + /** + * Sets up the versions and artifacts for the build to use. + * + * If either [VERSION_ENV] or [DF_VERSION_ENV] is set, those versions are used instead of + * the hardcoded ones. Also, in this mode, the [pluginLib] coordinates are changed so that + * it points at a locally published artifact. Otherwise, it points at an artifact that would be + * published to a public plugin registry. + */ + init { + val experimentVersion = System.getenv(VERSION_ENV) + val experimentDfVersion = System.getenv(DF_VERSION_ENV) + if (experimentVersion?.isNotBlank() == true || experimentDfVersion?.isNotBlank() == true) { + version = experimentVersion ?: fallbackVersion + dogfoodingVersion = experimentDfVersion ?: fallbackDfVersion + + pluginLib = pluginLib(version) + println(""" + + ❗ Running an experiment with the Spine Compiler. ❗ + ----------------------------------------- + Regular version = v$version + Dogfooding version = v$dogfoodingVersion + + The Compiler Gradle plugin can now be loaded from Maven Local. + + To reset the versions, erase the `$$VERSION_ENV` and `$$DF_VERSION_ENV` environment variables. + + """.trimIndent()) + } else { + version = fallbackVersion + dogfoodingVersion = fallbackDfVersion + pluginLib = pluginLib(version) + } + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt new file mode 100644 index 0000000..10d9a62 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt @@ -0,0 +1,51 @@ +/* + * 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.dependency.local + +// For backward compatibility. +typealias CoreJava = CoreJvm + +/** + * Dependencies on `core-java` modules. + * + * See [`SpineEventEngine/core-java`](https://github.com/SpineEventEngine/core-java/). + */ +@Suppress("ConstPropertyName", "unused") +object CoreJvm { + const val group = Spine.group + const val version = "2.0.0-SNAPSHOT.330" + + const val coreArtifact = "spine-core" + const val clientArtifact = "spine-client" + const val serverArtifact = "spine-server" + + const val core = "$group:$coreArtifact:$version" + const val client = "$group:$clientArtifact:$version" + const val server = "$group:$serverArtifact:$version" + + const val testUtilServer = "${ToolBase.group}:spine-testutil-server:$version" +} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt new file mode 100644 index 0000000..279c7d3 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt @@ -0,0 +1,83 @@ +/* + * 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.dependency.local + +/** + * Dependencies on the CoreJvm Compiler artifacts. + * + * See [mc-java](https://github.com/SpineEventEngine/core-jvm-compiler). + */ +@Suppress( + "MemberVisibilityCanBePrivate" /* `pluginLib()` is used by subprojects. */, + "ConstPropertyName", + "unused" +) +object CoreJvmCompiler { + + /** + * The Compiler belongs to the `tools` group. + */ + const val group = ToolBase.group + + /** + * The version used to in the build classpath. + */ + const val dogfoodingVersion = "2.0.0-SNAPSHOT.006" + + /** + * The version to be used for integration tests. + */ + const val version = "2.0.0-SNAPSHOT.006" + + /** + * The ID of the Gradle plugin. + */ + const val pluginId = "io.spine.core-jvm" + + /** + * The library with the [dogfoodingVersion]. + */ + val pluginLib = pluginLib(dogfoodingVersion) + + /** + * The library with the given [version]. + */ + fun pluginLib(version: String): String = "$group:core-jvm-plugins:$version:all" + + /** The artifact reference for forcing in configurations. */ + const val pluginsArtifact: String = "$group:core-jvm-plugins:$version" + + /** + * The `core-jvm-base` artifact with the [version]. + */ + val base = base(version) + + /** + * The `mc-java-base` artifact with the given [version]. + */ + fun base(version: String): String = "$group:core-jvm-base:$version" +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt b/buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt new file mode 100644 index 0000000..fc00555 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt @@ -0,0 +1,61 @@ +/* + * 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.gradle.java + +import net.ltgt.gradle.errorprone.errorprone +import org.gradle.api.Project +import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.kotlin.dsl.invoke +import org.gradle.kotlin.dsl.named + +/** + * Disables Java linters in this [Project]. + * + * In particular, the following linters will be disabled: + * + * 1. CheckStyle. + * 2. PMD. + * 3. ErrorProne. + * + * Apply this configuration for modules that have original Flogger sources, + * which have not been migrated to Kotlin yet. They produce a lot of + * errors/warnings failing the build. + * + * Our own sources are mostly in Kotlin (as for `spine-logging` repo), + * so this action seems quite safe. + */ +// TODO:2023-09-22:yevhenii.nadtochii: Remove this piece of configuration. +// See issue: https://github.com/SpineEventEngine/logging/issues/56 +fun Project.disableLinters() { + tasks { + named("checkstyleMain") { enabled = false } + named("pmdMain") { enabled = false } + named("compileJava") { + options.errorprone.isEnabled.set(false) + } + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt new file mode 100644 index 0000000..152455d --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt @@ -0,0 +1,70 @@ +/* + * 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.gradle.publish + +import io.spine.gradle.repo.Repository +import org.gradle.api.Project +import org.gradle.api.publish.maven.MavenPublication + +/** + * A handler for custom publications, which are declared under the [publications] + * section of a module. + * + * Such publications should be treated differently than [StandardJavaPublicationHandler], + * which is created for a module. Instead, since the publications are already declared, + * this class only [assigns Maven coordinates][copyProjectAttributes]. + * + * A module which declares custom publications must be specified in + * the [SpinePublishing.modulesWithCustomPublishing] property. + * + * If a module with [publications] declared locally is not specified as one with custom publishing, + * it may cause a name clash between an artifact produced by + * the [standard][org.gradle.api.publish.maven.MavenPublication] publication, and custom ones. + * To have both standard and custom publications, please specify custom artifact IDs or + * classifiers for each custom publication. + * + * @see StandardJavaPublicationHandler + */ +internal class CustomPublicationHandler private constructor( + project: Project, + destinations: Set +) : PublicationHandler(project, destinations) { + + override fun handlePublications() { + project.publications.forEach { + (it as MavenPublication).copyProjectAttributes() + } + } + + companion object : HandlerFactory() { + override fun create( + project: Project, + destinations: Set, + vararg params: Any + ): CustomPublicationHandler = CustomPublicationHandler(project, destinations) + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt new file mode 100644 index 0000000..75c5413 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt @@ -0,0 +1,250 @@ +/* + * 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.gradle.publish + +import LicenseSettings +import io.spine.gradle.isSnapshot +import io.spine.gradle.repo.Repository +import org.gradle.api.Project +import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.invocation.BuildInvocationDetails +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.support.serviceOf + +/** + * The name of the Maven Publishing Gradle plugin. + */ +private const val MAVEN_PUBLISH = "maven-publish" + +/** + * Abstract base for handlers of publications in a project + * with [spinePublishing] settings declared. + * + * @param project The project to which the handler is applied. + * @param destinations The repositories for publishing artifacts of this project. + * In a multi-module project the destinations can be re-defined by + * specifying custom values in + * the [`spinePublishing`][io.spine.gradle.publish.SpinePublishing.destinations] + * extension applied to the subproject. + */ +internal sealed class PublicationHandler( + protected val project: Project, + protected var destinations: Set +) { + /** + * Remembers if the [apply] function was called by this handler. + */ + private var applied: Boolean = false + + /** + * Overwrites the [destinations] property with the given set. + */ + fun publishTo(alternativeDestinations: Set) { + if (alternativeDestinations.isEmpty()) { + project.logger.info( + "The project ${project.path} is not going to be published because" + + " the publication handler `${this@PublicationHandler}`" + + " got an empty set of new `destinations`." + ) + } + destinations = alternativeDestinations + } + + /** + * Configures the publication of the associated [project]. + */ + fun apply() { + synchronized(project) { + if (applied) { + return + } + project.run { + // We apply the `maven-publish` plugin for modules with standard + // publishing automatically because they don't need custom DSL + // in their `build.gradle.kts` files. + // All the job is done by the `SpinePublishing` extension and + // `StandardPublicationHandler` instance associated with this project. + if (!hasCustomPublishing) { + apply(plugin = MAVEN_PUBLISH) + } + // And we do not apply the plugin for modules with custom publishing + // because they will need the `maven-publish` DSL to tune the publishing. + // Therefore, we only arrange the execution of our code when the plugin + // is applied. + pluginManager.withPlugin(MAVEN_PUBLISH) { + handlePublications() + registerDestinations() + configurePublishTask(destinations) + applied = true + } + } + } + } + + /** + * Either handles publications already declared in the associated [project] + * or creates new ones. + */ + abstract fun handlePublications() + + /** + * Goes through the [destinations] and registers each as a repository for publishing + * in the given Gradle project. + */ + private fun registerDestinations() { + val repositories = project.publishingExtension.repositories + destinations.forEach { destination -> + repositories.register(project, destination) + } + } + + /** + * Copies the attributes of Gradle [Project] to this [MavenPublication]. + * + * The following project attributes are copied: + * * [group][Project.getGroup]; + * * [version][Project.getVersion]; + * * [description][Project.getDescription]. + * + * Also, this function adds the [artifactPrefix][SpinePublishing.artifactPrefix] to + * the [artifactId][MavenPublication.setArtifactId] of this publication, + * if the prefix is not added yet. + * + * Finally, the Apache Software License 2.0 is set as the only license + * under which the published artifact is distributed. + */ + protected fun MavenPublication.copyProjectAttributes() { + groupId = project.group.toString() + val prefix = project.spinePublishing.artifactPrefix + if (!artifactId.startsWith(prefix)) { + artifactId = prefix + artifactId + } + version = project.version.toString() + pom.description.set(project.description) + + pom.licenses { + license { + name.set(LicenseSettings.name) + url.set(LicenseSettings.url) + } + } + } + + /** + * The abstract base for factories producing instances of classes + * derived from [io.spine.gradle.publish.PublicationHandler]. + * + * The factory maintains associations between a path of the project to + * its publication handler. + * + * If the handler already exists, its settings are updated when + * the [serving] factory method is called. + * + * Otherwise, a new handler is created and associated with the project. + * + * @param H The type of the publication handlers produced by this repository. + * @see serving + */ + abstract class HandlerFactory { + + /** + * Maps a project path suffixed with build start time to the associated publication handler. + * + * The suffix after the project path is needed to create a new handler + * for each build. We do not use Guava or other cache expecting the small amount + * of memory consumption of each publication handler. + */ + private val handlers = mutableMapOf() + + /** + * Computes the key for a publication handler taking the [project] and + * its build start time. + */ + private fun createKey(project: Project): String { + val buildService = project.gradle.serviceOf() + val buildStartedMillis = buildService.buildStartedTime + val localTime = java.time.Instant.ofEpochMilli(buildStartedMillis) + val key = "${project.path}-at-$localTime" + return key + } + + /** + * Obtains an instance of [PublicationHandler] for the given project. + * + * If the handler for the given [project] was already created, the handler + * gets new [destinations], [overwriting][publishTo] previously specified. + * + * @return the handler for the given project which would handle publishing to + * the specified [destinations]. + */ + fun serving(project: Project, destinations: Set, vararg params: Any): H { + synchronized(handlers) { + val key = createKey(project) + var handler = handlers[key] + if (handler == null) { + handler = create(project, destinations, *params) + handlers[key] = handler + } else { + handler.publishTo(destinations) + } + return handler + } + } + + /** + * Creates a new publication handler for the given project. + * + * @param project The project to which the handler applies. + * @param destinations The repositories for publishing artifacts of this project. + * @param params Optional parameters to be passed as constructor parameters for + * classes of the type [H]. + */ + protected abstract fun create( + project: Project, + destinations: Set, + vararg params: Any + ): H + } +} + +/** + * Adds a Maven repository to the project specifying credentials, if they are + * [available][Repository.credentials] from the root project. + */ +private fun RepositoryHandler.register(project: Project, repository: Repository) { + val isSnapshot = project.version.toString().isSnapshot() + val credentials = repository.credentials(project.rootProject) + maven { + name = repository.name(isSnapshot) + url = project.uri(repository.target(isSnapshot)) + credentials { + username = credentials?.username + password = credentials?.password + } + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt new file mode 100644 index 0000000..e2e67e0 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt @@ -0,0 +1,77 @@ +/* + * 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.gradle.publish + +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +/** + * Calls [ShadowJar.mergeServiceFiles] for the files we use in the Spine SDK. + */ +fun ShadowJar.handleMergingServiceFiles() { + ServiceFiles.all.forEach { + mergeServiceFiles(it) + } +} + +@Suppress("ConstPropertyName") +private object ServiceFiles { + + /** + * Files containing references to descriptor set files. + */ + private const val descriptorSetReferences = "desc.ref" + + private const val servicesDir = "META-INF/services" + /** + * Providers of custom Protobuf options introduced by the libraries. + */ + private const val optionProviders = "$servicesDir/io.spine.option.OptionsProvider" + + /** + * KSP symbol processor provider. + */ + private const val kspSymbolProcessorProviders = + "$servicesDir/com.google.devtools.ksp.KspSymbolProcessorProvider" + + /** + * Message routing setup classes generated by the Compiler for JVM. + */ + private const val routeSetupPackage = "io.spine.server.route.setup" + private const val routeSetupPrefix = "$servicesDir/$routeSetupPackage" + private const val commandRoutingSetupClasses = "$routeSetupPrefix.CommandRoutingSetup" + private const val eventRoutingSetupClasses = "$routeSetupPrefix.EventRoutingSetup" + private const val stateRoutingSetupClasses = "$routeSetupPrefix.StateRoutingSetup" + + val all = arrayOf( + descriptorSetReferences, + optionProviders, + kspSymbolProcessorProviders, + commandRoutingSetupClasses, + eventRoutingSetupClasses, + stateRoutingSetupClasses + ) +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt new file mode 100644 index 0000000..06d78c1 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt @@ -0,0 +1,133 @@ +/* + * 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.gradle.publish + +import io.spine.gradle.repo.Repository +import org.gradle.api.Project +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.bundling.Jar +import org.gradle.kotlin.dsl.create + +/** + * A publication for a typical Java project. + * + * In Gradle, to publish something, one should create a publication. + * A publication has a name and consists of one or more artifacts plus information about + * those artifacts – the metadata. + * + * An instance of this class represents + * [MavenPublication][org.gradle.api.publish.maven.MavenPublication] + * named [`"mavenJava"`][PUBLICATION_NAME]. + * It is generally accepted that a publication with this name contains a Java project + * published to one or more Maven repositories. + * + * By default, only a jar with the compilation output of `main` source set and its + * metadata files are published. Other artifacts are specified through the + * [constructor parameter][jarFlags]. + * Please take a look on [specifyArtifacts] for additional info. + * + * @param jarFlags The flags for additional JARs published along with the compilation output. + * @param destinations Maven repositories to which the produced artifacts will be sent. + * @see + * The Maven Publish Plugin | Publications + * @see CustomPublicationHandler + */ +internal class StandardJavaPublicationHandler private constructor( + project: Project, + private val jarFlags: JarFlags, + destinations: Set, +) : PublicationHandler(project, destinations) { + + companion object : HandlerFactory() { + + /** + * The name of the publication created by [StandardJavaPublicationHandler]. + */ + const val PUBLICATION_NAME = "mavenJava" + + override fun create( + project: Project, + destinations: Set, + vararg params: Any + ): StandardJavaPublicationHandler { + return StandardJavaPublicationHandler(project, params[0] as JarFlags, destinations) + } + } + + /** + * Creates a new `"mavenJava"` [MavenPublication][org.gradle.api.publish.maven.MavenPublication] + * in the [project] associated with this publication handler. + */ + override fun handlePublications() { + val jars = project.artifacts(jarFlags) + val publications = project.publications + publications.create(PUBLICATION_NAME) { + copyProjectAttributes() + specifyArtifacts(jars) + } + } + + /** + * Specifies which artifacts this [MavenPublication] will contain. + * + * A typical Maven publication contains: + * + * 1. Jar archives. For example, compilation output, sources, javadoc, etc. + * 2. Maven metadata file that has the ".pom" extension. + * 3. Gradle's metadata file that has the ".module" extension. + * + * Metadata files contain information about a publication itself, its artifacts, and their + * dependencies. Presence of ".pom" file is mandatory for publication to be consumed by + * `mvn` build tool itself or other build tools that understand Maven notation (Gradle, Ivy). + * The presence of ".module" is optional, but useful when a publication is consumed by Gradle. + * + * @see Maven – POM Reference + * @see + * Understanding Gradle Module Metadata + */ + private fun MavenPublication.specifyArtifacts(jars: Set>) { + + /* + "java" component provides a jar with compilation output of "main" source set. + It is NOT defined as another `Jar` task intentionally. Doing that will leave the + publication without correct ".pom" and ".module" metadata files generated. + */ + val javaComponent = project.components.findByName("java") + javaComponent?.let { + from(it) + } + + /* + Other artifacts are represented by `Jar` tasks. Those artifacts do not bring any other + metadata in comparison with `Component` (such as the `dependencies` notation). + */ + jars.forEach { + artifact(it) + } + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/repo/Credentials.kt b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Credentials.kt new file mode 100644 index 0000000..1624b38 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Credentials.kt @@ -0,0 +1,35 @@ +/* + * 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.gradle.repo + +/** + * Password credentials for a Maven repository. + */ +data class Credentials( + val username: String?, + val password: String? +) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/repo/RepoSlug.kt b/buildSrc/src/main/kotlin/io/spine/gradle/repo/RepoSlug.kt new file mode 100644 index 0000000..461c690 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/repo/RepoSlug.kt @@ -0,0 +1,67 @@ +/* + * 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.gradle.repo + +import org.gradle.api.GradleException + +/** + * A name of a repository. + */ +@Suppress("unused") +class RepoSlug(val value: String) { + + companion object { + + /** + * The name of the environment variable containing the repository slug, for which + * the Gradle build is performed. + */ + private const val environmentVariable = "REPO_SLUG" + + /** + * Reads `REPO_SLUG` environment variable and returns its value. + * + * In case it is not set, a [org.gradle.api.GradleException] is thrown. + */ + fun fromVar(): RepoSlug { + val envValue = System.getenv(environmentVariable) + if (envValue.isNullOrEmpty()) { + throw GradleException("`REPO_SLUG` environment variable is not set.") + } + return RepoSlug(envValue) + } + } + + override fun toString(): String = value + + /** + * Returns the GitHub URL to the project repository. + */ + fun gitHost(): String { + return "git@github.com-publish:${value}.git" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt new file mode 100644 index 0000000..43abe47 --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt @@ -0,0 +1,172 @@ +/* + * 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. + */ + +@file:Suppress("TooManyFunctions") // Deprecated functions will be kept for a while. + +package io.spine.gradle.repo + +import io.spine.gradle.publish.PublishingRepos +import java.net.URI +import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.artifacts.repositories.MavenArtifactRepository +import org.gradle.kotlin.dsl.maven + +/** + * Registers the standard set of Maven repositories. + * + * To be used in `buildscript` clauses when a fully-qualified call must be made. + */ +@Suppress("unused") +@Deprecated( + message = "Please use `standardSpineSdkRepositories()`.", + replaceWith = ReplaceWith("standardSpineSdkRepositories()") +) +fun doApplyStandard(repositories: RepositoryHandler) = repositories.standardToSpineSdk() + +/** + * A scrambled version of PAT generated with the only "read:packages" scope. + * + * The scrambling around PAT is necessary because GitHub analyzes commits for the presence + * of tokens and invalidates them. + * + * @see + * How to make GitHub packages to the public + */ +private object Pat { + private const val shade = "_phg->8YlN->MFRA->gxIk->HVkm->eO6g->FqHJ->z8MS->H4zC->ZEPq" + private const val separator = "->" + private val chunks: Int = shade.split(separator).size - 1 + + fun credentials(): Credentials { + val pass = shade.replace(separator, "").splitAndReverse(chunks, "") + return Credentials("public", pass) + } + + /** + * Splits this string to the chunks, reverses each chunk, and joins them + * back to a string using the [separator]. + */ + private fun String.splitAndReverse(numChunks: Int, separator: String): String { + check(length / numChunks >= 2) { + "The number of chunks is too big. Must be <= ${length / 2}." + } + val chunks = chunked(length / numChunks) + val reversedChunks = chunks.map { chunk -> chunk.reversed() } + return reversedChunks.joinToString(separator) + } +} + +/** + * Adds a read-only view to all artifacts of the SpineEventEngine + * GitHub organization. + */ +fun RepositoryHandler.spineArtifacts(): MavenArtifactRepository = maven { + url = URI("https://maven.pkg.github.com/SpineEventEngine/*") + includeSpineOnly() + val pat = Pat.credentials() + credentials { + username = pat.username + password = pat.password + } +} + +val RepositoryHandler.intellijReleases: MavenArtifactRepository + get() = maven("https://www.jetbrains.com/intellij-repository/releases") + +val RepositoryHandler.jetBrainsCacheRedirector: MavenArtifactRepository + get() = maven("https://cache-redirector.jetbrains.com/intellij-dependencies") + +/** + * Applies repositories commonly used by Spine Event Engine projects. + */ +fun RepositoryHandler.standardToSpineSdk() { + spineArtifacts() + + @Suppress("DEPRECATION") // Still use `CloudRepo` for earlier versions. + val spineRepos = listOf( + Repos.spine, + Repos.spineSnapshots, + Repos.artifactRegistry, + Repos.artifactRegistrySnapshots + ) + + spineRepos + .map { URI(it) } + .forEach { + maven { + url = it + includeSpineOnly() + } + } + + intellijReleases + jetBrainsCacheRedirector + + maven { + url = URI(Repos.sonatypeSnapshots) + } + + mavenCentral() + gradlePluginPortal() + mavenLocal().includeSpineOnly() +} + +@Deprecated( + message = "Please use `standardToSpineSdk() instead.", + replaceWith = ReplaceWith("standardToSpineSdk()") +) +fun RepositoryHandler.applyStandard() = this.standardToSpineSdk() + +/** + * Defines names of additional repositories commonly used in the Spine SDK projects. + * + * @see [applyStandard] + */ +@Suppress( + "DEPRECATION" /* Still need to use `CloudRepo` for older versions. */, + "ConstPropertyName" // https://bit.ly/kotlin-prop-names +) +private object Repos { + @Deprecated(message = "Please use `cloudArtifactRegistry.releases` instead.") + val spine = io.spine.gradle.publish.CloudRepo.published.target(snapshots = false) + + @Deprecated(message = "Please use `artifactRegistry.snapshots` instead.") + val spineSnapshots = io.spine.gradle.publish.CloudRepo.published.target(snapshots = true) + + val artifactRegistry = PublishingRepos.cloudArtifactRegistry.target(snapshots = false) + val artifactRegistrySnapshots = PublishingRepos.cloudArtifactRegistry.target(snapshots = true) + + const val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots" +} + +/** + * Narrows down the search for this repository to Spine-related artifact groups. + */ +private fun MavenArtifactRepository.includeSpineOnly() { + content { + includeGroupByRegex("io\\.spine.*") + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repository.kt b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repository.kt new file mode 100644 index 0000000..a586ffd --- /dev/null +++ b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repository.kt @@ -0,0 +1,138 @@ +/* + * 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.gradle.repo + +import java.io.File +import java.util.Properties +import org.gradle.api.Project + +/** + * A Maven repository. + * + * @param name The human-readable name which is also used in the publishing task names + * for identifying the target repository. + * The name must match the [regex]. + * @param releases The URL for publishing release versions of artifacts. + * @param snapshots The URL for publishing [snapshot][io.spine.gradle.isSnapshot] versions. + * @param credentialsFile The path to the file which contains the credentials for the registry. + * @param credentialValues The function to obtain an instance of [Credentials] from + * a Gradle [Project], if [credentialsFile] is not specified. + */ +data class Repository( + private val name: String, + private val releases: String, + private val snapshots: String, + private val credentialsFile: String? = null, + private val credentialValues: ((Project) -> Credentials?)? = null +) { + + companion object { + val regex = Regex("[A-Za-z0-9_\\-.]+") + } + + init { + require(regex.matches(name)) { + "The repository name `$name` does not match the regex `$regex`." + } + } + + /** + * Obtains the name of the repository. + * + * The name will be primarily used in the publishing tasks. + * + * @param snapshots If `true` this repository is used for publishing snapshots, + * and the suffix `-snapshots` will be added to the value of the [name] property. + * Otherwise, the function returns just [name]. + */ + fun name(snapshots: Boolean): String = name + if (snapshots) "-snapshots" else "" + + /** + * Obtains the target URL of the repository for publishing. + */ + fun target(snapshots: Boolean): String = if (snapshots) this.snapshots else releases + + /** + * Tells if release and snapshot versions are published to the same destination + * of this repository. + */ + fun hasOneTarget() = snapshots == releases + + /** + * Obtains the publishing password credentials to this repository. + * + * If the credentials are represented by a `.properties` file, reads the file and parses + * the credentials. The file must have properties `user.name` and `user.password`, which store + * the username and the password for the Maven repository auth. + */ + fun credentials(project: Project): Credentials? = when { + credentialValues != null -> credentialValues.invoke(project) + credentialsFile != null -> credsFromFile(credentialsFile, project) + else -> throw IllegalArgumentException( + "Credentials file or a supplier function should be passed." + ) + } + + private fun credsFromFile(fileName: String, project: Project): Credentials? { + val file = project.rootProject.file(fileName) + if (file.exists().not()) { + return null + } + + val log = project.logger + log.info("Using credentials from `$fileName`.") + val creds = file.parseCredentials() + log.info("Publishing build as `${creds.username}`.") + return creds + } + + private fun File.parseCredentials(): Credentials { + val properties = Properties().apply { load(inputStream()) } + val username = properties.getProperty("user.name") + val password = properties.getProperty("user.password") + return Credentials(username, password) + } + + override fun equals(other: Any?): Boolean = when { + this === other -> true + other !is Repository -> false + else -> name == other.name && + releases == other.releases && + snapshots == other.snapshots +} + + override fun hashCode(): Int { + var result = name.hashCode() + result = 31 * result + releases.hashCode() + result = 31 * result + snapshots.hashCode() + return result + } + + override fun toString(): String { + return name + } +} From 89bb36f725f222e1325dea28e07a29f9f20e90e2 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Fri, 26 Sep 2025 23:32:38 +0100 Subject: [PATCH 03/25] Simplify adding CoreJvm Compiler --- build.gradle.kts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 48105b4..279a7f1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,15 +41,11 @@ buildscript { spineCompiler.pluginLib, spineCompiler.backend, spineCompiler.jvm, -// validation.java, -// validation.javaBundle, ) } dependencies { - coreJvmCompiler.run { - classpath(pluginLib(version)) - } + classpath(coreJvmCompiler.pluginLib) } } @@ -58,12 +54,11 @@ plugins { id("com.google.protobuf") idea id("com.osacky.doctor") version "0.8.1" - id("io.spine.core-jvm") version "2.0.0-SNAPSHOT.006" } repositories.standardToSpineSdk() -//apply(plugin = CoreJvmCompiler.pluginId) +apply(plugin = CoreJvmCompiler.pluginId) dependencies { implementation(CoreJvm.server) From 8d4a2539fc8a3c91ccac954119cbf90058b461d0 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sat, 27 Sep 2025 00:02:11 +0100 Subject: [PATCH 04/25] Fix code layout --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 279a7f1..031f512 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -56,10 +56,10 @@ plugins { id("com.osacky.doctor") version "0.8.1" } -repositories.standardToSpineSdk() - apply(plugin = CoreJvmCompiler.pluginId) +repositories.standardToSpineSdk() + dependencies { implementation(CoreJvm.server) } From 9b33153576c6199b7e32bea7af278f7fccbe6227 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sat, 27 Sep 2025 00:11:44 +0100 Subject: [PATCH 05/25] Bump CoreJvm Compiler -> `2.0.0-SNAPSHOT.007` --- .../main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt index 279c7d3..2b9c067 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt @@ -46,12 +46,12 @@ object CoreJvmCompiler { /** * The version used to in the build classpath. */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.006" + const val dogfoodingVersion = "2.0.0-SNAPSHOT.007" /** * The version to be used for integration tests. */ - const val version = "2.0.0-SNAPSHOT.006" + const val version = "2.0.0-SNAPSHOT.007" /** * The ID of the Gradle plugin. From 65847f10f9c48b24cee3f482cac3873fa83da4af Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Sat, 27 Sep 2025 19:45:40 +0100 Subject: [PATCH 06/25] Address deprecations --- buildSrc/src/main/kotlin/jvm-module.gradle.kts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/jvm-module.gradle.kts b/buildSrc/src/main/kotlin/jvm-module.gradle.kts index c409950..6163984 100644 --- a/buildSrc/src/main/kotlin/jvm-module.gradle.kts +++ b/buildSrc/src/main/kotlin/jvm-module.gradle.kts @@ -137,15 +137,14 @@ fun Module.addDependencies() = dependencies { implementation(Logging.lib) testImplementation(Guava.testLib) - testImplementation(JUnit.runner) + testImplementation(JUnit.Jupiter.engine) testImplementation(JUnit.pioneer) - JUnit.api.forEach { testImplementation(it) } + JUnit.Jupiter.api.forEach { testImplementation(it) } testImplementation(TestLib.lib) testImplementation(Kotest.frameworkEngine) testImplementation(Kotest.datatest) testImplementation(Kotest.runnerJUnit5Jvm) - testImplementation(JUnit.runner) } fun Module.forceConfigurations() { @@ -156,7 +155,7 @@ fun Module.forceConfigurations() { resolutionStrategy { force( JUnit.bom, - JUnit.runner, + JUnit.Jupiter.engine, Dokka.BasePlugin.lib, Reflect.lib, ) From 45bd273a55ebd10de44db049380101a9f9a823aa Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Sat, 27 Sep 2025 19:45:55 +0100 Subject: [PATCH 07/25] Bump local dependencies --- .../main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt | 4 ++-- .../src/main/kotlin/io/spine/dependency/local/ToolBase.kt | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt index 2b9c067..9a21a6e 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt @@ -46,12 +46,12 @@ object CoreJvmCompiler { /** * The version used to in the build classpath. */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.007" + const val dogfoodingVersion = "2.0.0-SNAPSHOT.008" /** * The version to be used for integration tests. */ - const val version = "2.0.0-SNAPSHOT.007" + const val version = "2.0.0-SNAPSHOT.008" /** * The ID of the Gradle plugin. diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt index 3625a4b..36d5943 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt @@ -34,7 +34,7 @@ package io.spine.dependency.local @Suppress("ConstPropertyName", "unused") object ToolBase { const val group = "io.spine.tools" - const val version = "2.0.0-SNAPSHOT.355" + const val version = "2.0.0-SNAPSHOT.356" const val lib = "$group:tool-base:$version" const val pluginBase = "$group:plugin-base:$version" @@ -50,6 +50,7 @@ object ToolBase { const val gradlePluginApi = "$group:gradle-plugin-api:$version" const val gradlePluginApiTestFixtures = "$group:gradle-plugin-api-test-fixtures:$version" + const val rootPlugins = "$group:root-gradle-plugins:$version" const val jvmTools = "$group:jvm-tools:$version" const val jvmToolPlugins = "$group:jvm-tool-all-plugins:$version" From e7983cf3c59002b0e04b616f99434b26c9ed69aa Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Sat, 27 Sep 2025 19:46:25 +0100 Subject: [PATCH 08/25] Obtain the CoreJvm Compiler version from `../version.gradle.kts` --- build.gradle.kts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 031f512..44053c1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,7 +35,7 @@ import java.util.function.Supplier buildscript { standardSpineSdkRepositories() - + apply(from = "$rootDir/../version.gradle.kts") configurations.all { resolutionStrategy.force( spineCompiler.pluginLib, @@ -43,9 +43,12 @@ buildscript { spineCompiler.jvm, ) } + var coreJvmCompilerVersion: String by extra + val pluginLib = coreJvmCompiler.pluginLib(coreJvmCompilerVersion) + println("****** CoreJvm Compiler plugin: $pluginLib") dependencies { - classpath(coreJvmCompiler.pluginLib) + classpath(pluginLib) } } From 0d2c840558caf38ab4d4f9b859f5ed414b7dd1ef Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sun, 28 Sep 2025 18:39:01 +0100 Subject: [PATCH 09/25] Bump Gradle -> `8.14.2` Also: * Expose `TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK` environment variable. --- gradle.properties | 2 ++ gradle/wrapper/gradle-wrapper.jar | Bin 43705 -> 43764 bytes gradle/wrapper/gradle-wrapper.properties | 28 +------------------- gradlew | 31 ++++++++++------------- gradlew.bat | 7 +++-- 5 files changed, 21 insertions(+), 47 deletions(-) diff --git a/gradle.properties b/gradle.properties index 24a7d0c..86386ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,3 +25,5 @@ # org.gradle.jvmargs=-XX:+UseParallelGC -Xmx4096M + +org.gradle.debug=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 9bbc975c742b298b441bfb90dbc124400a3751b9..1b33c55baabb587c669f562ae36f953de2481846 100644 GIT binary patch delta 642 zcmdmamFde>rVZJA^}0Q$xegf!xPEW^+5YDM%iT2bEgct9o+jH~+sJas#HZ=szO|** z=Pj=X_vx?W&DSwKck|WWn~hffsvnQ+42*W$b7b0$SCcOoZ`{W{^$^pk;4>8-A*-)$ z?n(Po`1$6Jn_u?t-L+tsPyZ2#X}8T6OS8pAU;kdgd+_Hw4z4TW0p9E!T+=f7-c&O% zFic^X{7^$?^Ho04eona9n#mGMxKhA=~8B%JN`M zMhm5wc-2v)$``sY$!Q`9xiU@DhI73ZxiGEKg>yIPs)NmWwMdF-ngLXpZSqV5ez36n zVkxF2rjrjWR+_xr6e6@_u@s~2uv{9vi*1pj2)BjFD+-%@&pRVP1f{O1glxTOp2-62Ph;v z`N1+vCd)9ea)af*Ol1*JCfnp$%Uu}%OuoN7g2}3C@`L5FlP#(sA=|h@iixuZC?qp^ z=L$=v$ZoI}|87Wh=&h7udff{aieKr*l+zDp?pf)_bbRvUf>kn;HCDMXNlgbbo!QRK I1x7am0No)LiU0rr delta 584 zcmexzm1*ZyrVZJAexH5Moc8h7)w{^+t*dqJ%=yhh23L$9JpFV=_k`zJ-?Q4DI*eSe z+ES)HSrVnWLtJ&)lO%hRkV9zl5qqWRt0e;bb zPPo`)y?HTAyZI&u&X<|2$FDHCf4;!v8}p=?Tm`^F0`u(|1ttf~&t$qP3KUSD>@TJQ zRwJ}Pim6NzEc8KA6)e;S6gs8=7IIL8sQL*MYEuRYO;Uj<%3UbMbV&^&!Zvx+LKmjT z8Zch6rYP7Tw?$Hn(UTJwWiS=$f{lB(C=e*%usDV})0AQIK~sat=ND@+Gg*Pyij!rR z*fa02W|%BsV++>4W{DKDGSIUEHd2$P+8ct!RF+CHDowUuTEZOZ%rJSQv*qOXOSPDN zT|sP-$p*_3ncsWB*qoD7JQcyZ9xan%cJP6Tb4-?AZpr*F6v98hoNaPJm@HV`yya5N z))6pqFXn@}P(3T0nEzM8*c_9KtE9o|_pFd&K35GBXP^9Kg(b6GH-z8S4GDzIl~T+b zdLd#meKKHu$5u))8cu$=GKINkGDPOUD)!0$C(BH(U!}!-e;Q0ok8Sc?V1zRO04>ts AA^-pY diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 03d6bb7..ff23a68 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,32 +1,6 @@ -# -# 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. -# - distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index d4b5e0e..ab0e1c7 100755 --- a/gradlew +++ b/gradlew @@ -1,29 +1,21 @@ #!/bin/sh # -# Copyright 2025, TeamDev. All rights reserved. +# Copyright © 2015-2021 the original authors. # # 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 +# 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. +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # -# 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. +# SPDX-License-Identifier: Apache-2.0 # ############################################################################## @@ -72,6 +64,9 @@ # ############################################################################## +# Temporarily disable the runtime check of Protobuf version compatibility. +export TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true + # Attempt to set APP_HOME # Resolve links: $0 may be a link @@ -122,7 +117,7 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar +CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -221,7 +216,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9d21a21..619f695 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -16,6 +16,9 @@ @rem SPDX-License-Identifier: Apache-2.0 @rem +@rem Temporarily disable the runtime check of Protobuf version compatibility. +set TEMPORARILY_DISABLE_PROTOBUF_VERSION_CHECK=true + @if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @@ -70,11 +73,11 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar +set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell From 10d7c829b15f570ad6ead172a76b6d0f75c5bacb Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sun, 28 Sep 2025 18:39:12 +0100 Subject: [PATCH 10/25] Remove redundant forcing --- build.gradle.kts | 37 +++++++------------------------------ 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 031f512..017747e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,24 +35,16 @@ import java.util.function.Supplier buildscript { standardSpineSdkRepositories() - - configurations.all { - resolutionStrategy.force( - spineCompiler.pluginLib, - spineCompiler.backend, - spineCompiler.jvm, - ) - } - + apply(from = "$rootDir/../version.gradle.kts") + val coreJvmCompilerVersion: String by extra dependencies { - classpath(coreJvmCompiler.pluginLib) + classpath(coreJvmCompiler.pluginLib(coreJvmCompilerVersion)) } } plugins { java id("com.google.protobuf") - idea id("com.osacky.doctor") version "0.8.1" } @@ -64,24 +56,6 @@ dependencies { implementation(CoreJvm.server) } -configurations.all { - resolutionStrategy.force( - Compiler.backend, - Compiler.jvm, -// Validation.java, -// Validation.runtime, - ) -} - -idea { - module { - generatedSourceDirs = listOf( - "$projectDir/generated/main/java", - "$projectDir/generated/main/kotlin" - ).map(::file).toSet() - } -} - val customConfigFile = "../build-speed.gradle.kts" if (file(customConfigFile).exists()) { @@ -104,12 +78,15 @@ afterEvaluate { startTimeMillis = System.currentTimeMillis() } +apply(from = "$rootDir/../version.gradle.kts") +val coreJvmCompilerVersion: String by extra + val recordExecTime by tasks.registering(UpdateJournal::class) { startTime = Supplier { startTimeMillis!! } versions.set( mapOf( "Compiler" to Compiler.version, - "CoreJvmCompiler" to CoreJvmCompiler.version, + "CoreJvmCompiler" to coreJvmCompilerVersion, "CoreJvm" to CoreJvm.version, "Validation" to Validation.version, ) From 967c654c7664c5b836479ffe1647ae51550f318c Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sun, 28 Sep 2025 19:23:33 +0100 Subject: [PATCH 11/25] Add CoreJvm library to the version catalog --- settings.gradle.kts.template | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/settings.gradle.kts.template b/settings.gradle.kts.template index 9634f5f..247447c 100644 --- a/settings.gradle.kts.template +++ b/settings.gradle.kts.template @@ -54,6 +54,11 @@ dependencyResolutionManagement { val compilerGroup = toolsGroup val validationGroup = baseGroup + ".validation" + library( + "coreJvm", + baseGroup, "spine-core" + ).versionRef(coreJvm) + library( "coreJvmCompiler", toolsGroup, "core-jvm-plugins" From 8245e93fab4d9b8e76539f81f0334cb9b5e5623c Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sun, 28 Sep 2025 19:26:50 +0100 Subject: [PATCH 12/25] Remove imports of dependency objects --- build.gradle.kts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 017747e..a7c296d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,21 +24,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import io.spine.dependency.local.Compiler -import io.spine.dependency.local.CoreJvm -import io.spine.dependency.local.CoreJvmCompiler -import io.spine.dependency.local.Validation import io.spine.gradle.UpdateJournal import io.spine.gradle.base.build import io.spine.gradle.repo.standardToSpineSdk import java.util.function.Supplier +import org.gradle.accessors.dm.LibrariesForSpine buildscript { standardSpineSdkRepositories() apply(from = "$rootDir/../version.gradle.kts") + val spine = the() val coreJvmCompilerVersion: String by extra dependencies { - classpath(coreJvmCompiler.pluginLib(coreJvmCompilerVersion)) + classpath(variantOf(spine.coreJvmCompiler) { classifier("all") }) } } @@ -48,12 +46,14 @@ plugins { id("com.osacky.doctor") version "0.8.1" } -apply(plugin = CoreJvmCompiler.pluginId) +apply(plugin = "io.spine.core-jvm") repositories.standardToSpineSdk() +val spine = the() + dependencies { - implementation(CoreJvm.server) + implementation(spine.server) } val customConfigFile = "../build-speed.gradle.kts" @@ -85,10 +85,10 @@ val recordExecTime by tasks.registering(UpdateJournal::class) { startTime = Supplier { startTimeMillis!! } versions.set( mapOf( - "Compiler" to Compiler.version, - "CoreJvmCompiler" to coreJvmCompilerVersion, - "CoreJvm" to CoreJvm.version, - "Validation" to Validation.version, + "Compiler" to spine.versions.spineCompiler.get(), + "CoreJvmCompiler" to spine.versions.coreJvmCompiler.get(), + "CoreJvm" to spine.versions.coreJvm.get(), + "Validation" to spine.versions.validation.get(), ) ) } From e8d2970e16b0bed85cd5a61d3536cbb4335127f6 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sun, 28 Sep 2025 19:40:18 +0100 Subject: [PATCH 13/25] Trim down `buildSrc` --- buildSrc/src/main/kotlin/BuildExtensions.kt | 204 ------- .../src/main/kotlin/DependencyResolution.kt | 122 ---- buildSrc/src/main/kotlin/DokkaExts.kt | 224 -------- .../main/kotlin/compile-protobuf.gradle.kts | 45 -- .../kotlin/detekt-code-analysis.gradle.kts | 85 --- .../src/main/kotlin/dokka-for-java.gradle.kts | 43 -- .../main/kotlin/dokka-for-kotlin.gradle.kts | 42 -- .../kotlin/io/spine/dependency/Dependency.kt | 132 ----- .../kotlin/io/spine/dependency/boms/Boms.kt | 66 --- .../io/spine/dependency/boms/BomsPlugin.kt | 185 ------ .../spine/dependency/build/AnimalSniffer.kt | 34 -- .../io/spine/dependency/build/CheckStyle.kt | 46 -- .../dependency/build/CheckerFramework.kt | 39 -- .../kotlin/io/spine/dependency/build/Dokka.kt | 84 --- .../io/spine/dependency/build/ErrorProne.kt | 62 -- .../io/spine/dependency/build/FindBugs.kt | 41 -- .../io/spine/dependency/build/GradleDoctor.kt | 38 -- .../io/spine/dependency/build/JSpecify.kt | 40 -- .../kotlin/io/spine/dependency/build/Ksp.kt | 56 -- .../spine/dependency/build/LicenseReport.kt | 40 -- .../io/spine/dependency/build/OsDetector.kt | 36 -- .../dependency/build/PluginPublishPlugin.kt | 42 -- .../kotlin/io/spine/dependency/build/Pmd.kt | 35 -- .../io/spine/dependency/kotlinx/AtomicFu.kt | 54 -- .../io/spine/dependency/kotlinx/Coroutines.kt | 54 -- .../io/spine/dependency/kotlinx/DateTime.kt | 34 -- .../io/spine/dependency/kotlinx/KotlinX.kt | 32 -- .../spine/dependency/kotlinx/Serialization.kt | 73 --- .../kotlin/io/spine/dependency/lib/Aedile.kt | 38 -- .../io/spine/dependency/lib/ApacheHttp.kt | 34 -- .../io/spine/dependency/lib/AppEngine.kt | 39 -- .../kotlin/io/spine/dependency/lib/Asm.kt | 43 -- .../kotlin/io/spine/dependency/lib/Auto.kt | 55 -- .../io/spine/dependency/lib/BouncyCastle.kt | 33 -- .../io/spine/dependency/lib/Caffeine.kt | 43 -- .../kotlin/io/spine/dependency/lib/Clikt.kt | 34 -- .../io/spine/dependency/lib/CommonsCli.kt | 39 -- .../io/spine/dependency/lib/CommonsCodec.kt | 34 -- .../io/spine/dependency/lib/CommonsLogging.kt | 38 -- .../io/spine/dependency/lib/Coroutines.kt | 52 -- .../io/spine/dependency/lib/Firebase.kt | 34 -- .../kotlin/io/spine/dependency/lib/Flogger.kt | 42 -- .../io/spine/dependency/lib/GoogleApis.kt | 59 -- .../io/spine/dependency/lib/GoogleCloud.kt | 43 -- .../kotlin/io/spine/dependency/lib/Grpc.kt | 82 --- .../io/spine/dependency/lib/GrpcKotlin.kt | 44 -- .../kotlin/io/spine/dependency/lib/Gson.kt | 39 -- .../kotlin/io/spine/dependency/lib/Guava.kt | 44 -- .../io/spine/dependency/lib/HttpClient.kt | 42 -- .../io/spine/dependency/lib/IntelliJ.kt | 89 --- .../kotlin/io/spine/dependency/lib/J2ObjC.kt | 51 -- .../kotlin/io/spine/dependency/lib/Jackson.kt | 127 ----- .../io/spine/dependency/lib/JavaDiffUtils.kt | 42 -- .../kotlin/io/spine/dependency/lib/JavaJwt.kt | 46 -- .../io/spine/dependency/lib/JavaPoet.kt | 37 -- .../kotlin/io/spine/dependency/lib/JavaX.kt | 37 -- .../kotlin/io/spine/dependency/lib/Klaxon.kt | 38 -- .../kotlin/io/spine/dependency/lib/Kotlin.kt | 120 ---- .../io/spine/dependency/lib/KotlinPoet.kt | 35 -- .../io/spine/dependency/lib/KotlinSemver.kt | 34 -- .../kotlin/io/spine/dependency/lib/KotlinX.kt | 60 -- .../kotlin/io/spine/dependency/lib/Log4j2.kt | 42 -- .../kotlin/io/spine/dependency/lib/Netty.kt | 38 -- .../kotlin/io/spine/dependency/lib/Okio.kt | 38 -- .../kotlin/io/spine/dependency/lib/Plexus.kt | 48 -- .../io/spine/dependency/lib/Protobuf.kt | 71 --- .../kotlin/io/spine/dependency/lib/Roaster.kt | 45 -- .../kotlin/io/spine/dependency/lib/Slf4J.kt | 47 -- .../kotlin/io/spine/dependency/local/Base.kt | 44 -- .../io/spine/dependency/local/BaseTypes.kt | 40 -- .../io/spine/dependency/local/Change.kt | 40 -- .../io/spine/dependency/local/Compiler.kt | 176 ------ .../io/spine/dependency/local/CoreJvm.kt | 51 -- .../spine/dependency/local/CoreJvmCompiler.kt | 83 --- .../io/spine/dependency/local/Logging.kt | 57 -- .../io/spine/dependency/local/McJava.kt | 79 --- .../spine/dependency/local/ModelCompiler.kt | 40 -- .../io/spine/dependency/local/ProtoData.kt | 178 ------ .../io/spine/dependency/local/ProtoTap.kt | 46 -- .../io/spine/dependency/local/Reflect.kt | 40 -- .../kotlin/io/spine/dependency/local/Spine.kt | 36 -- .../io/spine/dependency/local/TestLib.kt | 40 -- .../kotlin/io/spine/dependency/local/Text.kt | 40 -- .../kotlin/io/spine/dependency/local/Time.kt | 42 -- .../io/spine/dependency/local/ToolBase.kt | 61 -- .../io/spine/dependency/local/Validation.kt | 65 --- .../io/spine/dependency/test/AssertK.kt | 39 -- .../io/spine/dependency/test/Hamcrest.kt | 40 -- .../kotlin/io/spine/dependency/test/JUnit.kt | 119 ---- .../kotlin/io/spine/dependency/test/Jacoco.kt | 37 -- .../kotlin/io/spine/dependency/test/Kotest.kt | 60 -- .../dependency/test/KotlinCompileTesting.kt | 40 -- .../kotlin/io/spine/dependency/test/Kover.kt | 35 -- .../io/spine/dependency/test/OpenTest4J.kt | 38 -- .../io/spine/dependency/test/SystemLambda.kt | 35 -- .../io/spine/dependency/test/TestKitTruth.kt | 41 -- .../kotlin/io/spine/dependency/test/Truth.kt | 38 -- .../io/spine/gradle/ProjectExtensions.kt | 20 - .../kotlin/io/spine/gradle/VersionWriter.kt | 149 ----- .../gradle/checkstyle/CheckStyleConfig.kt | 76 --- .../io/spine/gradle/dart/DartContext.kt | 45 -- .../io/spine/gradle/dart/DartEnvironment.kt | 170 ------ .../io/spine/gradle/dart/DartExtension.kt | 187 ------ .../spine/gradle/dart/plugin/DartPlugins.kt | 92 --- .../io/spine/gradle/dart/plugin/Protobuf.kt | 52 -- .../kotlin/io/spine/gradle/dart/task/Build.kt | 155 ----- .../io/spine/gradle/dart/task/DartTasks.kt | 115 ---- .../spine/gradle/dart/task/IntegrationTest.kt | 92 --- .../io/spine/gradle/dart/task/Publish.kt | 176 ------ .../io/spine/gradle/dokka/DokkaExtensions.kt | 48 -- .../gradle/dokka/TaskContainerExtensions.kt | 36 -- .../spine/gradle/github/pages/AuthorEmail.kt | 56 -- .../github/pages/RepositoryExtensions.kt | 58 -- .../io/spine/gradle/github/pages/SshKey.kt | 104 ---- .../io/spine/gradle/github/pages/TaskName.kt | 47 -- .../io/spine/gradle/github/pages/Update.kt | 167 ------ .../gradle/github/pages/UpdateGitHubPages.kt | 234 -------- .../pages/UpdateGitHubPagesExtension.kt | 131 ----- .../io/spine/gradle/javadoc/Encoding.kt | 32 -- .../gradle/javadoc/ExcludeInternalDoclet.kt | 115 ---- .../io/spine/gradle/javadoc/JavadocConfig.kt | 160 ------ .../io/spine/gradle/javadoc/JavadocTag.kt | 37 -- .../io/spine/gradle/javascript/JsContext.kt | 62 -- .../spine/gradle/javascript/JsEnvironment.kt | 255 --------- .../io/spine/gradle/javascript/JsExtension.kt | 194 ------- .../io/spine/gradle/javascript/plugin/Idea.kt | 64 --- .../gradle/javascript/plugin/JsPlugins.kt | 92 --- .../io/spine/gradle/javascript/plugin/McJs.kt | 63 --- .../gradle/javascript/plugin/Protobuf.kt | 86 --- .../spine/gradle/javascript/task/Assemble.kt | 205 ------- .../io/spine/gradle/javascript/task/Check.kt | 197 ------- .../io/spine/gradle/javascript/task/Clean.kt | 124 ---- .../gradle/javascript/task/IntegrationTest.kt | 128 ----- .../spine/gradle/javascript/task/JsTasks.kt | 118 ---- .../gradle/javascript/task/LicenseReport.kt | 89 --- .../spine/gradle/javascript/task/Publish.kt | 194 ------- .../spine/gradle/javascript/task/Webpack.kt | 108 ---- .../gradle/publish/CheckVersionIncrement.kt | 147 ----- .../io/spine/gradle/publish/CloudRepo.kt | 69 --- .../publish/CustomPublicationHandler.kt | 70 --- .../io/spine/gradle/publish/IncrementGuard.kt | 109 ---- .../gradle/publish/PublicationHandler.kt | 250 -------- .../io/spine/gradle/publish/PublishingExts.kt | 323 ----------- .../io/spine/gradle/publish/ShadowJarExts.kt | 77 --- .../spine/gradle/publish/SpinePublishing.kt | 535 ------------------ .../publish/StandardJavaPublicationHandler.kt | 133 ----- .../io/spine/gradle/repo/Repositories.kt | 9 - .../gradle/report/coverage/CodebaseFilter.kt | 112 ---- .../gradle/report/coverage/FileExtension.kt | 49 -- .../gradle/report/coverage/FileExtensions.kt | 129 ----- .../gradle/report/coverage/FileFilter.kt | 50 -- .../gradle/report/coverage/JacocoConfig.kt | 245 -------- .../gradle/report/coverage/PathMarker.kt | 70 --- .../spine/gradle/report/coverage/TaskName.kt | 39 -- .../gradle/report/license/Configuration.kt | 51 -- .../gradle/report/license/LicenseReporter.kt | 163 ------ .../report/license/MarkdownReportRenderer.kt | 61 -- .../report/license/ModuleDataExtensions.kt | 168 ------ .../io/spine/gradle/report/license/Paths.kt | 49 -- .../report/license/ProjectDependencies.kt | 70 --- .../io/spine/gradle/report/license/Tasks.kt | 40 -- .../spine/gradle/report/license/Template.kt | 76 --- .../gradle/report/pom/DependencyScope.kt | 45 -- .../gradle/report/pom/DependencyWriter.kt | 207 ------- .../spine/gradle/report/pom/InceptionYear.kt | 51 -- .../gradle/report/pom/MarkupExtensions.kt | 38 -- .../gradle/report/pom/ModuleDependency.kt | 95 ---- .../spine/gradle/report/pom/PomFormatting.kt | 111 ---- .../spine/gradle/report/pom/PomGenerator.kt | 99 ---- .../spine/gradle/report/pom/PomXmlWriter.kt | 84 --- .../gradle/report/pom/ProjectMetadata.kt | 103 ---- .../gradle/report/pom/ScopedDependency.kt | 179 ------ .../spine/gradle/report/pom/SpineLicense.kt | 59 -- .../io/spine/gradle/testing/Multiproject.kt | 4 - .../main/kotlin/jacoco-kotlin-jvm.gradle.kts | 67 --- .../src/main/kotlin/jvm-module.gradle.kts | 203 ------- .../src/main/kotlin/pmd-settings.gradle.kts | 56 -- .../src/main/kotlin/write-manifest.gradle.kts | 165 ------ gradle.properties | 2 +- 179 files changed, 1 insertion(+), 14818 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/DokkaExts.kt delete mode 100644 buildSrc/src/main/kotlin/compile-protobuf.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/detekt-code-analysis.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/dokka-for-java.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/dokka-for-kotlin.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/AnimalSniffer.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/CheckStyle.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/CheckerFramework.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/ErrorProne.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/FindBugs.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/GradleDoctor.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/LicenseReport.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/OsDetector.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Aedile.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/ApacheHttp.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/AppEngine.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Asm.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Auto.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/BouncyCastle.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Clikt.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCli.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCodec.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsLogging.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Firebase.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Flogger.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleApis.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleCloud.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/HttpClient.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/IntelliJ.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/J2ObjC.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaDiffUtils.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaJwt.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaPoet.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Klaxon.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Log4j2.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Netty.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Okio.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Plexus.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/lib/Slf4J.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/ModelCompiler.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Text.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/Kotest.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/OpenTest4J.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/SystemLambda.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/TestKitTruth.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/VersionWriter.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/DartContext.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/DartEnvironment.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/DartExtension.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/DartPlugins.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/Protobuf.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Build.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/task/DartTasks.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/task/IntegrationTest.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Publish.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dokka/DokkaExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/dokka/TaskContainerExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/AuthorEmail.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/SshKey.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/TaskName.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/Update.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPagesExtension.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javadoc/Encoding.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocTag.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsContext.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsEnvironment.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsExtension.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Idea.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/JsPlugins.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/McJs.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Protobuf.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Assemble.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Check.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Clean.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/IntegrationTest.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/JsTasks.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/LicenseReport.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Publish.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Webpack.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/IncrementGuard.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtension.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileFilter.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/PathMarker.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/TaskName.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/Configuration.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/MarkdownReportRenderer.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/Paths.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/ProjectDependencies.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/Tasks.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyScope.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/InceptionYear.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/MarkupExtensions.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ProjectMetadata.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ScopedDependency.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/report/pom/SpineLicense.kt delete mode 100644 buildSrc/src/main/kotlin/jacoco-kotlin-jvm.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/jvm-module.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/pmd-settings.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/write-manifest.gradle.kts diff --git a/buildSrc/src/main/kotlin/BuildExtensions.kt b/buildSrc/src/main/kotlin/BuildExtensions.kt index 34e262b..792671a 100644 --- a/buildSrc/src/main/kotlin/BuildExtensions.kt +++ b/buildSrc/src/main/kotlin/BuildExtensions.kt @@ -26,17 +26,6 @@ @file:Suppress("UnusedReceiverParameter", "unused", "TopLevelPropertyNaming", "ObjectPropertyName") -import io.spine.dependency.build.ErrorProne -import io.spine.dependency.build.GradleDoctor -import io.spine.dependency.build.Ksp -import io.spine.dependency.build.PluginPublishPlugin -import io.spine.dependency.lib.Protobuf -import io.spine.dependency.local.CoreJvmCompiler -import io.spine.dependency.local.Compiler -import io.spine.dependency.local.McJava -import io.spine.dependency.local.ProtoTap -import io.spine.dependency.test.Kotest -import io.spine.dependency.test.Kover import io.spine.gradle.repo.standardToSpineSdk import org.gradle.api.Project import org.gradle.api.Task @@ -74,199 +63,6 @@ fun ScriptHandlerScope.standardSpineSdkRepositories() { repositories.standardToSpineSdk() } -/** - * Shortcut to [Protobuf] dependency object for using under `buildScript`. - */ -val ScriptHandlerScope.protobuf: Protobuf - get() = Protobuf - -/** - * Shortcut to [CoreJvmCompiler] dependency object for using under `buildScript`. - */ -val ScriptHandlerScope.coreJvmCompiler: CoreJvmCompiler - get() = CoreJvmCompiler - -/** - * Shortcut to [McJava] dependency object for using under `buildScript`. - */ -val ScriptHandlerScope.mcJava: McJava - get() = McJava - -/** - * Shortcut to [CoreJvmCompiler] dependency object. - * - * This plugin is not published to Gradle Portal and cannot be applied directly to a project. - * Firstly, it should be put to buildscript's classpath and then applied by ID only. - */ -val PluginDependenciesSpec.coreJvmCompiler: CoreJvmCompiler - get() = CoreJvmCompiler - -/** - * Shortcut to [Compiler] dependency object for using under `buildscript`. - */ -val ScriptHandlerScope.spineCompiler: Compiler - get() = Compiler - -/** - * Shortcut to [Compiler] dependency object. - * - * This plugin is published at Gradle Plugin Portal. - * But when used in a pair with [mcJava], it cannot be applied directly to a project. - * It is so, because [mcJava] uses [spineCompiler] as its dependency. - * And the buildscript's classpath ends up with both of them. - */ -val PluginDependenciesSpec.spineCompiler: Compiler - get() = Compiler - -/** - * Provides shortcuts for applying plugins from our dependency objects. - * - * Dependency objects cannot be used under `plugins` section because `io` is a value - * declared in auto-generated `org.gradle.kotlin.dsl.PluginAccessors.kt` file. - * It conflicts with our own declarations. - * - * Declaring of top-level shortcuts eliminates the need to apply plugins - * using a fully qualified name of dependency objects. - * - * It is still possible to apply a plugin with a custom version, if needed. - * Just declare a version again on the returned [PluginDependencySpec]. - * - * For example: - * - * ``` - * plugins { - * protobuf version("0.8.19-custom") - * } - * ``` - */ -private const val ABOUT_PLUGIN_ACCESSORS = "" - -val PluginDependenciesSpec.errorprone: PluginDependencySpec - get() = id(ErrorProne.GradlePlugin.id) - -val PluginDependenciesSpec.protobuf: PluginDependencySpec - get() = id(Protobuf.GradlePlugin.id) - -val PluginDependenciesSpec.prototap: PluginDependencySpec - get() = id(ProtoTap.gradlePluginId).version(ProtoTap.version) - -val PluginDependenciesSpec.`gradle-doctor`: PluginDependencySpec - get() = id(GradleDoctor.pluginId).version(GradleDoctor.version) - -val PluginDependenciesSpec.kotest: PluginDependencySpec - get() = Kotest.MultiplatformGradlePlugin.let { - return id(it.id).version(it.version) - } - -val PluginDependenciesSpec.kover: PluginDependencySpec - get() = id(Kover.id).version(Kover.version) - -val PluginDependenciesSpec.ksp: PluginDependencySpec - get() = id(Ksp.id).version(Ksp.version) - -val PluginDependenciesSpec.`plugin-publish`: PluginDependencySpec - get() = id(PluginPublishPlugin.id).version(PluginPublishPlugin.version) - -/** - * Configures the dependencies between third-party Gradle tasks - * and those defined via the Spine Compiler and its plugins. - * - * It is required to avoid warnings in build logs, detecting the undeclared - * usage of Spine-specific task output by other tasks, - * e.g., the output of `launchSpineCompiler` is used by `compileKotlin`. - */ -@Suppress("unused") -fun Project.configureTaskDependencies() { - - /** - * Creates a dependency between the Gradle task of *this* name - * onto the task with `taskName`. - * - * If either of tasks does not exist in the enclosing `Project`, - * this method does nothing. - * - * This extension is kept local to `configureTaskDependencies` extension - * to prevent its direct usage from outside. - */ - fun String.dependOn(taskName: String) { - val whoDepends = this - val dependOntoTask: Task? = tasks.findByName(taskName) - dependOntoTask?.let { - tasks.findByName(whoDepends)?.dependsOn(it) - } - } - - afterEvaluate { - val launchProtoData = "launchProtoData" - val launchTestProtoData = "launchTestProtoData" - val generateProto = "generateProto" - val createVersionFile = "createVersionFile" - val compileKotlin = "compileKotlin" - compileKotlin.run { - dependOn(generateProto) - dependOn(launchProtoData) - } - val compileTestKotlin = "compileTestKotlin" - compileTestKotlin.dependOn(launchTestProtoData) - val sourcesJar = "sourcesJar" - val kspKotlin = "kspKotlin" - sourcesJar.run { - dependOn(generateProto) - dependOn(launchProtoData) - dependOn(kspKotlin) - dependOn(createVersionFile) - dependOn("prepareProtocConfigVersions") - } - val dokkaHtml = "dokkaHtml" - dokkaHtml.run { - dependOn(generateProto) - dependOn(launchProtoData) - dependOn(kspKotlin) - } - val dokkaJavadoc = "dokkaJavadoc" - dokkaJavadoc.run { - dependOn(launchProtoData) - dependOn(kspKotlin) - } - "publishPluginJar".dependOn(createVersionFile) - compileKotlin.dependOn(kspKotlin) - compileTestKotlin.dependOn("kspTestKotlin") - "compileTestFixturesKotlin".dependOn("kspTestFixturesKotlin") - "javadocJar".dependOn(dokkaHtml) - "dokkaKotlinJar".dependOn(dokkaJavadoc) - } -} - -/** - * Obtains all modules names of which do not have `"-tests"` as the suffix. - * - * By convention, such modules are for integration tests and should be treated differently. - */ -val Project.productionModules: Iterable - get() = rootProject.subprojects.filterNot { subproject -> - subproject.name.run { - contains("-tests") - || contains("test-fixtures") - || contains("integration-tests") - } - } - -/** - * Obtains the names of the [productionModules]. - * - * The extension could be useful for excluding modules from standard publishing: - * ```kotlin - * spinePublishing { - * val customModule = "my-custom-module" - * modules = productionModuleNames.toSet().minus(customModule) - * modulesWithCustomPublishing = setOf(customModule) - * //... - * } - * ``` - */ -val Project.productionModuleNames: List - get() = productionModules.map { it.name } - /** * Sets the remote debug option for this [JavaExec] task. * diff --git a/buildSrc/src/main/kotlin/DependencyResolution.kt b/buildSrc/src/main/kotlin/DependencyResolution.kt index 124adb3..63c48b0 100644 --- a/buildSrc/src/main/kotlin/DependencyResolution.kt +++ b/buildSrc/src/main/kotlin/DependencyResolution.kt @@ -24,34 +24,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import io.spine.dependency.build.AnimalSniffer -import io.spine.dependency.build.CheckerFramework -import io.spine.dependency.build.Dokka -import io.spine.dependency.build.ErrorProne -import io.spine.dependency.build.FindBugs -import io.spine.dependency.build.JSpecify -import io.spine.dependency.lib.Asm -import io.spine.dependency.lib.AutoCommon -import io.spine.dependency.lib.AutoService -import io.spine.dependency.lib.AutoValue -import io.spine.dependency.lib.CommonsCli -import io.spine.dependency.lib.CommonsCodec -import io.spine.dependency.lib.CommonsLogging -import io.spine.dependency.lib.Gson -import io.spine.dependency.lib.Guava -import io.spine.dependency.lib.J2ObjC -import io.spine.dependency.lib.JavaDiffUtils -import io.spine.dependency.lib.Kotlin -import io.spine.dependency.lib.Okio -import io.spine.dependency.lib.Plexus -import io.spine.dependency.lib.Protobuf -import io.spine.dependency.lib.Slf4J -import io.spine.dependency.local.Base -import io.spine.dependency.local.Spine -import io.spine.dependency.test.Hamcrest -import io.spine.dependency.test.Kotest -import io.spine.dependency.test.OpenTest4J -import io.spine.dependency.test.Truth import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project import org.gradle.api.artifacts.Configuration @@ -76,69 +48,10 @@ fun NamedDomainObjectContainer.forceVersions() { resolutionStrategy { failOnVersionConflict() cacheChangingModulesFor(0, "seconds") - forceProductionDependencies() - forceTestDependencies() - forceTransitiveDependencies() } } } -private fun ResolutionStrategy.forceProductionDependencies() { - @Suppress("DEPRECATION") // Force versions of SLF4J and Kotlin libs. - Protobuf.libs.forEach { - force(it) - } - force( - AnimalSniffer.lib, - AutoCommon.lib, - AutoService.annotations, - CheckerFramework.annotations, - Dokka.BasePlugin.lib, - ErrorProne.annotations, - ErrorProne.core, - FindBugs.annotations, - Gson.lib, - Guava.lib, - JSpecify.annotations, - Protobuf.GradlePlugin.lib, - Protobuf.libs, - Slf4J.lib - ) -} - -private fun ResolutionStrategy.forceTestDependencies() { - force( - Guava.testLib, - Truth.libs, - Kotest.assertions, - ) -} - -/** - * Forces transitive dependencies of 3rd party components that we don't use directly. - */ -private fun ResolutionStrategy.forceTransitiveDependencies() { - force( - Asm.lib, - Asm.tree, - Asm.analysis, - Asm.util, - Asm.commons, - AutoValue.annotations, - CommonsCli.lib, - CommonsCodec.lib, - CommonsLogging.lib, - Gson.lib, - Hamcrest.core, - J2ObjC.annotations, - JavaDiffUtils.lib, - Kotlin.jetbrainsAnnotations, - Okio.lib, - OpenTest4J.lib, - Plexus.utils, - ) -} - @Suppress("unused") fun NamedDomainObjectContainer.excludeProtobufLite() { @@ -154,38 +67,3 @@ fun NamedDomainObjectContainer.excludeProtobufLite() { excludeProtoLite("runtimeOnly") excludeProtoLite("testRuntimeOnly") } - -/** - * Excludes `spine-base` from the dependencies. - */ -@Suppress("unused") -fun ModuleDependency.excludeSpineBase() { - exclude(group = Spine.group, module = "spine-base") -} - -/** - * Forces the version of [Spine.base] in the given project. - */ -@Suppress("unused") -fun Project.forceSpineBase() { - configurations.all { - resolutionStrategy { - force(Base.lib) - } - } -} - -/** - * Forces configurations containing `"proto"` in their names (disregarding the case) to - * use [Spine.baseForBuildScript]. - */ -@Suppress("unused") -fun Project.forceBaseInProtoTasks() { - configurations.configureEach { - if (name.lowercase().contains("proto")) { - resolutionStrategy { - force(Base.libForBuildScript) - } - } - } -} diff --git a/buildSrc/src/main/kotlin/DokkaExts.kt b/buildSrc/src/main/kotlin/DokkaExts.kt deleted file mode 100644 index ff5de3f..0000000 --- a/buildSrc/src/main/kotlin/DokkaExts.kt +++ /dev/null @@ -1,224 +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. - */ - -import io.spine.dependency.build.Dokka -import io.spine.gradle.publish.getOrCreate -import java.io.File -import java.time.LocalDate -import org.gradle.api.Project -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.dsl.DependencyHandler -import org.gradle.api.file.FileCollection -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Jar -import org.gradle.kotlin.dsl.DependencyHandlerScope -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.base.DokkaBase -import org.jetbrains.dokka.base.DokkaBaseConfiguration -import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask -import org.jetbrains.dokka.gradle.AbstractDokkaTask -import org.jetbrains.dokka.gradle.DokkaTask -import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder - -/** - * To generate the documentation as seen from Java perspective, the `kotlin-as-java` - * plugin was added to the Dokka classpath. - * - * @see - * Dokka output formats - */ -fun DependencyHandlerScope.useDokkaForKotlinAsJava() { - dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib) -} - -/** - * To exclude pieces of code annotated with `@Internal` from the documentation - * a custom plugin is added to the Dokka classpath. - * - * @see - * Custom Dokka Plugins - */ -fun DependencyHandlerScope.useDokkaWithSpineExtensions() { - dokkaPlugin(Dokka.SpineExtensions.lib) -} - -private fun DependencyHandler.dokkaPlugin(dependencyNotation: Any): Dependency? = - add("dokkaPlugin", dependencyNotation) - -private fun Project.dokkaOutput(language: String): File { - val lng = language.titleCaseFirstChar() - return layout.buildDirectory.dir("docs/dokka$lng").get().asFile -} - -fun Project.dokkaConfigFile(file: String): File { - val dokkaConfDir = project.rootDir.resolve("buildSrc/src/main/resources/dokka") - return dokkaConfDir.resolve(file) -} - -/** - * Configures the presentation style, logo, and footer message. - * - * Dokka Base plugin allows setting a few properties to customize the output: - * - `customStyleSheets` property to which CSS files are passed overriding - * styles generated by Dokka; - * - `customAssets` property to provide resources. The image with the name - * "logo-icon.svg" is passed to override the default logo used by Dokka; - * - `separateInheritedMembers` when set to `true`, creates a separate tab in - * type-documentation for inherited members. - * - * @see - * Dokka modifying frontend assets - */ -fun AbstractDokkaTask.configureStyle() { - pluginConfiguration { - customStyleSheets = listOf(project.dokkaConfigFile("styles/custom-styles.css")) - customAssets = listOf(project.dokkaConfigFile("assets/logo-icon.svg")) - separateInheritedMembers = true - footerMessage = "Copyright ${LocalDate.now().year}, TeamDev" - } -} - -private fun AbstractDokkaLeafTask.configureFor(language: String) { - dokkaSourceSets.configureEach { - /** - * Configures links to the external Java documentation. - */ - jdkVersion.set(BuildSettings.javaVersion.asInt()) - - skipEmptyPackages.set(true) - - includeNonPublic.set(true) - - documentedVisibilities.set( - setOf( - DokkaConfiguration.Visibility.PUBLIC, - DokkaConfiguration.Visibility.PROTECTED - ) - ) - } - - outputDirectory.set(project.dokkaOutput(language)) - - configureStyle() -} - -/** - * Configures this [DokkaTask] to accept only Kotlin files. - */ -fun AbstractDokkaLeafTask.configureForKotlin() { - configureFor("kotlin") -} - -/** - * Configures this [DokkaTask] to accept only Java files. - */ -fun AbstractDokkaLeafTask.configureForJava() { - configureFor("java") -} - -/** - * Finds the `dokkaHtml` Gradle task. - */ -fun TaskContainer.dokkaHtmlTask(): DokkaTask? = this.findByName("dokkaHtml") as DokkaTask? - -/** - * Returns only Java source roots out of all present in the source set. - * - * It is a helper method for generating documentation by Dokka only for Java code. - * It is helpful when both Java and Kotlin source files are present in a source set. - * Dokka can properly generate documentation for either Kotlin or Java depending on - * the configuration, but not both. - */ -@Suppress("unused") -internal fun GradleDokkaSourceSetBuilder.onlyJavaSources(): FileCollection { - return sourceRoots.filter(File::isJavaSourceDirectory) -} - -private fun File.isJavaSourceDirectory(): Boolean { - return isDirectory && name == "java" -} - -/** - * Locates or creates `dokkaKotlinJar` task in this [Project]. - * - * The output of this task is a `jar` archive. The archive contains the Dokka output, generated upon - * Kotlin sources from `main` source set. Requires Dokka to be configured in the target project by - * applying `dokka-for-kotlin` plugin. - */ -fun Project.dokkaKotlinJar(): TaskProvider = tasks.getOrCreate("dokkaKotlinJar") { - archiveClassifier.set("dokka") - from(files(dokkaOutput("kotlin"))) - - tasks.dokkaHtmlTask()?.let{ dokkaTask -> - this@getOrCreate.dependsOn(dokkaTask) - } -} - -/** - * Tells if this task belongs to the execution graph which contains publishing tasks. - * - * The task `"publishToMavenLocal"` is excluded from the check because it is a part of - * the local testing workflow. - */ -fun AbstractDokkaTask.isInPublishingGraph(): Boolean = - project.gradle.taskGraph.allTasks.any { - it.name == "publish" - } - -/** - * Locates or creates `dokkaJavaJar` task in this [Project]. - * - * The output of this task is a `jar` archive. The archive contains the Dokka output, generated upon - * Kotlin sources from `main` source set. Requires Dokka to be configured in the target project by - * applying `dokka-for-java` and/or `dokka-for-kotlin` script plugin. - */ -fun Project.dokkaJavaJar(): TaskProvider = tasks.getOrCreate("dokkaJavaJar") { - archiveClassifier.set("dokka-java") - from(files(dokkaOutput("java"))) - - tasks.dokkaHtmlTask()?.let{ dokkaTask -> - this@getOrCreate.dependsOn(dokkaTask) - } -} - -/** - * Disables Dokka and Javadoc tasks in this `Project`. - * - * This function could be useful to improve build speed when building subprojects containing - * test environments or integration test projects. - */ -@Suppress("unused") -fun Project.disableDocumentationTasks() { - gradle.taskGraph.whenReady { - tasks.forEach { task -> - val lowercaseName = task.name.lowercase() - if (lowercaseName.contains("dokka") || lowercaseName.contains("javadoc")) { - task.enabled = false - } - } - } -} diff --git a/buildSrc/src/main/kotlin/compile-protobuf.gradle.kts b/buildSrc/src/main/kotlin/compile-protobuf.gradle.kts deleted file mode 100644 index 57a6b96..0000000 --- a/buildSrc/src/main/kotlin/compile-protobuf.gradle.kts +++ /dev/null @@ -1,45 +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. - */ - -import io.spine.dependency.lib.Protobuf -import io.spine.gradle.protobuf.setup - -plugins { - id("java-library") - id("com.google.protobuf") -} - - -// For generating test fixtures. See `src/test/proto`. -protobuf { - configurations.excludeProtobufLite() - protoc { - artifact = Protobuf.compiler - } - generateProtoTasks.all().configureEach { - setup() - } -} diff --git a/buildSrc/src/main/kotlin/detekt-code-analysis.gradle.kts b/buildSrc/src/main/kotlin/detekt-code-analysis.gradle.kts deleted file mode 100644 index 7b0ffd1..0000000 --- a/buildSrc/src/main/kotlin/detekt-code-analysis.gradle.kts +++ /dev/null @@ -1,85 +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. - */ - -import io.gitlab.arturbosch.detekt.Detekt - -/** - * This script-plugin sets up Kotlin code analyzing with Detekt. - * - * After applying, Detekt is configured to use `${rootDir}/config/quality/detekt-config.yml` file. - * Projects can append their own config files to override some parts of the default one or drop - * it at all in a favor of their own one. - * - * An example of appending a custom config file to the default one: - * - * ``` - * detekt { - * config.from("config/detekt-custom-config.yml") - * } - * ``` - * - * To totally substitute it, just overwrite the corresponding property: - * - * ``` - * detekt { - * config = files("config/detekt-custom-config.yml") - * } - * ``` - * - * Also, it's possible to suppress Detekt findings using [baseline](https://detekt.dev/docs/introduction/baseline/) - * file instead of suppressions in source code. - * - * An example of passing a baseline file: - * - * ``` - * detekt { - * baseline = file("config/detekt-baseline.yml") - * } - * ``` - */ -@Suppress("unused") -private val about = "" - -plugins { - id("io.gitlab.arturbosch.detekt") -} - -detekt { - buildUponDefaultConfig = true - config.from(files("${rootDir}/config/quality/detekt-config.yml")) -} - -tasks { - withType().configureEach { - reports { - html.required.set(true) // Only HTML report is generated. - xml.required.set(false) - txt.required.set(false) - sarif.required.set(false) - md.required.set(false) - } - } -} diff --git a/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts b/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts deleted file mode 100644 index ee22622..0000000 --- a/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts +++ /dev/null @@ -1,43 +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. - */ - -import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask - -plugins { - id("org.jetbrains.dokka") // Cannot use `Dokka` dependency object here yet. -} - -dependencies { - useDokkaForKotlinAsJava() - useDokkaWithSpineExtensions() -} - -tasks.withType().configureEach { - configureForJava() - onlyIf { - (it as AbstractDokkaLeafTask).isInPublishingGraph() - } -} diff --git a/buildSrc/src/main/kotlin/dokka-for-kotlin.gradle.kts b/buildSrc/src/main/kotlin/dokka-for-kotlin.gradle.kts deleted file mode 100644 index e50b10a..0000000 --- a/buildSrc/src/main/kotlin/dokka-for-kotlin.gradle.kts +++ /dev/null @@ -1,42 +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. - */ - -import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask - -plugins { - id("org.jetbrains.dokka") // Cannot use `Dokka` dependency object here yet. -} - -dependencies { - useDokkaWithSpineExtensions() -} - -tasks.withType().configureEach { - configureForKotlin() - onlyIf { - (it as AbstractDokkaLeafTask).isInPublishingGraph() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt b/buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt deleted file mode 100644 index 80c79f4..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/Dependency.kt +++ /dev/null @@ -1,132 +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.dependency - -import io.spine.gradle.log -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.ResolutionStrategy - -/** - * A dependency is a software component we use in a project. - * - * It could be a library, a set of libraries, or a development tool - * that participates in a build. - */ -abstract class Dependency { - - /** - * The version of the dependency in terms of Maven coordinates. - */ - abstract val version: String - - /** - * The group of the dependency in terms of Maven coordinates. - */ - abstract val group: String - - /** - * The modules of the dependency that we use directly or - * transitively in our projects. - */ - abstract val modules: List - - /** - * The [modules] given with the [version]. - */ - final val artifacts: Map by lazy { - modules.associateWith { "$it:$version" } - } - - /** - * Obtains full Maven coordinates for the requested [module]. - */ - fun artifact(module: String): String = artifacts[module] ?: error( - "The dependency `${this::class.simpleName}` does not declare a module `$module`." - ) - - /** - * Forces all artifacts of this dependency using the given resolution strategy. - * - * @param project The project in which the artifacts are forced. Used for logging. - * @param cfg The configuration for which the artifacts are forced. Used for logging. - * @param rs The resolution strategy which forces the artifacts. - */ - fun forceArtifacts(project: Project, cfg: Configuration, rs: ResolutionStrategy) { - artifacts.values.forEach { - rs.forceWithLogging(project, cfg, it) - } - } -} - -/** - * A dependency which declares a Maven Bill of Materials (BOM). - * - * @see - * Maven Bill of Materials - * @see io.spine.dependency.boms.Boms - * @see io.spine.dependency.boms.BomsPlugin - */ -abstract class DependencyWithBom : Dependency() { - - /** - * Maven coordinates of the dependency BOM. - */ - abstract val bom: String -} - -/** - * Returns the suffix of diagnostic messages for this configuration in the given project. - */ -fun Configuration.diagSuffix(project: Project): String = - "the configuration `$name` in the project: `${project.path}`." - - -private fun ResolutionStrategy.forceWithLogging( - project: Project, - configuration: Configuration, - artifact: String -) { - force(artifact) - project.log { "Forced the version of `$artifact` in " + configuration.diagSuffix(project) } -} - -/** - * Obtains full Maven coordinates for the requested [module]. - * - * This extension allows referencing properties of the [Dependency], - * upon which it is invoked. - * - * An example usage: - * - * ``` - * // Supposing there is `Ksp.symbolProcessingApi: String` property declared. - * Ksp.artifact { symbolProcessingApi } - * ``` - */ -fun T.artifact(module: T.() -> String): String = - artifact(module()) diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt b/buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt deleted file mode 100644 index df1751b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/boms/Boms.kt +++ /dev/null @@ -1,66 +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.dependency.boms - -import io.spine.dependency.DependencyWithBom -import io.spine.dependency.kotlinx.Coroutines -import io.spine.dependency.lib.Jackson -import io.spine.dependency.lib.Kotlin -import io.spine.dependency.lib.Grpc -import io.spine.dependency.test.JUnit - -/** - * The collection of references to BOMs applied by [BomsPlugin]. - * - * @see - * Maven Bill of Materials - */ -object Boms { - - /** - * The base production BOMs. - */ - val core: List = listOf( - Kotlin, - Coroutines - ) - - /** - * The BOMs for testing dependencies. - */ - val testing: List = listOf( - JUnit - ) - - /** - * Technology-based BOMs. - */ - object Optional { - val jackson = Jackson.bom - val grpc = Grpc.bom - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt deleted file mode 100644 index 2724dda..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/boms/BomsPlugin.kt +++ /dev/null @@ -1,185 +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.dependency.boms - -import io.gitlab.arturbosch.detekt.getSupportedKotlinVersion -import io.spine.dependency.DependencyWithBom -import io.spine.dependency.diagSuffix -import io.spine.dependency.kotlinx.Coroutines -import io.spine.dependency.lib.Kotlin -import io.spine.dependency.test.JUnit -import io.spine.gradle.log -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.ConfigurationContainer - -/** - * The plugin which forces versions of platforms declared in the [Boms] object. - * - * Versions are enforced via the - * [org.gradle.api.artifacts.dsl.DependencyHandler.enforcedPlatform] call - * for configurations of the project to which the plugin is applied. - * - * The configurations are selected by the "kind" of BOM. - * - * [Boms.core] are applied to: - * 1. Production configurations, such as `api` or `implementation`. - * 2. Compilation configurations. - * 3. All `ksp` configurations. - * - * [Boms.testing] are applied to all testing configurations. - * - * In addition to forcing BOM-based dependencies, - * the plugin [forces][org.gradle.api.artifacts.ResolutionStrategy.force] the versions - * of [Kotlin.StdLib.artifacts] for all configurations because even through Kotlin - * artifacts are forced with BOM, the `variants` in the dependencies cannot be - * picked by Gradle. - * - * Run Gradle with the [INFO][org.gradle.api.logging.Logger.isInfoEnabled] logging level - * to see the dependencies forced by this plugin. - */ -class BomsPlugin : Plugin { - - private val productionConfigs = listOf( - "api", - "implementation", - "compileOnly", - "runtimeOnly" - ) - - override fun apply(project: Project) = with(project) { - - configurations.run { - matching { isCompilationConfig(it.name) }.all { - applyBoms(project, Boms.core) - } - matching { isKspConfig(it.name) }.all { - applyBoms(project, Boms.core) - } - matching { it.name in productionConfigs }.all { - applyBoms(project, Boms.core) - } - matching { isTestConfig(it.name) }.all { - applyBoms(project, Boms.core + Boms.testing) - } - - matching { !supportsBom(it.name) }.all { - resolutionStrategy.eachDependency { - if (requested.group == Kotlin.group) { - val kotlinVersion = Kotlin.runtimeVersion - useVersion(kotlinVersion) - val suffix = this@all.diagSuffix(project) - log { "Forced Kotlin version `$kotlinVersion` in $suffix" } - } - } - } - - selectKotlinCompilerForDetekt() - project.forceArtifacts() - } - } -} - -private fun Configuration.applyBoms(project: Project, deps: List) { - deps.forEach { dep -> - withDependencies { - val platform = project.dependencies.platform(dep.bom) - addLater(project.provider { platform }) - project.log { - "Applied BOM: `${dep.bom}` to the configuration: `${this@applyBoms.name}`." - } - } - } -} - -private val Configuration.isDetekt: Boolean - get() = name.contains("detekt", ignoreCase = true) - -@Suppress("UnstableApiUsage") // `io.gitlab.arturbosch.detekt.getSupportedKotlinVersion` -private fun ConfigurationContainer.selectKotlinCompilerForDetekt() = - matching { it.isDetekt } - .configureEach { - resolutionStrategy.eachDependency { - if (requested.group == Kotlin.group) { - val supportedVersion = getSupportedKotlinVersion() - useVersion(supportedVersion) - because("Force Kotlin version $supportedVersion in Detekt configurations.") - } - } - } - -private fun isCompilationConfig(name: String) = - name.contains("compile", ignoreCase = true) && - // `compileProtoPath` or `compileTestProtoPath`. - !name.contains("ProtoPath", ignoreCase = true) - -private fun isKspConfig(name: String) = - name.startsWith("ksp", ignoreCase = true) - -private fun isTestConfig(name: String) = - name.startsWith("test", ignoreCase = true) - -/** - * Tells if the configuration with the given [name] supports forcing - * versions via the BOM mechanism. - * - * Not all configurations support forcing via BOM. E.g., the configurations created - * by Protobuf Gradle Plugin such as `compileProtoPath` or `extractIncludeProto` do - * not pick up versions of dependencies set via `enforcedPlatform(myBom)`. - */ -private fun supportsBom(name: String) = - (isCompilationConfig(name) || isKspConfig(name) || isTestConfig(name)) - -/** - * Forces the versions of the artifacts that are even being correctly selected by BOMs - * are not guaranteed to be handled correctly when Gradle picks up a `variant`. - * - * The function forces the versions for all configurations but [detekt][isDetekt], because - * it requires a compatible version of the Kotlin compiler. - * - * @see Kotlin.artifacts - * @see Kotlin.StdLib.artifacts - * @see Coroutines.artifacts - * @see selectKotlinCompilerForDetekt - */ -private fun Project.forceArtifacts() = - configurations.all { - resolutionStrategy { - if (!isDetekt) { - val rs = this@resolutionStrategy - val project = this@forceArtifacts - val cfg = this@all - Kotlin.forceArtifacts(project, cfg, rs) - Kotlin.StdLib.forceArtifacts(project, cfg, rs) - Coroutines.forceArtifacts(project, cfg, rs) - JUnit.Jupiter.forceArtifacts(project, cfg, rs) /* - for configurations like `testFixturesCompileProtoPath`. - */ - } - } - } diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/AnimalSniffer.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/AnimalSniffer.kt deleted file mode 100644 index 8258896..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/AnimalSniffer.kt +++ /dev/null @@ -1,34 +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.dependency.build - -// https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/ -@Suppress("unused", "ConstPropertyName") -object AnimalSniffer { - private const val version = "1.21" - const val lib = "org.codehaus.mojo:animal-sniffer-annotations:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/CheckStyle.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/CheckStyle.kt deleted file mode 100644 index e1e3b28..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/CheckStyle.kt +++ /dev/null @@ -1,46 +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.dependency.build - -/** - * Dependencies on Checkstyle Java linter. - * - * @see Checkstyle - * @see [io.spine.gradle.checkstyle.CheckStyleConfig] - */ -@Suppress("unused", "ConstPropertyName") -object CheckStyle { - /** - * The version to be used in the project. - * - * `10.12.1` is the last version in `10.12.0`, which does not introduce - * capability conflict over `google-collections` with Guava. - * - * @see Checkstyle - */ - const val version = "10.12.1" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/CheckerFramework.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/CheckerFramework.kt deleted file mode 100644 index 5d2140a..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/CheckerFramework.kt +++ /dev/null @@ -1,39 +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.dependency.build - -// https://checkerframework.org/ -@Suppress("unused", "ConstPropertyName") -object CheckerFramework { - private const val version = "3.40.0" - const val annotations = "org.checkerframework:checker-qual:$version" - @Suppress("unused") - val dataflow = listOf( - "org.checkerframework:dataflow:$version", - "org.checkerframework:javacutil:$version" - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt deleted file mode 100644 index 003bf58..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/Dokka.kt +++ /dev/null @@ -1,84 +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.dependency.build - -// https://github.com/Kotlin/dokka -@Suppress("unused", "ConstPropertyName") -object Dokka { - private const val group = "org.jetbrains.dokka" - - /** - * When changing the version, also change the version used in the - * `buildSrc/build.gradle.kts`. - */ - const val version = "2.0.0" - - object GradlePlugin { - const val id = "org.jetbrains.dokka" - - /** - * The version of this plugin is already specified in `buildSrc/build.gradle.kts` - * file. Thus, when applying the plugin to project's build files, only the [id] - * should be used. - */ - const val lib = "$group:dokka-gradle-plugin:$version" - } - - object BasePlugin { - const val lib = "$group:dokka-base:$version" - } - - const val analysis = "org.jetbrains.dokka:dokka-analysis:$version" - - object CorePlugin { - const val lib = "$group:dokka-core:$version" - } - - /** - * To generate the documentation as seen from the Java perspective, please use this plugin. - * - * @see - * Dokka output formats - */ - object KotlinAsJavaPlugin { - const val lib = "$group:kotlin-as-java-plugin:$version" - } - - /** - * Custom Dokka plugins developed for Spine-specific needs like excluding by - * `@Internal` annotation. - * - * @see - * Custom Dokka Plugins - */ - object SpineExtensions { - private const val group = "io.spine.tools" - - const val version = "2.0.0-SNAPSHOT.7" - const val lib = "$group:spine-dokka-extensions:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/ErrorProne.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/ErrorProne.kt deleted file mode 100644 index 5b47c1b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/ErrorProne.kt +++ /dev/null @@ -1,62 +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.dependency.build - -// https://errorprone.info/ -@Suppress("unused", "ConstPropertyName") -object ErrorProne { - // https://github.com/google/error-prone - private const val version = "2.36.0" - - const val group = "com.google.errorprone" - - // https://github.com/tbroyer/gradle-errorprone-plugin/blob/v0.8/build.gradle.kts - private const val javacPluginVersion = "9+181-r4173-1" - - val annotations = listOf( - "$group:error_prone_annotations:$version", - "$group:error_prone_type_annotations:$version" - ) - const val core = "$group:error_prone_core:$version" - const val checkApi = "$group:error_prone_check_api:$version" - const val testHelpers = "$group:error_prone_test_helpers:$version" - const val javacPlugin = "$group:javac:$javacPluginVersion" - - // https://github.com/tbroyer/gradle-errorprone-plugin/releases - object GradlePlugin { - const val id = "net.ltgt.errorprone" - /** - * The version of this plugin is already specified in `buildSrc/build.gradle.kts` file. - * Thus, when applying the plugin to project build files, only the [id] should be used. - * - * When the plugin is used as a library (e.g., in tools), its version and the library - * artifacts are of importance. - */ - const val version = "4.1.0" - const val lib = "net.ltgt.gradle:gradle-errorprone-plugin:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/FindBugs.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/FindBugs.kt deleted file mode 100644 index 98003b9..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/FindBugs.kt +++ /dev/null @@ -1,41 +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.dependency.build - -/** - * The FindBugs project has been dead since 2017. It has a successor called SpotBugs, - * but we don't use it. We use ErrorProne for static analysis instead. - * The only reason for having this dependency is the annotations for null-checking - * introduced by JSR-305. These annotations are troublesome, - * but no alternatives are known for some of them so far. - * Please see [this issue](https://github.com/SpineEventEngine/base/issues/108) for more details. - */ -@Suppress("unused", "ConstPropertyName") -object FindBugs { - private const val version = "3.0.2" - const val annotations = "com.google.code.findbugs:jsr305:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/GradleDoctor.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/GradleDoctor.kt deleted file mode 100644 index 89cfb34..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/GradleDoctor.kt +++ /dev/null @@ -1,38 +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.dependency.build - -/** - * Helps optimize Gradle Builds by ensuring recommendations at build time. - * - * See [plugin site](https://runningcode.github.io/gradle-doctor) for features and usage. - */ -@Suppress("unused", "ConstPropertyName") -object GradleDoctor { - const val version = "0.10.0" - const val pluginId = "com.osacky.doctor" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt deleted file mode 100644 index d884ffb..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/JSpecify.kt +++ /dev/null @@ -1,40 +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.dependency.build - -/** - * An artifact of well-specified annotations to power static analysis - * checks and JVM language interop. Developed by consensus of the partner - * organizations listed at [the project site](https://jspecify.org). - * - * @see JSpecify at GitHub - */ -@Suppress("ConstPropertyName") -object JSpecify { - const val version = "1.0.0" - const val annotations = "org.jspecify:jspecify:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt deleted file mode 100644 index 3ea45b3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/Ksp.kt +++ /dev/null @@ -1,56 +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.dependency.build - -import io.spine.dependency.Dependency - -/** - * Kotlin Symbol Processing API. - * - * @see KSP GitHub repository - */ -@Suppress("unused") -object Ksp : Dependency() { - override val version = "2.1.21-2.0.1" - override val group = "com.google.devtools.ksp" - - const val id = "com.google.devtools.ksp" - - val symbolProcessingApi = "$group:symbol-processing-api" - val symbolProcessing = "$group:symbol-processing" - val symbolProcessingAaEmb = "$group:symbol-processing-aa-embeddable" - val symbolProcessingCommonDeps = "$group:symbol-processing-common-deps" - val gradlePlugin = "$group:symbol-processing-gradle-plugin" - - override val modules = listOf( - symbolProcessingApi, - symbolProcessing, - symbolProcessingAaEmb, - symbolProcessingCommonDeps, - gradlePlugin, - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/LicenseReport.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/LicenseReport.kt deleted file mode 100644 index a4eb754..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/LicenseReport.kt +++ /dev/null @@ -1,40 +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.dependency.build - -// https://github.com/jk1/Gradle-License-Report -@Suppress("unused") -object LicenseReport { - private const val version = "1.16" - const val lib = "com.github.jk1:gradle-license-report:$version" - - object GradlePlugin { - const val version = LicenseReport.version - const val id = "com.github.jk1.dependency-license-report" - const val lib = LicenseReport.lib - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/OsDetector.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/OsDetector.kt deleted file mode 100644 index 5b479bf..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/OsDetector.kt +++ /dev/null @@ -1,36 +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.dependency.build - -@Suppress("unused", "ConstPropertyName") -object OsDetector { - // https://github.com/google/osdetector-gradle-plugin - const val version = "1.7.3" - const val id = "com.google.osdetector" - const val lib = "com.google.gradle:osdetector-gradle-plugin:$version" - const val classpath = lib -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt deleted file mode 100644 index 12c28f8..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/PluginPublishPlugin.kt +++ /dev/null @@ -1,42 +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. - */ - -@file:Suppress("unused") - -package io.spine.dependency.build - -/** - * The Gradle plugin for publishing Gradle plugins to the Gradle Plugin Portal. - * - * @see - * The plugin page at the Portal - * @see Publishing Rules - */ -@Suppress("ConstPropertyName") -object PluginPublishPlugin { - const val version = "1.3.1" - const val id = "com.gradle.plugin-publish" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt b/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt deleted file mode 100644 index dd71b49..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/build/Pmd.kt +++ /dev/null @@ -1,35 +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. - */ - -@file:Suppress("MaxLineLength") - -package io.spine.dependency.build - -// https://github.com/pmd/pmd/releases -@Suppress("unused", "ConstPropertyName") -object Pmd { - const val version = "7.12.0" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt deleted file mode 100644 index a245bcb..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/AtomicFu.kt +++ /dev/null @@ -1,54 +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.dependency.kotlinx - -import io.spine.dependency.Dependency - -/** - * Kotlin/Multiplatform AtomicFU library. - * - * https://github.com/Kotlin/kotlinx.atomicfu - */ -object AtomicFu : Dependency() { - - override val version: String = "0.29.0" - - override val group: String = KotlinX.group - - @Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names - const val module = "atomicfu" - - /** - * The base artifact without platform classifier. - */ - val std = "$group:$module" - - override val modules: List = listOf(std) - - /** Convenience: full coordinates with the version for the standard artifact. */ - val lib: String get() = artifact(std) -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt deleted file mode 100644 index 7fa3bd8..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Coroutines.kt +++ /dev/null @@ -1,54 +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.dependency.kotlinx - -import io.spine.dependency.DependencyWithBom - -/** - * Kotlin Coroutines. - * - * @see GitHub project - */ -object Coroutines : DependencyWithBom() { - override val group = KotlinX.group - override val version = "1.10.2" - - @Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names - const val infix = "kotlinx-coroutines" - - override val bom = "$group:$infix-bom:$version" - - val core = "$group:$infix-core" - val coreJvm = "$group:$infix-core-jvm" - val jdk7 = "$group:$infix-jdk7" - val jdk8 = "$group:$infix-jdk8" - val debug = "$group:$infix-debug" - val test = "$group:$infix-test" - val testJvm = "$group:$infix-test-jvm" - - override val modules = listOf(core, coreJvm, jdk7, jdk8, debug, test, testJvm) -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt deleted file mode 100644 index bb267d8..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/DateTime.kt +++ /dev/null @@ -1,34 +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.dependency.kotlinx - -// https://github.com/Kotlin/kotlinx-datetime -@Suppress("ConstPropertyName", "unused") -object DateTime { - const val group = KotlinX.group - const val lib = "$group:kotlinx-datetime:0.7.1" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt deleted file mode 100644 index 097b916..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/KotlinX.kt +++ /dev/null @@ -1,32 +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.dependency.kotlinx - -@Suppress("ConstPropertyName", "unused") // https://bit.ly/kotlin-prop-names -object KotlinX { - const val group = "org.jetbrains.kotlinx" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt b/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt deleted file mode 100644 index 08e436d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/kotlinx/Serialization.kt +++ /dev/null @@ -1,73 +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.dependency.kotlinx - -/** - * The [KotlinX Serialization](https://github.com/Kotlin/kotlinx.serialization) library. - */ -@Suppress("ConstPropertyName") // https://bit.ly/kotlin-prop-names -object Serialization { - - const val group = KotlinX.group - - /** - * The version of the library. - * - * @see Releases - */ - const val version = "1.8.1" - - private const val infix = "kotlinx-serialization" - const val bom = "$group:$infix-bom:$version" - const val coreJvm = "$group:$infix-core-jvm" - const val json = "$group:$infix-json" - - /** - * The [Gradle plugin](https://github.com/Kotlin/kotlinx.serialization/tree/master?tab=readme-ov-file#gradle) - * for using the serialization library. - * - * Usage: - * ```kotlin - * plugins { - * // ... - * kotlin(Serialization.GradlePlugin.shortId) version Kotlin.version - * } - * ``` - */ - object GradlePlugin { - - /** - * The ID to be used with the `kotlin(shortId)` DSL under the`plugins { }` block. - */ - const val shortId = "plugin.serialization" - - /** - * The full ID of the plugin. - */ - const val id = "org.jetbrains.kotlin.$shortId" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Aedile.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Aedile.kt deleted file mode 100644 index 1a623f3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Aedile.kt +++ /dev/null @@ -1,38 +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.dependency.lib - -/** - * A Kotlin wrapper over [io.spine.dependency.lib.Caffeine]. - * - * @see Aedile at GitHub - */ -@Suppress("unused") -object Aedile { - private const val version = "2.1.2" - const val lib = "com.sksamuel.aedile:aedile-core:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/ApacheHttp.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/ApacheHttp.kt deleted file mode 100644 index f3eff5e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/ApacheHttp.kt +++ /dev/null @@ -1,34 +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.dependency.lib - -@Suppress("unused", "ConstPropertyName") -object ApacheHttp { - - // https://hc.apache.org/downloads.cgi - const val core = "org.apache.httpcomponents:httpcore:4.4.14" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/AppEngine.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/AppEngine.kt deleted file mode 100644 index b4e7336..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/AppEngine.kt +++ /dev/null @@ -1,39 +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.dependency.lib - -// https://cloud.google.com/java/docs/reference -@Suppress("unused", "ConstPropertyName") -object AppEngine { - private const val version = "1.9.82" - const val sdk = "com.google.appengine:appengine-api-1.0-sdk:$version" - - object GradlePlugin { - private const val version = "2.2.0" - const val lib = "com.google.cloud.tools:appengine-gradle-plugin:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Asm.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Asm.kt deleted file mode 100644 index 0a388c9..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Asm.kt +++ /dev/null @@ -1,43 +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.dependency.lib - -// https://asm.ow2.io/ -@Suppress("unused", "ConstPropertyName") -object Asm { - private const val version = "9.6" - const val group = "org.ow2.asm" - const val lib = "$group:asm:$version" - - // We use the following artifacts only to force the versions - // of the dependencies which are transitive for us. - // - const val tree = "$group:asm-tree:$version" - const val analysis = "$group:asm-analysis:$version" - const val util = "$group:asm-util:$version" - const val commons = "$group:asm-commons:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Auto.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Auto.kt deleted file mode 100644 index 6c222b9..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Auto.kt +++ /dev/null @@ -1,55 +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. - */ - -@file:Suppress("unused", "ConstPropertyName") - -package io.spine.dependency.lib - -// https://github.com/google/auto -object AutoCommon { - private const val version = "1.2.2" - const val lib = "com.google.auto:auto-common:$version" -} - -// https://github.com/google/auto -object AutoService { - private const val version = "1.1.1" - const val annotations = "com.google.auto.service:auto-service-annotations:$version" - @Suppress("unused") - const val processor = "com.google.auto.service:auto-service:$version" -} - -// https://github.com/google/auto -object AutoValue { - private const val version = "1.10.2" - const val annotations = "com.google.auto.value:auto-value-annotations:$version" -} - -// https://github.com/ZacSweers/auto-service-ksp -object AutoServiceKsp { - private const val version = "1.2.0" - const val processor = "dev.zacsweers.autoservice:auto-service-ksp:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/BouncyCastle.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/BouncyCastle.kt deleted file mode 100644 index 5289d0c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/BouncyCastle.kt +++ /dev/null @@ -1,33 +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.dependency.lib - -// https://www.bouncycastle.org/java.html -@Suppress("unused", "ConstPropertyName") -object BouncyCastle { - const val libPkcsJdk15 = "org.bouncycastle:bcpkix-jdk15on:1.68" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt deleted file mode 100644 index 23f44a4..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Caffeine.kt +++ /dev/null @@ -1,43 +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.dependency.lib - -/** - * A [high performance](https://github.com/ben-manes/caffeine/wiki/Benchmarks), - * [near optimal](https://github.com/ben-manes/caffeine/wiki/Efficiency) caching library. - * - * This library is a transitive dependency for us via - * [io.spine.dependency.lib.Aedile] and - * [io.spine.dependency.build.ErrorProne]. - * - * @see Caffeine at GitHub - */ -@Suppress("unused") -object Caffeine { - private const val version = "3.2.0" - const val lib = "com.github.ben-manes.caffeine:caffeine:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Clikt.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Clikt.kt deleted file mode 100644 index 3da42ce..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Clikt.kt +++ /dev/null @@ -1,34 +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.dependency.lib - -// https://ajalt.github.io/clikt/ -@Suppress("unused") -object Clikt { - private const val version = "3.5.2" - const val lib = "com.github.ajalt.clikt:clikt:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCli.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCli.kt deleted file mode 100644 index 6063278..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCli.kt +++ /dev/null @@ -1,39 +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.dependency.lib - -/** - * Commons CLI is a transitive dependency which we don't use directly. - * We `force` it in [forceVersions]. - * - * [Commons CLI](https://commons.apache.org/proper/commons-cli/) - */ -@Suppress("unused", "ConstPropertyName") -object CommonsCli { - private const val version = "1.5.0" - const val lib = "commons-cli:commons-cli:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCodec.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCodec.kt deleted file mode 100644 index 270b704..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsCodec.kt +++ /dev/null @@ -1,34 +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.dependency.lib - -// https://commons.apache.org/proper/commons-codec/changes-report.html -@Suppress("unused", "ConstPropertyName") -object CommonsCodec { - private const val version = "1.16.0" - const val lib = "commons-codec:commons-codec:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsLogging.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsLogging.kt deleted file mode 100644 index 9f1139c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/CommonsLogging.kt +++ /dev/null @@ -1,38 +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.dependency.lib - -/** - * [Commons Logging](https://commons.apache.org/proper/commons-logging/) is a transitive - * dependency, which we don't use directly. This object is used for forcing the version. - */ -@Suppress("unused", "ConstPropertyName") -object CommonsLogging { - // https://commons.apache.org/proper/commons-logging/ - private const val version = "1.2" - const val lib = "commons-logging:commons-logging:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt deleted file mode 100644 index 2073d76..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Coroutines.kt +++ /dev/null @@ -1,52 +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.dependency.lib - -/** - * Kotlin Coroutines. - * - * @see GitHub projecet - */ -@Suppress("unused", "ConstPropertyName") -@Deprecated( - message = "Please use `Coroutines` from the `io.spine.dependency.kotlinx` package", - replaceWith = ReplaceWith( - expression = "Coroutines", - imports = ["io.spine.dependency.kotlinx.Coroutines"] - ) -) -object Coroutines { - const val group = "org.jetbrains.kotlinx" - val version = io.spine.dependency.kotlinx.Coroutines.version - val bom = "$group:kotlinx-coroutines-bom:$version" - val core = "$group:kotlinx-coroutines-core:$version" - val coreJvm = "$group:kotlinx-coroutines-core-jvm:$version" - val jdk8 = "$group:kotlinx-coroutines-jdk8:$version" - val debug = "$group:kotlinx-coroutines-debug:$version" - val test = "$group:kotlinx-coroutines-test:$version" - val testJvm = "$group:kotlinx-coroutines-test-jvm:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Firebase.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Firebase.kt deleted file mode 100644 index 1d798ee..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Firebase.kt +++ /dev/null @@ -1,34 +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.dependency.lib - -// https://firebase.google.com/docs/admin/setup#java -@Suppress("unused", "ConstPropertyName") -object Firebase { - private const val adminVersion = "8.1.0" - const val admin = "com.google.firebase:firebase-admin:$adminVersion" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Flogger.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Flogger.kt deleted file mode 100644 index 769c905..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Flogger.kt +++ /dev/null @@ -1,42 +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.dependency.lib - -// https://github.com/google/flogger -@Deprecated("Please use Spine Logging library instead.") -@Suppress("unused", "ConstPropertyName") -object Flogger { - internal const val version = "0.7.4" - const val lib = "com.google.flogger:flogger:$version" - - object Runtime { - const val systemBackend = "com.google.flogger:flogger-system-backend:$version" - const val log4j2Backend = "com.google.flogger:flogger-log4j2-backend:$version" - const val slf4JBackend = "com.google.flogger:flogger-slf4j-backend:$version" - const val grpcContext = "com.google.flogger:flogger-grpc-context:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleApis.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleApis.kt deleted file mode 100644 index 7fd3340..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleApis.kt +++ /dev/null @@ -1,59 +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.dependency.lib - -/** - * Provides dependencies on [GoogleApis projects](https://github.com/googleapis/). - */ -@Suppress("unused", "ConstPropertyName") -object GoogleApis { - - // https://github.com/googleapis/google-api-java-client - const val client = "com.google.api-client:google-api-client:1.32.2" - - // https://github.com/googleapis/api-common-java - const val common = "com.google.api:api-common:2.1.1" - - // https://github.com/googleapis/java-common-protos - const val commonProtos = "com.google.api.grpc:proto-google-common-protos:2.7.0" - - // https://github.com/googleapis/gax-java - const val gax = "com.google.api:gax:2.7.1" - - // https://github.com/googleapis/java-iam - const val protoAim = "com.google.api.grpc:proto-google-iam-v1:1.2.0" - - // https://github.com/googleapis/google-oauth-java-client - const val oAuthClient = "com.google.oauth-client:google-oauth-client:1.32.1" - - // https://github.com/googleapis/google-auth-library-java - object AuthLibrary { - const val version = "1.3.0" - const val credentials = "com.google.auth:google-auth-library-credentials:$version" - const val oAuth2Http = "com.google.auth:google-auth-library-oauth2-http:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleCloud.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleCloud.kt deleted file mode 100644 index b755168..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GoogleCloud.kt +++ /dev/null @@ -1,43 +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.dependency.lib - -@Suppress("unused", "ConstPropertyName") -object GoogleCloud { - - // https://github.com/googleapis/java-core - const val core = "com.google.cloud:google-cloud-core:2.3.3" - - // https://github.com/googleapis/java-pubsub/tree/main/proto-google-cloud-pubsub-v1 - const val pubSubGrpcApi = "com.google.api.grpc:proto-google-cloud-pubsub-v1:1.97.0" - - // https://github.com/googleapis/java-trace - const val trace = "com.google.cloud:google-cloud-trace:2.1.0" - - // https://github.com/googleapis/java-datastore - const val datastore = "com.google.cloud:google-cloud-datastore:2.2.1" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt deleted file mode 100644 index 48e70f4..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Grpc.kt +++ /dev/null @@ -1,82 +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.dependency.lib - -import io.spine.dependency.DependencyWithBom - -// https://github.com/grpc/grpc-java -@Suppress("unused") -object Grpc : DependencyWithBom() { - - override val version = "1.72.0" - override val group = "io.grpc" - override val bom = "$group:grpc-bom:$version" - - val api = "$group:grpc-api" - val auth = "$group:grpc-auth" - val core = "$group:grpc-core" - val context = "$group:grpc-context" - val inProcess = "$group:grpc-inprocess" - val stub = "$group:grpc-stub" - val okHttp = "$group:grpc-okhttp" - val protobuf = "$group:grpc-protobuf" - val protobufLite = "$group:grpc-protobuf-lite" - val netty = "$group:grpc-netty" - val nettyShaded = "$group:grpc-netty-shaded" - - override val modules = listOf( - api, - auth, - core, - context, - inProcess, - stub, - okHttp, - protobuf, - protobufLite, - netty, - nettyShaded - ) - - object ProtocPlugin { - const val id = "grpc" - @Deprecated( - message = "Please use `GrpcKotlin.ProtocPlugin.artifact` instead.", - replaceWith = ReplaceWith("GrpcKotlin.ProtocPlugin.artifact") - ) - const val kotlinPluginVersion = GrpcKotlin.version - val artifact = "$group:protoc-gen-grpc-java:$version" - - // https://github.com/grpc/grpc-kotlin - // https://repo.maven.apache.org/maven2/io/grpc/protoc-gen-grpc-kotlin/ - @Deprecated( - message = "Please use `GrpcKotlin.ProtocPlugin.artifact` instead.", - replaceWith = ReplaceWith("GrpcKotlin.ProtocPlugin.artifact") - ) - const val artifactKotlin = GrpcKotlin.ProtocPlugin.artifact - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt deleted file mode 100644 index 05d21dd..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/GrpcKotlin.kt +++ /dev/null @@ -1,44 +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.dependency.lib - -/** - * gRPC-Kotlin/JVM. - * - * @see GitHub project - */ -@Suppress("unused") -object GrpcKotlin { - const val version = "1.4.1" - const val stub = "io.grpc:grpc-kotlin-stub:$version" - - object ProtocPlugin { - const val id = "grpckt" - // https://central.sonatype.com/artifact/io.grpc/protoc-gen-grpc-kotlin - const val artifact = "io.grpc:protoc-gen-grpc-kotlin:$version:jdk8@jar" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt deleted file mode 100644 index da9ae93..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Gson.kt +++ /dev/null @@ -1,39 +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.dependency.lib - -/** - * Gson is a transitive dependency, which we don't use directly. - * We `force` it in [DependencyResolution.forceConfiguration()]. - * - * [Gson](https://github.com/google/gson) - */ -@Suppress("unused", "ConstPropertyName") -object Gson { - private const val version = "2.13.0" - const val lib = "com.google.code.gson:gson:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt deleted file mode 100644 index 9115701..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Guava.kt +++ /dev/null @@ -1,44 +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.dependency.lib - -/** - * The dependencies for Guava. - * - * When changing the version, also change the version used in the `build.gradle.kts`. We need - * to synchronize the version used in `buildSrc` and in Spine modules. Otherwise, when testing - * Gradle plugins, errors may occur due to version clashes. - * - * @see Guava at GitHub. - */ -@Suppress("unused", "ConstPropertyName") -object Guava { - private const val version = "33.4.8-jre" - const val group = "com.google.guava" - const val lib = "$group:guava:$version" - const val testLib = "$group:guava-testlib:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/HttpClient.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/HttpClient.kt deleted file mode 100644 index 526f05f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/HttpClient.kt +++ /dev/null @@ -1,42 +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.dependency.lib - -/** - * Google implementations of [HTTP client](https://github.com/googleapis/google-http-java-client). - */ -@Suppress("unused", "ConstPropertyName") -object HttpClient { - // https://github.com/googleapis/google-http-java-client - const val version = "1.43.3" - const val google = "com.google.http-client:google-http-client:$version" - const val jackson2 = "com.google.http-client:google-http-client-jackson2:$version" - const val gson = "com.google.http-client:google-http-client-gson:$version" - const val apache2 = "com.google.http-client:google-http-client-apache-v2:$version" - - const val apache = "com.google.http-client:google-http-client-apache:2.1.2" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/IntelliJ.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/IntelliJ.kt deleted file mode 100644 index 7f9232b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/IntelliJ.kt +++ /dev/null @@ -1,89 +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. - */ - -@file:Suppress("ConstPropertyName") - -package io.spine.dependency.lib - -/** - * The components of the IntelliJ Platform. - * - * Make sure to add the `intellijReleases` and `jetBrainsCacheRedirector` - * repositories to your project. See `kotlin/Repositories.kt` for details. - */ -@Suppress("unused") -object IntelliJ { - - /** - * The version of the IntelliJ platform. - * - * This is the version used by Kotlin compiler `1.9.21`. - * Advance this version with caution because it may break the setup of - * IntelliJ platform standalone execution. - */ - const val version = "213.7172.53" - - object Platform { - private const val group = "com.jetbrains.intellij.platform" - const val core = "$group:core:$version" - const val util = "$group:util:$version" - const val coreImpl = "$group:core-impl:$version" - const val codeStyle = "$group:code-style:$version" - const val codeStyleImpl = "$group:code-style-impl:$version" - const val projectModel = "$group:project-model:$version" - const val projectModelImpl = "$group:project-model-impl:$version" - const val lang = "$group:lang:$version" - const val langImpl = "$group:lang-impl:$version" - const val ideImpl = "$group:ide-impl:$version" - const val ideCoreImpl = "$group:ide-core-impl:$version" - const val analysisImpl = "$group:analysis-impl:$version" - const val indexingImpl = "$group:indexing-impl:$version" - } - - object Jsp { - private const val group = "com.jetbrains.intellij.jsp" - @Suppress("MemberNameEqualsClassName") - const val jsp = "$group:jsp:$version" - } - - object Xml { - private const val group = "com.jetbrains.intellij.xml" - const val xmlPsiImpl = "$group:xml-psi-impl:$version" - } - - object JavaPsi { - private const val group = "com.jetbrains.intellij.java" - const val api = "$group:java-psi:$version" - const val impl = "$group:java-psi-impl:$version" - } - - object Java { - private const val group = "com.jetbrains.intellij.java" - @Suppress("MemberNameEqualsClassName") - const val java = "$group:java:$version" - const val impl = "$group:java-impl:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/J2ObjC.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/J2ObjC.kt deleted file mode 100644 index 3098466..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/J2ObjC.kt +++ /dev/null @@ -1,51 +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.dependency.lib - -/** - * [J2ObjC](https://developers.google.com/j2objc) is a transitive dependency, - * which we don't use directly. This object is used for forcing the version. - */ -@Suppress("unused", "ConstPropertyName") -object J2ObjC { - /** - * See [J2ObjC releases](https://github.com/google/j2objc/releases). - * - * `1.3` was the latest version available from Maven Central. - * Now `2.8` is the latest version available. - * As [HttpClient] - * [migrated](https://github.com/googleapis/google-http-java-client/releases/tag/v1.43.3) to v2, - * we set the latest v2 version as well. - * - * @see - * J2ObjC on Maven Central - */ - private const val version = "2.8" - const val annotations = "com.google.j2objc:j2objc-annotations:$version" - @Deprecated("Please use `annotations` instead.", ReplaceWith("annotations")) - const val lib = annotations -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt deleted file mode 100644 index b47b0c5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Jackson.kt +++ /dev/null @@ -1,127 +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.dependency.lib - -import io.spine.dependency.Dependency -import io.spine.dependency.DependencyWithBom - -// https://github.com/FasterXML/jackson/wiki/Jackson-Releases -@Suppress("unused") -object Jackson : DependencyWithBom() { - override val group = "com.fasterxml.jackson" - override val version = "2.18.3" - - // https://github.com/FasterXML/jackson-bom - override val bom = "$group:jackson-bom:$version" - - private val groupPrefix = group - private val coreGroup = "$groupPrefix.core" - private val moduleGroup = "$groupPrefix.module" - - // Constants coming below without `$version` are covered by the BOM. - - // https://github.com/FasterXML/jackson-core - val core = "$coreGroup:jackson-core" - - // https://github.com/FasterXML/jackson-databind - val databind = "$coreGroup:jackson-databind" - - // https://github.com/FasterXML/jackson-annotations - val annotations = "$coreGroup:jackson-annotations" - - // https://github.com/FasterXML/jackson-module-kotlin/releases - val moduleKotlin = "$moduleGroup:jackson-module-kotlin" - - override val modules = listOf( - core, - databind, - annotations, - moduleKotlin - ) - - object DataFormat : Dependency() { - override val version = Jackson.version - override val group = "$groupPrefix.dataformat" - - private const val infix = "jackson-dataformat" - - // https://github.com/FasterXML/jackson-dataformat-xml/releases - val xml = "$group:$infix-xml" - - // https://github.com/FasterXML/jackson-dataformats-text/releases - val yaml = "$group:$infix-yaml" - - val xmlArtifact = "$xml:$version" - val yamlArtifact = "$yaml:$version" - - override val modules = listOf(xml, yaml) - } - - object DataType : Dependency() { - override val version = Jackson.version - override val group = "$groupPrefix.datatype" - - private const val infix = "jackson-datatype" - - // https://github.com/FasterXML/jackson-modules-java8 - val jdk8 = "$group:$infix-jdk8" - - // https://github.com/FasterXML/jackson-modules-java8/tree/2.19/datetime - val dateTime = "$group:$infix-jsr310" - - // https://github.com/FasterXML/jackson-datatypes-collections/blob/2.19/guava - val guava = "$group:$infix-guava" - - // https://github.com/FasterXML/jackson-dataformats-binary/tree/2.19/protobuf - val protobuf = "$group:$infix-protobuf" - - // https://github.com/FasterXML/jackson-datatypes-misc/tree/2.19/javax-money - val javaXMoney = "$group:$infix-javax-money" - - // https://github.com/FasterXML/jackson-datatypes-misc/tree/2.19/moneta - val moneta = "$group:jackson-datatype-moneta" - - override val modules = listOf( - jdk8, - dateTime, - guava, - protobuf, - javaXMoney, - moneta - ) - } - - // https://github.com/FasterXML/jackson-jr - object Junior : Dependency() { - override val version = Jackson.version - override val group = "com.fasterxml.jackson.jr" - - val objects = "$group:jackson-jr-objects" - - override val modules = listOf(objects) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaDiffUtils.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaDiffUtils.kt deleted file mode 100644 index 7cc2e59..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaDiffUtils.kt +++ /dev/null @@ -1,42 +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.dependency.lib - -/** - * The dependency on the `java-diff-utils` library, which is transitive for us at the time - * of writing. - * - * It might become our dependency as a part of - * the [Spine Text](https://github.com/SpineEventEngine/text) library. - */ -@Suppress("unused", "ConstPropertyName") -object JavaDiffUtils { - - // https://github.com/java-diff-utils/java-diff-utils/releases - private const val version = "4.12" - const val lib = "io.github.java-diff-utils:java-diff-utils:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaJwt.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaJwt.kt deleted file mode 100644 index 4d9b1df..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaJwt.kt +++ /dev/null @@ -1,46 +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.dependency.lib - -/** - * A Java implementation of JSON Web Token (JWT) - RFC 7519. - * - * [Java JWT](https://github.com/auth0/java-jwt) - */ -@Suppress("unused", "ConstPropertyName") -object JavaJwt { - - /** - * The last version in the v3.x.x series. - * - * There's a v4.x.x series (e.g., https://github.com/auth0/java-jwt/releases/tag/4.4.0), but - * it introduces breaking changes. Consider upgrading to it when we're ready to migrate. - */ - private const val version = "3.19.4" - - const val lib = "com.auth0:java-jwt:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaPoet.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaPoet.kt deleted file mode 100644 index b99e503..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaPoet.kt +++ /dev/null @@ -1,37 +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.dependency.lib - -// https://github.com/square/javapoet -@Suppress("unused", "ConstPropertyName") -object JavaPoet { - private const val version = "1.13.0" - const val group = "com.squareup" - const val artifact = "javapoet" - const val module = "$group:$artifact" - const val lib = "$module:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt deleted file mode 100644 index e605a16..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/JavaX.kt +++ /dev/null @@ -1,37 +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.dependency.lib - -@Suppress("unused", "ConstPropertyName") -object JavaX { - // This artifact, which used to be a part of J2EE, moved under the Eclipse EE4J project. - // https://github.com/jakartaee/common-annotations-api - const val annotationGroup = "javax.annotation" - const val annotations = "$annotationGroup:javax.annotation-api:1.3.2" - - const val servletApi = "javax.servlet:javax.servlet-api:3.1.0" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Klaxon.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Klaxon.kt deleted file mode 100644 index 69089c6..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Klaxon.kt +++ /dev/null @@ -1,38 +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.dependency.lib - -/** - * A JSON parser in Kotlin. - * - * [Klaxon](https://github.com/cbeust/klaxon) - */ -@Suppress("unused", "ConstPropertyName") -object Klaxon { - private const val version = "5.6" - const val lib = "com.beust:klaxon:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt deleted file mode 100644 index 48694c5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Kotlin.kt +++ /dev/null @@ -1,120 +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.dependency.lib - -import io.spine.dependency.Dependency -import io.spine.dependency.DependencyWithBom - -// https://github.com/JetBrains/kotlin -// https://github.com/Kotlin -@Suppress("unused") -object Kotlin : DependencyWithBom() { - - /** - * This is the version of Kotlin we use for writing code which does not - * depend on Gradle and the version of embedded Kotlin. - */ - @Suppress("MemberVisibilityCanBePrivate") // used directly from the outside. - const val runtimeVersion = "2.1.21" - - override val version = runtimeVersion - override val group = "org.jetbrains.kotlin" - override val bom = "$group:kotlin-bom:$runtimeVersion" - - /** - * This is the version of - * [Kotlin embedded into Gradle](https://docs.gradle.org/current/userguide/compatibility.html#kotlin). - */ - const val embeddedVersion = "2.1.21" - - /** - * The version of the JetBrains annotations library, which is a transitive - * dependency for us via Kotlin libraries. - * - * @see Java Annotations - */ - private const val annotationsVersion = "26.0.2" - - val scriptRuntime = "$group:kotlin-script-runtime:$runtimeVersion" - - object StdLib : Dependency() { - override val version = runtimeVersion - override val group = Kotlin.group - - private const val infix = "kotlin-stdlib" - val itself = "$group:$infix" - val common = "$group:$infix-common" - val jdk7 = "$group:$infix-jdk7" - val jdk8 = "$group:$infix-jdk8" - - override val modules = listOf(itself, common, jdk7, jdk8) - } - - @Deprecated("Please use `StdLib.itself` instead.", ReplaceWith("StdLib.itself")) - val stdLib = StdLib.itself - - @Deprecated("Please use `StdLib.common` instead.", ReplaceWith("StdLib.common")) - val stdLibCommon = StdLib.common - - @Deprecated("Please use `StdLib.jdk7` instead.", ReplaceWith("StdLib.jdk7")) - val stdLibJdk7 = StdLib.jdk7 - - @Deprecated("Please use `StdLib.jdk8` instead.") - val stdLibJdk8 = StdLib.jdk8 - - val toolingCore = "$group:kotlin-tooling-core" - val reflect = "$group:kotlin-reflect" - val testJUnit5 = "$group:kotlin-test-junit5" - - /** - * The modules our interest that do not belong to [StdLib]. - */ - override val modules = listOf(reflect, testJUnit5) - - @Deprecated(message = "Please use `GradlePlugin.api` instead.", ReplaceWith("GradlePlugin.api")) - val gradlePluginApi = "$group:kotlin-gradle-plugin-api" - - @Deprecated(message = "Please use `GradlePlugin.lib` instead.", ReplaceWith("GradlePlugin.lib")) - val gradlePluginLib = "$group:kotlin-gradle-plugin" - - const val jetbrainsAnnotations = "org.jetbrains:annotations:$annotationsVersion" - - object Compiler { - val embeddable = "$group:kotlin-compiler-embeddable:$embeddedVersion" - } - - object GradlePlugin : Dependency() { - override val version = runtimeVersion - override val group = Kotlin.group - - val api = "$group:kotlin-gradle-plugin-api:$version" - val lib = "$group:kotlin-gradle-plugin:$version" - val model = "$group:kotlin-gradle-model:$version" - - override val modules = listOf(api, lib, model) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt deleted file mode 100644 index d7ece62..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinPoet.kt +++ /dev/null @@ -1,35 +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.dependency.lib - -// https://github.com/square/kotlinpoet -@Suppress("unused", "ConstPropertyName") -object KotlinPoet { - private const val version = "2.2.0" - const val lib = "com.squareup:kotlinpoet:$version" - const val ksp = "com.squareup:kotlinpoet-ksp:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt deleted file mode 100644 index 92a348d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinSemver.kt +++ /dev/null @@ -1,34 +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.dependency.lib - -// https://github.com/z4kn4fein/kotlin-semver -@Suppress("unused", "ConstPropertyName") -object KotlinSemver { - private const val version = "2.0.0" - const val lib = "io.github.z4kn4fein:semver:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt deleted file mode 100644 index ee521e3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/KotlinX.kt +++ /dev/null @@ -1,60 +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.dependency.lib - -@Suppress("unused", "ConstPropertyName") -@Deprecated( - message = "Please use `KotlinX` from `io.spine.dependency.kotlinx` package", - replaceWith = ReplaceWith( - expression = "KotlinX", - imports = ["io.spine.dependency.kotlinx.KotlinX"] - ) -) -object KotlinX { - - const val group = "org.jetbrains.kotlinx" - - @Deprecated( - message = "Please use `Coroutines` from the `io.spine.dependency.kotlinx` package", - replaceWith = ReplaceWith( - expression = "Coroutines", - imports = ["io.spine.dependency.kotlinx.Coroutines"] - ) - ) - object Coroutines { - - // https://github.com/Kotlin/kotlinx.coroutines - val version = io.spine.dependency.kotlinx.Coroutines.version - val bom = "$group:kotlinx-coroutines-bom:$version" - val core = "$group:kotlinx-coroutines-core:$version" - val coreJvm = "$group:kotlinx-coroutines-core-jvm:$version" - val jdk8 = "$group:kotlinx-coroutines-jdk8:$version" - val debug = "$group:kotlinx-coroutines-debug:$version" - val test = "$group:kotlinx-coroutines-test:$version" - val testJvm = "$group:kotlinx-coroutines-test-jvm:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Log4j2.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Log4j2.kt deleted file mode 100644 index d4f2bd2..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Log4j2.kt +++ /dev/null @@ -1,42 +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.dependency.lib - -/** - * An open-source logging framework. - * - * Spine uses its own [logging library][io.spine.dependency.local.Logging], but also - * provides a backend implementation for [Log4j2]. This is why - * this dependency is needed. - * - * @see Log4j2 releases at GitHub - */ -@Suppress("unused", "ConstPropertyName") -object Log4j2 { - private const val version = "2.20.0" - const val core = "org.apache.logging.log4j:log4j-core:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Netty.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Netty.kt deleted file mode 100644 index c317bb3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Netty.kt +++ /dev/null @@ -1,38 +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.dependency.lib - -@Suppress("unused", "ConstPropertyName") -object Netty { - // https://github.com/netty/netty/tags - private const val version = "4.1.100.Final" - const val common = "io.netty:netty-common:$version" - const val buffer = "io.netty:netty-buffer:$version" - const val transport = "io.netty:netty-transport:$version" - const val handler = "io.netty:netty-handler:$version" - const val codecHttp = "io.netty:netty-codec-http:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Okio.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Okio.kt deleted file mode 100644 index 3107d76..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Okio.kt +++ /dev/null @@ -1,38 +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.dependency.lib - -/** - * Okio is a transitive dependency, which we don't use directly. - * - * https://github.com/square/okio/tags - */ -@Suppress("unused", "ConstPropertyName") -object Okio { - private const val version = "3.6.0" - const val lib = "com.squareup.okio:okio:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Plexus.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Plexus.kt deleted file mode 100644 index e393906..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Plexus.kt +++ /dev/null @@ -1,48 +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. - */ - -@file:Suppress("MaxLineLength") - -package io.spine.dependency.lib - -/** - * Plexus Utils is a transitive dependency, which we don't use directly. - * - * [Plexus Utils](https://github.com/codehaus-plexus/plexus-utils) - */ -@Suppress("unused", "ConstPropertyName") -object Plexus { - - /** - * This is the last version in the 3.x series. - * - * There's a major update to 4.x. - * - * @see plexus-utils-4.0.0 - */ - private const val version = "4.0.0" - const val utils = "org.codehaus.plexus:plexus-utils:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt deleted file mode 100644 index 8eaf49a..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Protobuf.kt +++ /dev/null @@ -1,71 +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.dependency.lib - -// https://github.com/protocolbuffers/protobuf -@Suppress( - "MemberVisibilityCanBePrivate" /* used directly from the outside */, - "ConstPropertyName" /* https://bit.ly/kotlin-prop-names */ -) -object Protobuf { - const val group = "com.google.protobuf" - const val version = "4.31.1" - - /** - * The Java library with Protobuf data types. - */ - const val javaLib = "$group:protobuf-java:$version" - - /** - * The Java library containing proto definitions of Google Protobuf types. - */ - @Suppress("unused") - const val protoSrcLib = javaLib - - /** - * All Java and Kotlin libraries we depend on. - */ - val libs = listOf( - javaLib, - "$group:protobuf-java-util:$version", - "$group:protobuf-kotlin:$version" - ) - const val compiler = "$group:protoc:$version" - - // https://github.com/google/protobuf-gradle-plugin/releases - object GradlePlugin { - /** - * The version of this plugin is already specified in `buildSrc/build.gradle.kts` file. - * Thus, when applying the plugin to project build files, only the [id] should be used. - * - * When changing the version, also change the version used in the `build.gradle.kts`. - */ - const val version = "0.9.5" - const val id = "com.google.protobuf" - const val lib = "$group:protobuf-gradle-plugin:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt deleted file mode 100644 index 601be9a..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Roaster.kt +++ /dev/null @@ -1,45 +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.dependency.lib - -// https://github.com/forge/roaster -@Suppress("unused", "ConstPropertyName") -object Roaster { - - /** - * This is the last version build with Java 11. - * - * Starting from the version - * [2.29.0.Final](https://github.com/forge/roaster/releases/tag/2.29.0.Final), - * Roaster requires Java 17. - */ - private const val version = "2.29.0.Final" - - const val group = "org.jboss.forge.roaster" - const val api = "$group:roaster-api:$version" - const val jdt = "$group:roaster-jdt:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Slf4J.kt b/buildSrc/src/main/kotlin/io/spine/dependency/lib/Slf4J.kt deleted file mode 100644 index bd5b9df..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/lib/Slf4J.kt +++ /dev/null @@ -1,47 +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.dependency.lib - -/** - * Spine used to log with SLF4J. Now we use Flogger. Whenever a choice comes up, we recommend to - * use the latter. - * - * The primary purpose of having this dependency object is working in combination with - * [Flogger.Runtime.slf4JBackend]. - * - * Some third-party libraries may clash with different versions of the library. - * Thus, we specify this version and force it via [forceVersions]. - * Please see `DependencyResolution.kt` for details. - */ -@Suppress("unused", "ConstPropertyName") -object Slf4J { - private const val version = "2.0.7" - const val lib = "org.slf4j:slf4j-api:$version" - const val jdk14 = "org.slf4j:slf4j-jdk14:$version" - const val reload4j = "org.slf4j:slf4j-reload4j:$version" - const val simple = "org.slf4j:slf4j-simple:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt deleted file mode 100644 index 65ac468..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Base.kt +++ /dev/null @@ -1,44 +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.dependency.local - -/** - * Spine Base module. - * - * @see spine-base - */ -@Suppress("ConstPropertyName", "unused") -object Base { - const val version = "2.0.0-SNAPSHOT.360" - const val versionForBuildScript = "2.0.0-SNAPSHOT.360" - const val group = Spine.group - const val artifact = "spine-base" - const val lib = "$group:$artifact:$version" - const val format = "$group:spine-format:$version" - const val libForBuildScript = "$group:$artifact:$versionForBuildScript" - const val annotations = "$group:spine-annotations:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt deleted file mode 100644 index b0b534d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/BaseTypes.kt +++ /dev/null @@ -1,40 +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.dependency.local - -/** - * Spine Base module. - * - * @see spine-base-types - */ -@Suppress("ConstPropertyName") -object BaseTypes { - const val version = "2.0.0-SNAPSHOT.210" - const val group = Spine.group - const val artifact = "spine-base-types" - const val lib = "$group:$artifact:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt deleted file mode 100644 index 2436580..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Change.kt +++ /dev/null @@ -1,40 +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.dependency.local - -/** - * Spine Reflect library. - * - * @see spine-change - */ -@Suppress("ConstPropertyName") -object Change { - const val version = "2.0.0-SNAPSHOT.200" - const val group = Spine.group - const val artifact = "spine-change" - const val lib = "$group:$artifact:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt deleted file mode 100644 index b88f342..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt +++ /dev/null @@ -1,176 +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.dependency.local - -/** - * Dependencies on the Spine Compiler modules. - * - * To use a locally published ProtoData version instead of the version from a public plugin - * registry, set the `COMPILER_VERSION` and/or the `COMPILER_DF_VERSION` environment variables - * and stop the Gradle daemons so that Gradle observes the env change: - * ``` - * export COMPILER_VERSION=0.43.0-local - * export COMPILER_DF_VERSION=0.41.0 - * - * ./gradle --stop - * ./gradle build # Conduct the intended checks. - * ``` - * - * Then, to reset the console to run the usual versions again, remove the values of - * the environment variables and stop the daemon: - * ``` - * export COMPILER_VERSION="" - * export COMPILER_DF_VERSION="" - * - * ./gradle --stop - * ``` - * - * See [`SpineEventEngine/compiler`](https://github.com/SpineEventEngine/compiler/). - */ -@Suppress( - "unused" /* Some subprojects do not use the Compiler directly. */, - "ConstPropertyName" /* We use custom convention for artifact properties. */, - "MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */, -) -object Compiler { - const val pluginGroup = Spine.group - const val group = "io.spine.tools" - const val pluginId = "io.spine.compiler" - - /** - * Identifies the Compiler as a `classpath` dependency under `buildScript` block. - */ - const val module = "io.spine.tools:compiler" - - /** - * The version of ProtoData dependencies. - */ - val version: String - private const val fallbackVersion = "2.0.0-SNAPSHOT.016" - - /** - * The distinct version of ProtoData used by other build tools. - * - * When ProtoData is used both for building the project and as a part of the Project's - * transitional dependencies, this is the version used to build the project itself. - */ - val dogfoodingVersion: String - private const val fallbackDfVersion = "2.0.0-SNAPSHOT.016" - - /** - * The artifact for the ProtoData Gradle plugin. - */ - val pluginLib: String - - /** - * The artifact to be used during experiments when publishing locally. - * - * @see Compiler - */ - fun pluginLib(version: String): String = - "$group:compiler-gradle-plugin:$version" - - fun api(version: String): String = - "$group:compiler-api:$version" - - val api - get() = api(version) - - val backend - get() = "$group:compiler-backend:$version" - - val params - get() = "$group:compiler-params:$version" - - val protocPlugin - get() = "$group:compiler-protoc-plugin:$version" - - val gradleApi - get() = "$group:compiler-gradle-api:$version" - - val cliApi - get() = "$group:compiler-cli-api:$version" - - val jvmModule = "$group:compiler-jvm" - - fun jvm(version: String): String = - "$jvmModule:$version" - - val jvm - get() = jvm(version) - - val fatCli - get() = "$group:compiler-fat-cli:$version" - - val testlib - get() = "$group:compiler-testlib:$version" - - /** - * An env variable storing a custom [version]. - */ - private const val VERSION_ENV = "COMPILER_VERSION" - - /** - * An env variable storing a custom [dogfoodingVersion]. - */ - private const val DF_VERSION_ENV = "COMPILER_DF_VERSION" - - /** - * Sets up the versions and artifacts for the build to use. - * - * If either [VERSION_ENV] or [DF_VERSION_ENV] is set, those versions are used instead of - * the hardcoded ones. Also, in this mode, the [pluginLib] coordinates are changed so that - * it points at a locally published artifact. Otherwise, it points at an artifact that would be - * published to a public plugin registry. - */ - init { - val experimentVersion = System.getenv(VERSION_ENV) - val experimentDfVersion = System.getenv(DF_VERSION_ENV) - if (experimentVersion?.isNotBlank() == true || experimentDfVersion?.isNotBlank() == true) { - version = experimentVersion ?: fallbackVersion - dogfoodingVersion = experimentDfVersion ?: fallbackDfVersion - - pluginLib = pluginLib(version) - println(""" - - ❗ Running an experiment with the Spine Compiler. ❗ - ----------------------------------------- - Regular version = v$version - Dogfooding version = v$dogfoodingVersion - - The Compiler Gradle plugin can now be loaded from Maven Local. - - To reset the versions, erase the `$$VERSION_ENV` and `$$DF_VERSION_ENV` environment variables. - - """.trimIndent()) - } else { - version = fallbackVersion - dogfoodingVersion = fallbackDfVersion - pluginLib = pluginLib(version) - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt deleted file mode 100644 index 10d9a62..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvm.kt +++ /dev/null @@ -1,51 +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.dependency.local - -// For backward compatibility. -typealias CoreJava = CoreJvm - -/** - * Dependencies on `core-java` modules. - * - * See [`SpineEventEngine/core-java`](https://github.com/SpineEventEngine/core-java/). - */ -@Suppress("ConstPropertyName", "unused") -object CoreJvm { - const val group = Spine.group - const val version = "2.0.0-SNAPSHOT.330" - - const val coreArtifact = "spine-core" - const val clientArtifact = "spine-client" - const val serverArtifact = "spine-server" - - const val core = "$group:$coreArtifact:$version" - const val client = "$group:$clientArtifact:$version" - const val server = "$group:$serverArtifact:$version" - - const val testUtilServer = "${ToolBase.group}:spine-testutil-server:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt deleted file mode 100644 index 2b9c067..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt +++ /dev/null @@ -1,83 +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.dependency.local - -/** - * Dependencies on the CoreJvm Compiler artifacts. - * - * See [mc-java](https://github.com/SpineEventEngine/core-jvm-compiler). - */ -@Suppress( - "MemberVisibilityCanBePrivate" /* `pluginLib()` is used by subprojects. */, - "ConstPropertyName", - "unused" -) -object CoreJvmCompiler { - - /** - * The Compiler belongs to the `tools` group. - */ - const val group = ToolBase.group - - /** - * The version used to in the build classpath. - */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.007" - - /** - * The version to be used for integration tests. - */ - const val version = "2.0.0-SNAPSHOT.007" - - /** - * The ID of the Gradle plugin. - */ - const val pluginId = "io.spine.core-jvm" - - /** - * The library with the [dogfoodingVersion]. - */ - val pluginLib = pluginLib(dogfoodingVersion) - - /** - * The library with the given [version]. - */ - fun pluginLib(version: String): String = "$group:core-jvm-plugins:$version:all" - - /** The artifact reference for forcing in configurations. */ - const val pluginsArtifact: String = "$group:core-jvm-plugins:$version" - - /** - * The `core-jvm-base` artifact with the [version]. - */ - val base = base(version) - - /** - * The `mc-java-base` artifact with the given [version]. - */ - fun base(version: String): String = "$group:core-jvm-base:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt deleted file mode 100644 index 3bb1140..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Logging.kt +++ /dev/null @@ -1,57 +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.dependency.local - -/** - * Dependencies on the artifacts of the Spine Logging library. - * - * @see spine-logging - */ -@Suppress("ConstPropertyName", "unused") -object Logging { - const val version = "2.0.0-SNAPSHOT.411" - const val group = Spine.group - - const val loggingArtifact = "spine-logging" - - const val lib = "$group:$loggingArtifact:$version" - const val libJvm = "$group:spine-logging-jvm:$version" - - const val log4j2Backend = "$group:spine-logging-log4j2-backend:$version" - const val stdContext = "$group:spine-logging-std-context:$version" - const val grpcContext = "$group:spine-logging-grpc-context:$version" - const val smokeTest = "$group:spine-logging-smoke-test:$version" - - const val testLib = "${Spine.toolsGroup}:spine-logging-testlib:$version" - - // Transitive dependencies. - // Make `public` and use them to force a version in a particular repository, if needed. - internal const val julBackend = "$group:spine-logging-jul-backend:$version" - const val middleware = "$group:spine-logging-middleware:$version" - internal const val platformGenerator = "$group:spine-logging-platform-generator:$version" - internal const val jvmDefaultPlatform = "$group:spine-logging-jvm-default-platform:$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 deleted file mode 100644 index 7a7336b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/McJava.kt +++ /dev/null @@ -1,79 +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.dependency.local - -/** - * Dependencies on Spine Model Compiler for Java. - * - * See [mc-java](https://github.com/SpineEventEngine/mc-java). - */ -@Suppress( - "MemberVisibilityCanBePrivate" /* `pluginLib()` is used by subprojects. */, - "ConstPropertyName", - "unused" -) -object McJava { - const val group = ToolBase.group - - /** - * The version used to in the build classpath. - */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.320" - - /** - * The version to be used for integration tests. - */ - const val version = "2.0.0-SNAPSHOT.320" - - /** - * The ID of the Gradle plugin. - */ - const val pluginId = "io.spine.mc-java" - - /** - * The library with the [dogfoodingVersion]. - */ - val pluginLib = pluginLib(dogfoodingVersion) - - /** - * The library with the given [version]. - */ - fun pluginLib(version: String): String = "$group:spine-mc-java-plugins:$version:all" - - /** The artifact reference for forcing in configurations. */ - const val pluginsArtifact: String = "$group:spine-mc-java-plugins:$version" - - /** - * The `mc-java-base` artifact with the [version]. - */ - val base = base(version) - - /** - * The `mc-java-base` artifact with the given [version]. - */ - fun base(version: String): String = "$group:spine-mc-java-base:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ModelCompiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ModelCompiler.kt deleted file mode 100644 index 5f9e541..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ModelCompiler.kt +++ /dev/null @@ -1,40 +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.dependency.local - -/** - * Spine Model Compiler Gradle API. - * - * @see spine-model-compiler - */ -@Suppress("ConstPropertyName") -object ModelCompiler { - const val version = "2.0.0-SNAPSHOT.133" - const val group = Spine.toolsGroup - const val artifact = "spine-model-compiler" - const val lib = "$group:$artifact:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt deleted file mode 100644 index c4f06c8..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoData.kt +++ /dev/null @@ -1,178 +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.dependency.local - -/** - * Dependencies on ProtoData modules. - * - * To use a locally published ProtoData version instead of the version from a public plugin - * registry, set the `PROTODATA_VERSION` and/or the `PROTODATA_DF_VERSION` environment variables - * and stop the Gradle daemons so that Gradle observes the env change: - * ``` - * export PROTODATA_VERSION=0.43.0-local - * export PROTODATA_DF_VERSION=0.41.0 - * - * ./gradle --stop - * ./gradle build # Conduct the intended checks. - * ``` - * - * Then, to reset the console to run the usual versions again, remove the values of - * the environment variables and stop the daemon: - * ``` - * export PROTODATA_VERSION="" - * export PROTODATA_DF_VERSION="" - * - * ./gradle --stop - * ``` - * - * See [`SpineEventEngine/ProtoData`](https://github.com/SpineEventEngine/ProtoData/). - */ -@Suppress( - "unused" /* Some subprojects do not use ProtoData directly. */, - "ConstPropertyName" /* We use custom convention for artifact properties. */, - "MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */, -) -object ProtoData { - const val pluginGroup = Spine.group - const val group = "io.spine.protodata" - const val pluginId = "io.spine.protodata" - - /** - * Identifies ProtoData as a `classpath` dependency under `buildScript` block. - * - * The dependency is obtained from https://plugins.gradle.org/m2/. - */ - const val module = "io.spine:protodata" - - /** - * The version of ProtoData dependencies. - */ - val version: String - private const val fallbackVersion = "0.96.4" - - /** - * The distinct version of ProtoData used by other build tools. - * - * When ProtoData is used both for building the project and as a part of the Project's - * transitional dependencies, this is the version used to build the project itself. - */ - val dogfoodingVersion: String - private const val fallbackDfVersion = "0.96.4" - - /** - * The artifact for the ProtoData Gradle plugin. - */ - val pluginLib: String - - /** - * The artifact to be used during experiments when publishing locally. - * - * @see ProtoData - */ - private fun pluginLib(version: String): String = - "$group:gradle-plugin:$version" - - fun api(version: String): String = - "$group:protodata-api:$version" - - val api - get() = api(version) - - val backend - get() = "$group:protodata-backend:$version" - - val params - get() = "$group:protodata-params:$version" - - val protocPlugin - get() = "$group:protodata-protoc:$version" - - val gradleApi - get() = "$group:protodata-gradle-api:$version" - - val cliApi - get() = "$group:protodata-cli-api:$version" - - val javaModule = "$group:protodata-java" - - fun java(version: String): String = - "$javaModule:$version" - - val java - get() = java(version) - - val fatCli - get() = "$group:protodata-fat-cli:$version" - - val testlib - get() = "$group:protodata-testlib:$version" - - /** - * An env variable storing a custom [version]. - */ - private const val VERSION_ENV = "PROTODATA_VERSION" - - /** - * An env variable storing a custom [dogfoodingVersion]. - */ - private const val DF_VERSION_ENV = "PROTODATA_DF_VERSION" - - /** - * Sets up the versions and artifacts for the build to use. - * - * If either [VERSION_ENV] or [DF_VERSION_ENV] is set, those versions are used instead of - * the hardcoded ones. Also, in this mode, the [pluginLib] coordinates are changed so that - * it points at a locally published artifact. Otherwise, it points at an artifact that would be - * published to a public plugin registry. - */ - init { - val experimentVersion = System.getenv(VERSION_ENV) - val experimentDfVersion = System.getenv(DF_VERSION_ENV) - if (experimentVersion?.isNotBlank() == true || experimentDfVersion?.isNotBlank() == true) { - version = experimentVersion ?: fallbackVersion - dogfoodingVersion = experimentDfVersion ?: fallbackDfVersion - - pluginLib = pluginLib(version) - println(""" - - ❗ Running an experiment with ProtoData. ❗ - ----------------------------------------- - Regular version = v$version - Dogfooding version = v$dogfoodingVersion - - ProtoData Gradle plugin can now be loaded from Maven Local. - - To reset the versions, erase the `$$VERSION_ENV` and `$$DF_VERSION_ENV` environment variables. - - """.trimIndent()) - } else { - version = fallbackVersion - dogfoodingVersion = fallbackDfVersion - pluginLib = "$pluginGroup:protodata:$version" - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt deleted file mode 100644 index 813b4cc..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ProtoTap.kt +++ /dev/null @@ -1,46 +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.dependency.local - -/** - * Dependencies on ProtoTap plugins. - * - * See [`SpineEventEngine/ProtoTap`](https://github.com/SpineEventEngine/ProtoTap/). - */ -@Suppress( - "unused" /* Some subprojects do not use ProtoData directly. */, - "ConstPropertyName" /* We use custom convention for artifact properties. */, - "MemberVisibilityCanBePrivate" /* The properties are used directly by other subprojects. */, -) -object ProtoTap { - const val group = "io.spine.tools" - const val version = "0.13.0" - const val gradlePluginId = "io.spine.prototap" - const val api = "$group:prototap-api:$version" - const val gradlePlugin = "$group:prototap-gradle-plugin:$version" - const val protocPlugin = "$group:prototap-protoc-plugin:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt deleted file mode 100644 index 12f58a3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Reflect.kt +++ /dev/null @@ -1,40 +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.dependency.local - -/** - * Spine Reflect library. - * - * @see spine-reflect - */ -@Suppress("ConstPropertyName") -object Reflect { - const val version = "2.0.0-SNAPSHOT.200" - const val group = Spine.group - const val artifact = "spine-reflect" - const val lib = "$group:$artifact:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt deleted file mode 100644 index a5cce49..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Spine.kt +++ /dev/null @@ -1,36 +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.dependency.local - -/** - * Dependencies on smaller Spine modules. - */ -@Suppress("unused", "ConstPropertyName") -object Spine { - const val group = "io.spine" - const val toolsGroup = "io.spine.tools" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt deleted file mode 100644 index 1f3ffc3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/TestLib.kt +++ /dev/null @@ -1,40 +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.dependency.local - -/** - * Spine TestLib library. - * - * @see spine-testlib - */ -@Suppress("ConstPropertyName") -object TestLib { - const val version = "2.0.0-SNAPSHOT.210" - const val group = ToolBase.group - const val artifact = "spine-testlib" - const val lib = "$group:$artifact:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Text.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Text.kt deleted file mode 100644 index 216ec13..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Text.kt +++ /dev/null @@ -1,40 +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.dependency.local - -/** - * Spine Reflect library. - * - * @see spine-text - */ -@Suppress("ConstPropertyName") -object Text { - const val version = "2.0.0-SNAPSHOT.6" - const val group = Spine.group - const val artifact = "spine-text" - const val lib = "$group:$artifact:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt deleted file mode 100644 index c10dae5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Time.kt +++ /dev/null @@ -1,42 +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.dependency.local - -/** - * Spine Time library. - * - * @see spine-time - */ -@Suppress("ConstPropertyName") -object Time { - const val version = "2.0.0-SNAPSHOT.203" - const val group = Spine.group - const val artifact = "spine-time" - const val lib = "$group:$artifact:$version" - - const val testLib = "${ToolBase.group}:spine-time-testlib:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt deleted file mode 100644 index 3625a4b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/ToolBase.kt +++ /dev/null @@ -1,61 +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.dependency.local - -/** - * Artifacts of the `tool-base` module. - * - * @see tool-base - */ -@Suppress("ConstPropertyName", "unused") -object ToolBase { - const val group = "io.spine.tools" - const val version = "2.0.0-SNAPSHOT.355" - - const val lib = "$group:tool-base:$version" - const val pluginBase = "$group:plugin-base:$version" - const val pluginTestlib = "$group:plugin-testlib:$version" - - const val intellijPlatform = "$group:intellij-platform:$version" - const val intellijPlatformJava = "$group:intellij-platform-java:$version" - - const val psi = "$group:psi:$version" - const val psiJava = "$group:psi-java:$version" - - const val gradleRootPlugin = "$group:gradle-root-plugin:$version" - const val gradlePluginApi = "$group:gradle-plugin-api:$version" - const val gradlePluginApiTestFixtures = "$group:gradle-plugin-api-test-fixtures:$version" - - const val jvmTools = "$group:jvm-tools:$version" - const val jvmToolPlugins = "$group:jvm-tool-all-plugins:$version" - - object JavadocFilter { - const val group = ToolBase.group - const val version = "2.0.0-SNAPSHOT.75" - const val artifact = "$group:spine-javadoc-filter:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt deleted file mode 100644 index e842283..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.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.dependency.local - -/** - * Dependencies on Spine Validation SDK. - * - * See [`SpineEventEngine/validation`](https://github.com/SpineEventEngine/validation/). - */ -@Suppress("ConstPropertyName", "unused") -object Validation { - /** - * The version of the Validation library artifacts. - */ - const val version = "2.0.0-SNAPSHOT.351" - - /** - * The last version of Validation compatible with ProtoData. - */ - const val pdCompatibleVersion = "2.0.0-SNAPSHOT.342" - - const val group = "io.spine.validation" - private const val prefix = "spine-validation" - - const val runtimeModule = "$group:$prefix-java-runtime" - const val runtime = "$runtimeModule:$version" - const val javaModule = "$group:$prefix-java" - const val java = "$javaModule:$version" - - const val javaBundleModule = "$group:$prefix-java-bundle" - - /** Obtains the artifact for the `java-bundle` artifact of the given version. */ - fun javaBundle(version: String) = "$javaBundleModule:$version" - - val javaBundle = javaBundle(version) - - const val model = "$group:$prefix-model:$version" - - const val configModule = "$group:$prefix-configuration" - const val configuration = "$configModule:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt deleted file mode 100644 index 760c116..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/AssertK.kt +++ /dev/null @@ -1,39 +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.dependency.test - -/** - * Assertion library for tests in Kotlin - * - * [AssertK](https://github.com/willowtreeapps/assertk) - */ -@Deprecated("Please use Kotest assertions instead.") -@Suppress("unused", "ConstPropertyName") -object AssertK { - private const val version = "0.28.1" - const val libJvm = "com.willowtreeapps.assertk:assertk-jvm:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt deleted file mode 100644 index e540c2c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Hamcrest.kt +++ /dev/null @@ -1,40 +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.dependency.test - -/** - * The dependency on the Hamcrest, which is transitive for us. - * - * If you need assertions in Java, please use Google [Truth] instead. - * For Kotlin, please use [Kotest]. - */ -@Suppress("unused", "ConstPropertyName") -object Hamcrest { - // https://github.com/hamcrest/JavaHamcrest/releases - private const val version = "3.0" - const val core = "org.hamcrest:hamcrest-core:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt deleted file mode 100644 index b07849f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/JUnit.kt +++ /dev/null @@ -1,119 +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.dependency.test - -import io.spine.dependency.Dependency -import io.spine.dependency.DependencyWithBom - -// https://junit.org/junit5/ -@Suppress("unused", "ConstPropertyName") -object JUnit : DependencyWithBom() { - - override val version = "5.13.2" - override val group: String = "org.junit" - - /** - * The BOM of JUnit. - * - * This one should be forced in a project via: - * - * ```kotlin - * dependencies { - * testImplementation(enforcedPlatform(JUnit.bom)) - * } - * ``` - * The version of JUnit is forced automatically by - * the [BomsPlugin][io.spine.dependency.boms.BomsPlugin] - * when it is applied to the project. - */ - override val bom = "$group:junit-bom:$version" - - private const val legacyVersion = "4.13.1" - - // https://github.com/apiguardian-team/apiguardian - private const val apiGuardianVersion = "1.1.2" - - // https://github.com/junit-pioneer/junit-pioneer - private const val pioneerVersion = "2.3.0" - const val pioneer = "org.junit-pioneer:junit-pioneer:$pioneerVersion" - - const val legacy = "junit:junit:$legacyVersion" - - @Deprecated("Use JUnit.Jupiter.api instead", ReplaceWith("JUnit.Jupiter.api")) - val api = listOf( - "org.apiguardian:apiguardian-api:$apiGuardianVersion", - "org.junit.jupiter:junit-jupiter-api:$version", - "org.junit.jupiter:junit-jupiter-params:$version" - ) - - @Deprecated("Use JUnit.Jupiter.engine instead", ReplaceWith("JUnit.Jupiter.engine")) - val runner = "org.junit.jupiter:junit-jupiter-engine:$version" - - @Deprecated("Use JUnit.Jupiter.params instead", ReplaceWith("JUnit.Jupiter.params")) - val params = "org.junit.jupiter:junit-jupiter-params:$version" - - object Jupiter : Dependency() { - override val version = JUnit.version - override val group = "org.junit.jupiter" - private const val infix = "junit-jupiter" - - // We do not use versions because they are forced via BOM. - val api = "$group:$infix-api" - val params = "$group:$infix-params" - val engine = "$group:$infix-engine" - - @Deprecated("Please use `[Jupiter.run { artifacts[api] }` instead.") - val apiArtifact = "$api:$version" - - override val modules = listOf(api, params, engine) - } - - /** - * The same as [Jupiter.artifacts]. - */ - override val modules = Jupiter.modules - - object Platform : Dependency() { - - /** - * The version of the platform is defined by JUnit BOM. - * - * So when we use JUnit as a platform, this property should be picked up - * for the dependencies automatically. - */ - override val version: String = "1.13.2" - override val group = "org.junit.platform" - - private const val infix = "junit-platform" - val commons = "$group:$infix-commons" - val launcher = "$group:$infix-launcher" - val engine = "$group:$infix-engine" - val suiteApi = "$group:$infix-suite-api" - - override val modules = listOf(commons, launcher, engine, suiteApi) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt deleted file mode 100644 index 5f007ec..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Jacoco.kt +++ /dev/null @@ -1,37 +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.dependency.test - -/** - * Code coverage library for Java. - * - * @see Releases - */ -@Suppress("ConstPropertyName") -object Jacoco { - const val version = "0.8.13" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Kotest.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Kotest.kt deleted file mode 100644 index 8de10ff..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Kotest.kt +++ /dev/null @@ -1,60 +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. - */ - -@file:Suppress("unused") - -package io.spine.dependency.test - -/** - * Testing framework for Kotlin. - * - * @see Kotest site - */ -@Suppress("unused", "ConstPropertyName") -object Kotest { - const val version = "5.9.1" - const val group = "io.kotest" - const val assertions = "$group:kotest-assertions-core:$version" - const val runnerJUnit5 = "$group:kotest-runner-junit5:$version" - const val runnerJUnit5Jvm = "$group:kotest-runner-junit5-jvm:$version" - const val frameworkApi = "$group:kotest-framework-api:$version" - const val datatest = "$group:kotest-framework-datatest:$version" - const val frameworkEngine = "$group:kotest-framework-engine:$version" - - // https://plugins.gradle.org/plugin/io.kotest.multiplatform - object MultiplatformGradlePlugin { - const val version = Kotest.version - const val id = "io.kotest.multiplatform" - const val classpath = "$group:kotest-framework-multiplatform-plugin-gradle:$version" - } - - // https://github.com/kotest/kotest-gradle-plugin - object JvmGradlePlugin { - const val version = "0.4.10" - const val id = "io.kotest" - const val classpath = "$group:kotest-gradle-plugin:$version" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt deleted file mode 100644 index bde365a..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/KotlinCompileTesting.kt +++ /dev/null @@ -1,40 +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.dependency.test - -/** - * A library for in-process compilation of Kotlin and Java code compilation. - * - * @see GitHub repo - */ -@Suppress("unused", "ConstPropertyName") -object KotlinCompileTesting { - private const val version = "0.7.1" - private const val group = "dev.zacsweers.kctfork" - const val libCore = "$group:core:$version" - const val libKsp = "$group:ksp:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt deleted file mode 100644 index 61897cc..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Kover.kt +++ /dev/null @@ -1,35 +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.dependency.test - -// https://github.com/Kotlin/kotlinx-kover -@Suppress("unused", "ConstPropertyName") -object Kover { - const val version = "0.9.1" - const val id = "org.jetbrains.kotlinx.kover" - const val classpath = "org.jetbrains.kotlinx:kover-gradle-plugin:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/OpenTest4J.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/OpenTest4J.kt deleted file mode 100644 index 1e22fb3..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/OpenTest4J.kt +++ /dev/null @@ -1,38 +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.dependency.test - -/** - * The dependency on the OpenTest4j library, which is transitive for us. - */ -@Suppress("unused", "ConstPropertyName") -object OpenTest4J { - - // https://github.com/ota4j-team/opentest4j/releases - private const val version = "1.3.0" - const val lib = "org.opentest4j:opentest4j:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/SystemLambda.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/SystemLambda.kt deleted file mode 100644 index 5f0eef8..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/SystemLambda.kt +++ /dev/null @@ -1,35 +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.dependency.test - -// https://github.com/stefanbirkner/system-lambda -@Suppress("unused", "ConstPropertyName") -object SystemLambda { - const val version = "1.2.1" - const val group = "com.github.stefanbirkner" - const val lib = "$group:system-lambda:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/TestKitTruth.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/TestKitTruth.kt deleted file mode 100644 index bfec211..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/TestKitTruth.kt +++ /dev/null @@ -1,41 +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. - */ - -@file:Suppress("MaxLineLength") - -package io.spine.dependency.test - -/** - * Gradle TestKit extension for Google Truth. - * - * @see TestKit source code - * @see Usage description - */ -@Suppress("unused", "ConstPropertyName") -object TestKitTruth { - private const val version = "1.20.0" - const val lib = "com.autonomousapps:testkit-truth:$version" -} diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt b/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt deleted file mode 100644 index cbfb4ad..0000000 --- a/buildSrc/src/main/kotlin/io/spine/dependency/test/Truth.kt +++ /dev/null @@ -1,38 +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.dependency.test - -// https://github.com/google/truth -@Suppress("unused", "ConstPropertyName") -object Truth { - private const val version = "1.4.4" - val libs = listOf( - "com.google.truth:truth:$version", - "com.google.truth.extensions:truth-java8-extension:$version", - "com.google.truth.extensions:truth-proto-extension:$version" - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt index deda203..1a0c615 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/ProjectExtensions.kt @@ -26,7 +26,6 @@ package io.spine.gradle -import io.spine.gradle.publish.SpinePublishing import java.io.File import org.gradle.api.Plugin import org.gradle.api.Project @@ -83,25 +82,6 @@ fun Project.getTask(name: String): T { return task as T } -/** - * Obtains Maven artifact ID of this [Project]. - * - * The method checks if [SpinePublishing] extension is configured upon this project. If yes, - * returns [SpinePublishing.artifactId] for the project. Otherwise, a project's name is returned. - */ -val Project.artifactId: String - get() { - - // Publishing of a project can be configured either from the project itself or - // from its root project. This is why it is required to check both places. - - val spinePublishing = extensions.findByType() - ?: rootProject.extensions.findByType() - - val artifactId = spinePublishing?.artifactId(this) - return artifactId ?: name - } - /** * Returns project's build directory as [File]. */ diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/VersionWriter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/VersionWriter.kt deleted file mode 100644 index d3d4323..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/VersionWriter.kt +++ /dev/null @@ -1,149 +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.gradle - -import java.util.* -import org.gradle.api.DefaultTask -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.file.DirectoryProperty -import org.gradle.api.provider.MapProperty -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.OutputDirectory -import org.gradle.api.tasks.TaskAction - -/** - * A task that generates a dependency versions `.properties` file. - */ -abstract class WriteVersions : DefaultTask() { - - /** - * Versions to add to the file. - * - * The map key is a string in the format of `_`, and the value - * is the version corresponding to those group ID and artifact name. - * - * @see WriteVersions.version - */ - @get:Input - abstract val versions: MapProperty - - /** - * The directory that hosts the generated file. - */ - @get:OutputDirectory - abstract val versionsFileLocation: DirectoryProperty - - /** - * Adds a dependency version to write into the file. - * - * The given dependency notation is a Gradle artifact string of format: - * `"::"`. - * - * @see WriteVersions.versions - * @see WriteVersions.includeOwnVersion - */ - fun version(dependencyNotation: String) { - val parts = dependencyNotation.split(":") - check(parts.size == 3) { "Invalid dependency notation: `$dependencyNotation`." } - versions.put("${parts[0]}_${parts[1]}", parts[2]) - } - - /** - * Enables the versions file to include the version of the project that owns this task. - * - * @see WriteVersions.version - * @see WriteVersions.versions - */ - fun includeOwnVersion() { - val groupId = project.group.toString() - val artifactId = project.artifactId - val version = project.version.toString() - versions.put("${groupId}_${artifactId}", version) - } - - /** - * Creates a `.properties` file with versions, named after the value - * of [Project.artifactId] property. - * - * The name of the file would be: `versions-.properties`. - * - * By default, value of [Project.artifactId] property is a project's name with "spine-" prefix. - * For example, if a project's name is "tools", then the name of the file would be: - * `versions-spine-tools.properties`. - */ - @TaskAction - fun writeFile() { - versions.finalizeValue() - versionsFileLocation.finalizeValue() - - val values = versions.get() - val properties = Properties() - properties.putAll(values) - val outputDir = versionsFileLocation.get().asFile - outputDir.mkdirs() - val fileName = resourceFileName() - val file = outputDir.resolve(fileName) - file.createNewFile() - file.writer().use { - properties.store(it, "Dependency versions supplied by the `$path` task.") - } - } - - private fun resourceFileName(): String { - val artifactId = project.artifactId - return "versions-${artifactId}.properties" - } -} - -/** - * A plugin that enables storing dependency versions into a resource file. - * - * Dependency version may be used by Gradle plugins at runtime. - * - * The plugin adds one task — `writeVersions`, which generates a `.properties` file with some - * dependency versions. - * - * The generated file will be available in classpath of the target project under the name: - * `versions-.properties`, where `` is the name of the target - * Gradle project. - */ -@Suppress("unused") -class VersionWriter : Plugin { - - override fun apply(target: Project): Unit = with (target.tasks) { - val task = register("writeVersions", WriteVersions::class.java) { - versionsFileLocation.convention(project.layout.buildDirectory.dir(name)) - includeOwnVersion() - project.sourceSets - .getByName("main") - .resources - .srcDir(versionsFileLocation) - } - getByName("processResources").dependsOn(task) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt deleted file mode 100644 index bb2a181..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/checkstyle/CheckStyleConfig.kt +++ /dev/null @@ -1,76 +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.gradle.checkstyle - -import io.spine.dependency.build.CheckStyle -import org.gradle.api.Project -import org.gradle.api.plugins.quality.CheckstyleExtension -import org.gradle.api.plugins.quality.CheckstylePlugin -import org.gradle.kotlin.dsl.the - -/** - * Configures the Checkstyle plugin. - * - * Usage: - * ``` - * CheckStyleConfig.applyTo(project) - * ``` - * - * Please note, the checks of the `test` sources are disabled. - * - * Also, this type is named in double-camel-case to avoid re-declaration due to a clash - * with some Gradle-provided types. - */ -@Suppress("unused") -object CheckStyleConfig { - - /** - * Applies the configuration to the passed [project]. - */ - fun applyTo(project: Project) { - project.apply { - plugin(CheckstylePlugin::class.java) - } - - val configDir = project.rootDir.resolve("buildSrc/quality/") - - with(project.the()) { - toolVersion = CheckStyle.version - configDirectory.set(configDir) - } - - project.afterEvaluate { - // Disables checking the test sources and test fixtures. - arrayOf( - "checkstyleTest", - "checkstyleTestFixtures" - ).forEach { - task -> tasks.findByName(task)?.enabled = false - } - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartContext.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartContext.kt deleted file mode 100644 index c32c10f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartContext.kt +++ /dev/null @@ -1,45 +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.gradle.dart - -import org.gradle.api.Project -import org.gradle.api.tasks.Exec - -/** - * Provides access to the current [DartEnvironment] and shortcuts for running `pub` tool. - */ -open class DartContext(dartEnv: DartEnvironment, internal val project: Project) - : DartEnvironment by dartEnv -{ - /** - * Executes `pub` command in this [Exec] task. - * - * The Dart ecosystem uses packages to manage shared software such as libraries and tools. - * To get or publish Dart packages, the `pub` package manager is to be used. - */ - fun Exec.pub(vararg args: Any) = commandLine(pubExecutable, *args) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartEnvironment.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartEnvironment.kt deleted file mode 100644 index 4e4ae83..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartEnvironment.kt +++ /dev/null @@ -1,170 +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.gradle.dart - -import java.io.File -import org.apache.tools.ant.taskdefs.condition.Os - -/** - * Describes the environment in which Dart code is assembled and processed during the build. - * - * Consists of two parts describing: - * - * 1. The module itself. - * 2. Tools and their input/output files. - */ -interface DartEnvironment { - - /* - * A module itself - ******************/ - - /** - * Module's root catalog. - */ - val projectDir: File - - /** - * Module's name. - */ - val projectName: String - - /** - * A directory which all artifacts are generated into. - * - * Default value: "$projectDir/build". - */ - val buildDir: File - get() = projectDir.resolve("build") - - /** - * A directory where artifacts for further publishing would be prepared. - * - * Default value: "$buildDir/pub/publication/$projectName". - */ - val publicationDir: File - get() = buildDir - .resolve("pub") - .resolve("publication") - .resolve(projectName) - - /** - * A directory which contains integration test Dart sources. - * - * Default value: "$projectDir/integration-test". - */ - val integrationTestDir: File - get() = projectDir.resolve("integration-test") - - /* - * Tools and their input/output files - *************************************/ - - /** - * Name of an executable for running `pub` tool. - * - * Default value: - * - * 1. "pub.bat" for Windows. - * 2. "pub" for other Oss. - */ - val pubExecutable: String - get() = if (isWindows()) "pub.bat" else "pub" - - /** - * Dart module's metadata file. - * - * Every pub package needs some metadata so it can specify its dependencies. Pub packages that - * are shared with others also need to provide some other information so users can discover - * them. All of this metadata goes in the package’s `pubspec`. - * - * Default value: "$projectDir/pubspec.yaml". - * - * See [The pubspec file | Dart](https://dart.dev/tools/pub/pubspec) - */ - val pubSpec: File - get() = projectDir.resolve("pubspec.yaml") - - /** - * Module dependencies' index that maps resolved package names to location URIs. - * - * By default, pub creates a [packageConfig] file in the `.dart_tool/` directory for this. - * Before the [packageConfig], pub used to create this [packageIndex] file in the root - * directory. - * - * As for Dart 2.14, `pub` still updates the deprecated file for backwards compatibility. - * - * Default value: "$projectDir/.packages". - */ - val packageIndex: File - get() = projectDir.resolve(".packages") - - /** - * Module dependencies' index that maps resolved package names to location URIs. - * - * Default value: "$projectDir/.dart_tool/package_config.json". - */ - val packageConfig: File - get() = projectDir - .resolve(".dart_tool") - .resolve("package_config.json") -} - -/** - * Allows overriding [DartEnvironment]'s defaults. - * - * Please note, not all properties of the environment can be overridden. Properties that describe - * `pub` tool's input/output files can NOT be overridden because `pub` itself doesn't allow to - * specify them for its execution. - * - * The next properties could not be overridden: - * - * 1. [DartEnvironment.pubSpec]. - * 2. [DartEnvironment.packageIndex]. - * 3. [DartEnvironment.packageConfig]. - */ -class ConfigurableDartEnvironment(initialEnv: DartEnvironment) - : DartEnvironment by initialEnv -{ - /* - * A module itself - ******************/ - - override var projectDir = initialEnv.projectDir - override var projectName = initialEnv.projectName - override var buildDir = initialEnv.buildDir - override var publicationDir = initialEnv.publicationDir - override var integrationTestDir = initialEnv.integrationTestDir - - /* - * Tools and their input/output files - *************************************/ - - override var pubExecutable = initialEnv.pubExecutable -} - -internal fun isWindows(): Boolean = Os.isFamily(Os.FAMILY_WINDOWS) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartExtension.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartExtension.kt deleted file mode 100644 index 57a2bcf..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/DartExtension.kt +++ /dev/null @@ -1,187 +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.gradle.dart - -import io.spine.gradle.dart.plugin.DartPlugins -import io.spine.gradle.dart.task.DartTasks -import org.gradle.api.Project -import org.gradle.kotlin.dsl.create -import org.gradle.kotlin.dsl.findByType - -/** - * Configures [DartExtension] that facilitates configuration of Gradle tasks and plugins - * to build Dart projects. - * - * The whole structure of the extension looks as follows: - * - * ``` - * dart { - * environment { - * // ... - * } - * plugins { - * // ... - * } - * tasks { - * // ... - * } - * } - * ``` - * - * ### Environment - * - * One of the main features of this extension is [DartEnvironment]. Environment describes a module - * itself and used tools with their input/output files. - * - * The extension is shipped with a pre-configured environment. So, no pre-configuration is required. - * Most properties in [DartEnvironment] have calculated defaults right in the interface. - * Only two properties need explicit override. - * - * The extension defines them as follows: - * - * 1. [DartEnvironment.projectDir] –> `project.projectDir`. - * 2. [DartEnvironment.projectName] —> `project.name`. - * - * There are two ways to modify the environment: - * - * 1. Modify [DartEnvironment] interface directly. Go with this option when it is a global change - * that should affect all projects which use this extension. - * 2. Use [DartExtension.environment] scope — for temporary and custom overridings. - * - * An example of a property overriding: - * - * ``` - * dart { - * environment { - * integrationTestDir = projectDir.resolve("tests") - * } - * } - * ``` - * - * Please note, environment should be set up firstly to have the effect on the parts - * of the extension that use it. - * - * ### Tasks and Plugins - * - * The spirit of tasks configuration in this extension is extracting the code that defines and - * registers tasks into extension functions upon `DartTasks` in `buildSrc`. Those extensions should - * be named after a task it registers or a task group if several tasks are registered at once. - * Then this extension is called in a project's `build.gradle.kts`. - * - * `DartTasks` and `DartPlugins` scopes extend [DartContext] which provides access - * to the current [DartEnvironment] and shortcuts for running `pub` tool. - * - * Below is the simplest example of how to create a primitive `printPubVersion` task. - * - * Firstly, a corresponding extension function should be defined in `buildSrc`: - * - * ``` - * fun DartTasks.printPubVersion() = - * register("printPubVersion") { - * pub("--version") - * } - * ``` - * - * Secondly, in a project's `build.gradle.kts` this extension is called: - * - * ``` - * dart { - * tasks { - * printPubVersion() - * } - * } - * ``` - * - * An extension function is not restricted to register exactly one task. If several tasks can - * be grouped into a logical bunch, they should be registered together: - * - * ``` - * fun DartTasks.build() { - * assembleDart() - * testDart() - * generateCoverageReport() - * } - * - * private fun DartTasks.assembleDart() = ... - * - * private fun DartTasks.testDart() = ... - * - * private fun DartTasks.generateCoverageReport() = ... - * ``` - * - * This section is mostly dedicated to tasks. But tasks and plugins are configured - * in a very similar way. So, everything above is also applicable to plugins. More detailed - * guides can be found in docs to `DartTasks` and `DartPlugins`. - * - * @see [ConfigurableDartEnvironment] - * @see [DartTasks] - * @see [DartPlugins] - */ -fun Project.dart(configuration: DartExtension.() -> Unit) { - extensions.run { - configuration.invoke( - findByType() ?: create("dartExtension", project) - ) - } -} - -/** - * Scope for performing Dart-related configuration. - * - * @see [dart] - */ -open class DartExtension(project: Project) { - - private val environment = ConfigurableDartEnvironment( - object : DartEnvironment { - override val projectDir = project.projectDir - override val projectName = project.name - } - ) - - private val tasks = DartTasks(environment, project) - private val plugins = DartPlugins(environment, project) - - /** - * Overrides default values of [DartEnvironment]. - * - * Please note, environment should be set up firstly to have the effect on the parts - * of the extension that use it. - */ - fun environment(overridings: ConfigurableDartEnvironment.() -> Unit) = - environment.run(overridings) - - /** - * Configures [Dart-related plugins][DartPlugins]. - */ - fun plugins(configurations: DartPlugins.() -> Unit) = plugins.run(configurations) - - /** - * Configures [Dart-related tasks][DartTasks]. - */ - fun tasks(configurations: DartTasks.() -> Unit) = tasks.run(configurations) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/DartPlugins.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/DartPlugins.kt deleted file mode 100644 index 9d76a77..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/DartPlugins.kt +++ /dev/null @@ -1,92 +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.gradle.dart.plugin - -import io.spine.gradle.dart.DartContext -import io.spine.gradle.dart.DartEnvironment -import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionContainer -import org.gradle.api.plugins.PluginContainer -import org.gradle.api.tasks.TaskContainer - -/** - * A scope for applying and configuring Dart-related plugins. - * - * The scope extends [DartContext] and provides shortcuts for key project's containers: - * - * 1. [plugins]. - * 2. [extensions]. - * 3. [tasks]. - * - * Let's imagine one wants to apply and configure `FooBar` plugin. To do that, several steps - * should be completed: - * - * 1. Declare the corresponding extension function upon [DartContext] named after the plugin. - * 2. Apply and configure the plugin inside that function. - * 3. Call the resulted extension in your `build.gradle.kts` file. - * - * Here's an example of `dart/plugin/FooBar.kt`: - * - * ``` - * fun DartPlugins.fooBar() { - * plugins.apply("com.fooBar") - * extensions.configure { - * // ... - * } - * } - * ``` - * - * And here's how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.dart.dart - * import io.spine.gradle.dart.plugins.fooBar - * - * // ... - * - * dart { - * plugins { - * fooBar() - * } - * } - * ``` - */ -class DartPlugins(dartEnv: DartEnvironment, project: Project) : DartContext(dartEnv, project) { - - internal val plugins = project.plugins - internal val extensions = project.extensions - internal val tasks = project.tasks - - internal fun plugins(configurations: PluginContainer.() -> Unit) = - plugins.run(configurations) - - internal fun extensions(configurations: ExtensionContainer.() -> Unit) = - extensions.run(configurations) - - internal fun tasks(configurations: TaskContainer.() -> Unit) = - tasks.run(configurations) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/Protobuf.kt deleted file mode 100644 index bfd503f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/plugin/Protobuf.kt +++ /dev/null @@ -1,52 +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.gradle.dart.plugin - -import com.google.protobuf.gradle.ProtobufExtension -import com.google.protobuf.gradle.id -import com.google.protobuf.gradle.remove -import io.spine.dependency.lib.Protobuf - -/** - * Applies `protobuf` plugin and configures `GenerateProtoTask` to work with a Dart module. - * - * @see DartPlugins - */ -fun DartPlugins.protobuf() { - - plugins.apply(Protobuf.GradlePlugin.id) - - val protobufExtension = project.extensions.getByType(ProtobufExtension::class.java) - protobufExtension.apply { - generateProtoTasks.all().configureEach { - apply { - plugins { id("dart") } - builtins { remove("java") } - } - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Build.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Build.kt deleted file mode 100644 index 163747e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Build.kt +++ /dev/null @@ -1,155 +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.gradle.dart.task - -import io.spine.gradle.TaskName -import io.spine.gradle.base.assemble -import io.spine.gradle.base.check -import io.spine.gradle.base.clean -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.tasks.Delete -import org.gradle.api.tasks.Exec -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers tasks for building Dart projects. - * - * List of tasks to be created: - * - * 1. [TaskContainer.cleanPackageIndex]. - * 2. [TaskContainer.resolveDependencies]. - * 3. [TaskContainer.testDart]. - * - * An example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.dart.dart - * import io.spine.gradle.dart.task.build - * - * // ... - * - * dart { - * tasks { - * build() - * } - * } - * ``` - * - * @param configuration any additional configuration related to the module's building. - */ -fun DartTasks.build(configuration: DartTasks.() -> Unit = {}) { - - cleanPackageIndex().also { - clean.configure { - dependsOn(it) - } - } - resolveDependencies().also { - assemble.configure { - dependsOn(it) - } - } - testDart().also { - check.configure { - dependsOn(it) - } - } - - configuration() -} - -private val resolveDependenciesName = TaskName.of("resolveDependencies", Exec::class) - -/** - * Locates `resolveDependencies` task in this [TaskContainer]. - * - * The task fetches dependencies declared via `pubspec.yaml` using `pub get` command. - */ -val TaskContainer.resolveDependencies: TaskProvider - get() = named(resolveDependenciesName) - -private fun DartTasks.resolveDependencies(): TaskProvider = - register(resolveDependenciesName) { - - description = "Fetches dependencies declared via `pubspec.yaml`." - group = DartTasks.Group.build - - mustRunAfter(cleanPackageIndex) - - inputs.file(pubSpec) - outputs.file(packageIndex) - - pub("get") - } - -private val cleanPackageIndexName = TaskName.of("cleanPackageIndex", Delete::class) - -/** - * Locates `cleanPackageIndex` task in this [TaskContainer]. - * - * The task deletes the resolved module dependencies' index. - * - * The standard configuration file that contains index is `package_config.json`. For backwards - * compatability `pub` still updates the deprecated `.packages` file. The task deletes both files. - */ -val TaskContainer.cleanPackageIndex: TaskProvider - get() = named(cleanPackageIndexName) - -private fun DartTasks.cleanPackageIndex(): TaskProvider = - register(cleanPackageIndexName) { - - description = "Deletes the resolved `.packages` and `package_config.json` files." - group = DartTasks.Group.build - - delete( - packageIndex, - packageConfig - ) - } - -private val testDartName = TaskName.of("testDart", Exec::class) - -/** - * Locates `testDart` task in this [TaskContainer]. - * - * The task runs Dart tests declared in the `./test` directory. - */ -val TaskContainer.testDart: TaskProvider - get() = named(testDartName) - -private fun DartTasks.testDart(): TaskProvider = - register(testDartName) { - - description = "Runs Dart tests declared in the `./test` directory." - group = DartTasks.Group.build - - dependsOn(resolveDependencies) - - pub("run", "test") - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/DartTasks.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/DartTasks.kt deleted file mode 100644 index bc5e1e9..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/DartTasks.kt +++ /dev/null @@ -1,115 +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.gradle.dart.task - -import io.spine.gradle.dart.DartContext -import io.spine.gradle.dart.DartEnvironment -import org.gradle.api.Project -import org.gradle.api.tasks.TaskContainer - -/** - * A scope for registering and configuring Dart-related tasks. - * - * The scope provides: - * - * 1. Access to the current [DartContext]. - * 2. Project's [TaskContainer]. - * 3. Default task groups. - * - * Supposing, one needs to create a new task that would participate in building. Let the task name - * be `testDart`. To do that, several steps should be completed: - * - * 1. Define the task name and type using [TaskName][io.spine.gradle.TaskName]. - * 2. Create a public typed reference for the task upon [TaskContainer]. It would facilitate - * referencing to the new task, so that external tasks could depend on it. This reference - * should be documented. - * 3. Implement an extension upon [DartTasks] to register the task. - * 4. Call the resulted extension from `build.gradle.kts`. - * - * Here's an example of `testDart()` extension: - * - * ``` - * import io.spine.gradle.named - * import io.spine.gradle.register - * import io.spine.gradle.TaskName - * import org.gradle.api.Task - * import org.gradle.api.tasks.TaskContainer - * import org.gradle.api.tasks.Exec - * - * // ... - * - * private val testDartName = TaskName.of("testDart", Exec::class) - * - * /** - * * Locates `testDart` task in this [TaskContainer]. - * * - * * The task runs Dart tests declared in the `./test` directory. - * */ - * val TaskContainer.testDart: TaskProvider - * get() = named(testDartName) - * - * fun DartTasks.testDart() = - * register(testDartName) { - * - * description = "Runs Dart tests declared in the `./test` directory." - * group = DartTasks.Group.build - * - * // ... - * } - * ``` - * - * And here's how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.dart.dart - * import io.spine.gradle.dart.task.testDart - * - * // ... - * - * dart { - * tasks { - * testDart() - * } - * } - * ``` - * - * Declaring typed references upon [TaskContainer] is optional. But it is highly encouraged - * to reference other tasks by such extensions instead of hard-typed string values. - */ -class DartTasks(dartEnv: DartEnvironment, project: Project) - : DartContext(dartEnv, project), TaskContainer by project.tasks -{ - /** - * Default task groups for tasks that participate in building a Dart module. - * - * @see [org.gradle.api.Task.getGroup] - */ - internal object Group { - const val build = "Dart/Build" - const val publish = "Dart/Publish" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/IntegrationTest.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/IntegrationTest.kt deleted file mode 100644 index 19f1f14..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/IntegrationTest.kt +++ /dev/null @@ -1,92 +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.gradle.dart.task - -import io.spine.gradle.TaskName -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.tasks.Exec -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -private val integrationTestName = TaskName.of("integrationTest", Exec::class) - -/** - * Locates `integrationTest` task in this [TaskContainer]. - * - * The task runs integration tests of the `spine-dart` library against a sample - * Spine-based application. The tests are run in Chrome browser because they use `WebFirebaseClient` - * which only works in web environment. - * - * A sample Spine-based application is run from the `test-app` module before integration - * tests start and is stopped as the tests complete. - */ -val TaskContainer.integrationTest: TaskProvider - get() = named(integrationTestName) - -/** - * Registers [TaskContainer.integrationTest] task. - * - * Please note, this task depends on [build] tasks. Therefore, building tasks should be applied in - * the first place. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.dart.dart - * import io.spine.gradle.task.build - * import io.spine.gradle.task.integrationTest - * - * // ... - * - * dart { - * tasks { - * build() - * integrationTest() - * } - * } - * ``` - */ -@Suppress("unused") -fun DartTasks.integrationTest() = - register(integrationTestName) { - - dependsOn( - resolveDependencies, - ":test-app:appBeforeIntegrationTest" - ) - - pub( - "run", - "test", - integrationTestDir, - "-p", - "chrome" - ) - - finalizedBy(":test-app:appAfterIntegrationTest") - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Publish.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Publish.kt deleted file mode 100644 index 2f8df6b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dart/task/Publish.kt +++ /dev/null @@ -1,176 +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.gradle.dart.task - -import io.spine.gradle.TaskName -import io.spine.gradle.base.assemble -import io.spine.gradle.named -import io.spine.gradle.publish.publish -import io.spine.gradle.register -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.Exec -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers tasks for publishing Dart projects. - * - * Please note, this task group depends on [build] tasks. Therefore, building tasks should - * be applied in the first place. - * - * List of tasks to be created: - * - * 1. [TaskContainer.stagePubPublication]. - * 2. [TaskContainer.activateLocally]. - * 3. [TaskContainer.publishToPub]. - * - * Usage example: - * - * ``` - * import io.spine.gradle.dart.dart - * import io.spine.gradle.dart.task.build - * import io.spine.gradle.dart.task.publish - * - * // ... - * - * dart { - * tasks { - * build() - * publish() - * } - * } - * ``` - */ -fun DartTasks.publish() { - - stagePubPublication() - activateLocally() - - publishToPub().also { - publish.configure { - dependsOn(it) - } - } -} - -private val stagePubPublicationName = TaskName.of("stagePubPublication", Copy::class) - -/** - * Locates `stagePubPublication` in this [TaskContainer]. - * - * The task prepares the Dart package for Pub publication in the - * [publication directory][io.spine.gradle.dart.DartEnvironment.publicationDir]. - */ -val TaskContainer.stagePubPublication: TaskProvider - get() = named(stagePubPublicationName) - -private fun DartTasks.stagePubPublication(): TaskProvider = - register(stagePubPublicationName) { - - description = "Prepares the Dart package for Pub publication." - group = DartTasks.Group.publish - - dependsOn(assemble) - - // Beside `.dart` sources itself, `pub` package manager conventions require: - // 1. README.md and CHANGELOG.md to build a page at `pub.dev/packages/;`. - // 2. `pubspec` file to fill out details about your package on the right side of your - // package’s page. - // 3. LICENSE file. - - from(project.projectDir) { - include("**/*.dart", "pubspec.yaml", "**/*.md") - exclude("proto/", "generated/", "build/", "**/.*") - } - from("${project.rootDir}/LICENSE") - into(publicationDir) - - doLast { - logger.debug("Pub publication is prepared in directory `{}`.", publicationDir) - } - } - -private val publishToPubName = TaskName.of("publishToPub", Exec::class) - -/** - * Locates `publishToPub` task in this [TaskContainer]. - * - * The task publishes the prepared publication to Pub using `pub publish` command. - */ -val TaskContainer.publishToPub: TaskProvider - get() = named(publishToPubName) - -private fun DartTasks.publishToPub(): TaskProvider = - register(publishToPubName) { - - description = "Publishes the prepared publication to Pub." - group = DartTasks.Group.publish - - dependsOn(stagePubPublication) - - val sayYes = "y".byteInputStream() - standardInput = sayYes - - workingDir(publicationDir) - - pub("publish", "--trace") - } - -private val activateLocallyName = TaskName.of("activateLocally", Exec::class) - -/** - * Locates `activateLocally` task in this [TaskContainer]. - * - * Makes this package available in the command line as an executable. - * - * The `dart run` command supports running a Dart program — located in a file, in the current - * package, or in one of the dependencies of the current package - from the command line. - * To run a program from an arbitrary location, the package should be "activated". - * - * See [dart pub global | Dart](https://dart.dev/tools/pub/cmd/pub-global) - */ -val TaskContainer.activateLocally: TaskProvider - get() = named(activateLocallyName) - -private fun DartTasks.activateLocally(): TaskProvider = - register(activateLocallyName) { - - description = "Activates this package locally." - group = DartTasks.Group.publish - - dependsOn(stagePubPublication) - - workingDir(publicationDir) - pub( - "global", - "activate", - "--source", - "path", - publicationDir, - "--trace" - ) - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dokka/DokkaExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dokka/DokkaExtensions.kt deleted file mode 100644 index 727a079..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dokka/DokkaExtensions.kt +++ /dev/null @@ -1,48 +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.gradle.dokka - -import java.io.File -import org.gradle.api.file.FileCollection -import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder - -/** - * Returns only Java source roots out of all present in the source set. - * - * It is a helper method for generating documentation by Dokka only for Java code. - * It is helpful when both Java and Kotlin source files are present in a source set. - * Dokka can properly generate documentation for either Kotlin or Java depending on - * the configuration, but not both. - */ -@Suppress("unused") -internal fun GradleDokkaSourceSetBuilder.onlyJavaSources(): FileCollection { - return sourceRoots.filter(File::isJavaSourceDirectory) -} - -private fun File.isJavaSourceDirectory(): Boolean { - return isDirectory && name == "java" -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/dokka/TaskContainerExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/dokka/TaskContainerExtensions.kt deleted file mode 100644 index 02deead..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/dokka/TaskContainerExtensions.kt +++ /dev/null @@ -1,36 +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.gradle.dokka - -import org.gradle.api.tasks.TaskContainer -import org.jetbrains.dokka.gradle.DokkaTask - -/** - * Finds the `dokkaHtml` Gradle task. - */ -@Suppress("unused") -fun TaskContainer.dokkaHtmlTask() = this.getByName("dokkaHtml") as DokkaTask diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/AuthorEmail.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/AuthorEmail.kt deleted file mode 100644 index f0d839f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/AuthorEmail.kt +++ /dev/null @@ -1,56 +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.gradle.github.pages - -/** - * An author of updates to GitHub pages. - */ -class AuthorEmail(val value: String) { - - companion object { - - /** - * The name of the environment variable that contains the email to use for authoring - * the commits to the GitHub Pages branch. - */ - @Suppress("MemberVisibilityCanBePrivate") // for documentation purposes. - const val environmentVariable = "FORMAL_GIT_HUB_PAGES_AUTHOR" - - /** - * Obtains the author from the system [environment variable][environmentVariable]. - */ - fun fromVar() : AuthorEmail { - val envValue = System.getenv(environmentVariable) - check(envValue != null && envValue.isNotBlank()) { - "Unable to obtain an author from `${environmentVariable}`." - } - return AuthorEmail(envValue) - } - } - - override fun toString(): String = value -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt deleted file mode 100644 index ef67c71..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/RepositoryExtensions.kt +++ /dev/null @@ -1,58 +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.gradle.github.pages - -import io.spine.gradle.git.Branch -import io.spine.gradle.git.Repository -import io.spine.gradle.git.UserInfo -import io.spine.gradle.repo.RepoSlug - -/** - * Clones the current project repository with the branch dedicated to publishing - * documentation to GitHub Pages checked out. - * - * The repository's GitHub SSH URL is derived from the `REPO_SLUG` environment - * variable. The [branch][Branch.documentation] dedicated to publishing documentation - * is automatically checked out in this repository. Also, the username and the email - * of the git user are automatically configured. The username is set - * to "UpdateGitHubPages Plugin", and the email is derived from - * the `FORMAL_GIT_HUB_PAGES_AUTHOR` environment variable. - * - * @throws org.gradle.api.GradleException if any of the environment variables described above - * is not set. - */ -internal fun Repository.Factory.forPublishingDocumentation(): Repository { - val host = RepoSlug.fromVar().gitHost() - - val username = "UpdateGitHubPages Plugin" - val userEmail = AuthorEmail.fromVar().toString() - val user = UserInfo(username, userEmail) - - val branch = Branch.documentation - - return of(host, user, branch) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/SshKey.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/SshKey.kt deleted file mode 100644 index 186c474..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/SshKey.kt +++ /dev/null @@ -1,104 +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.gradle.github.pages - -import io.spine.gradle.Cli -import java.io.File -import org.gradle.api.GradleException - -/** - * Registers SSH key for further operations with GitHub Pages. - */ -internal class SshKey(private val rootProjectFolder: File) { - /** - * Creates an SSH key with the credentials and registers it by invoking the - * `register-ssh-key.sh` script. - */ - fun register() { - val gitHubAccessKey = gitHubKey() - val sshConfigFile = sshConfigFile() - sshConfigFile.appendPublisher(gitHubAccessKey) - - execute( - "${rootProjectFolder.absolutePath}/config/scripts/register-ssh-key.sh", - gitHubAccessKey.absolutePath - ) - } - - /** - * Locates `deploy_key_rsa` in the [rootProjectFolder] and returns it as a [File]. - * - * A CI instance comes with an RSA key. However, of course, the default key has - * no privileges in Spine repositories. Thus, we add our own RSA key — - * `deploy_rsa_key`. It must have `write` rights in the associated repository. - * Also, we don't want that key to be used for anything else but GitHub Pages - * publishing. - * - * Thus, we configure the SSH agent to use the `deploy_rsa_key` only for specific - * references, namely in `github.com-publish`. - * - * @throws GradleException if `deploy_key_rsa` is not found. - */ - private fun gitHubKey(): File { - val gitHubAccessKey = File("${rootProjectFolder.absolutePath}/deploy_key_rsa") - - if (!gitHubAccessKey.exists()) { - throw GradleException( - "File $gitHubAccessKey does not exist. It should be encrypted" + - " in the repository and decrypted on CI." - ) - } - return gitHubAccessKey - } - - private fun sshConfigFile(): File { - val sshConfigFile = File("${System.getProperty("user.home")}/.ssh/config") - - if (!sshConfigFile.exists()) { - val parentDir = sshConfigFile.canonicalFile.parentFile - parentDir.mkdirs() - sshConfigFile.createNewFile() - } - - return sshConfigFile - } - - private fun File.appendPublisher(privateKey: File) { - val nl = System.lineSeparator() - this.appendText( - nl + - "Host github.com-publish" + nl + - "User git" + nl + - "IdentityFile ${privateKey.absolutePath}" + nl - ) - } - - /** - * Executes a command in the project [rootProjectFolder]. - */ - private fun execute(vararg command: String): String = Cli(rootProjectFolder).execute(*command) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/TaskName.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/TaskName.kt deleted file mode 100644 index f5e3bfc..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/TaskName.kt +++ /dev/null @@ -1,47 +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.gradle.github.pages - -object TaskName { - - /** - * The name of the task which updates the GitHub Pages. - */ - const val updateGitHubPages = "updateGitHubPages" - - /** - * The name of the helper task to gather the generated Javadoc before updating - * GitHub Pages. - */ - const val copyJavadoc = "copyJavadoc" - - /** - * The name of the helper task to gather Dokka-generated documentation before - * updating GitHub Pages. - */ - const val copyDokka = "copyDokka" -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/Update.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/Update.kt deleted file mode 100644 index 0f9a0f5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/Update.kt +++ /dev/null @@ -1,167 +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.gradle.github.pages - -import io.spine.gradle.git.Repository -import java.io.File -import java.nio.file.Path -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.file.ConfigurableFileCollection -import org.gradle.api.file.FileCollection -import org.gradle.api.logging.Logger - -/** - * Performs the update of GitHub pages. - */ -fun Task.updateGhPages(project: Project) { - val plugin = project.plugins.getPlugin(UpdateGitHubPages::class.java) - - with(plugin) { - SshKey(rootFolder).register() - } - - val repository = Repository.forPublishingDocumentation() - - val updateJavadoc = with(plugin) { - UpdateJavadoc(project, javadocOutputFolder, repository, logger) - } - - val updateDokka = with(plugin) { - UpdateDokka(project, dokkaOutputFolder, repository, logger) - } - - repository.use { - updateJavadoc.run() - updateDokka.run() - repository.push() - } -} - -private abstract class UpdateDocumentation( - private val project: Project, - private val docsSourceFolder: Path, - private val repository: Repository, - private val logger: Logger -) { - - /** - * The folder under the repository's root(`/`) for storing documentation. - * - * The value should not contain any leading or trailing file separators. - * - * The absolute path to the project's documentation is made by appending its - * name to the end, making `/docsDestinationFolder/project.name`. - */ - protected abstract val docsDestinationFolder: String - - /** - * The name of the tool used to generate the documentation to update. - * - * This name will appear in logs as part of a message. - */ - protected abstract val toolName: String - - private val mostRecentFolder by lazy { - File("${repository.location}/${docsDestinationFolder}/${project.name}") - } - - private fun logDebug(message: () -> String) { - if (logger.isDebugEnabled) { - logger.debug(message()) - } - } - - fun run() { - val module = project.name - logDebug {"Update of the $toolName documentation for module `$module` started." } - - val documentation = replaceMostRecentDocs() - copyIntoVersionDir(documentation) - - val version = project.version - val updateMessage = - "Update `$toolName` documentation for module `$module` as for version $version" - repository.commitAllChanges(updateMessage) - - logDebug { "Update of the `$toolName` documentation for `$module` successfully finished." } - } - - private fun replaceMostRecentDocs(): ConfigurableFileCollection { - val generatedDocs = project.files(docsSourceFolder) - - logDebug { - "Replacing the most recent `$toolName` documentation in `${mostRecentFolder}`." - } - copyDocs(generatedDocs, mostRecentFolder) - - return generatedDocs - } - - private fun copyDocs(source: FileCollection, destination: File) { - destination.mkdir() - project.copy { - from(source) - into(destination) - } - } - - private fun copyIntoVersionDir(generatedDocs: ConfigurableFileCollection) { - val versionedDocDir = File("$mostRecentFolder/v/${project.version}") - - logDebug { - "Storing the new version of `$toolName` documentation in `${versionedDocDir}`." - } - copyDocs(generatedDocs, versionedDocDir) - } -} - -private class UpdateJavadoc( - project: Project, - docsSourceFolder: Path, - repository: Repository, - logger: Logger -) : UpdateDocumentation(project, docsSourceFolder, repository, logger) { - - override val docsDestinationFolder: String - get() = "reference" - override val toolName: String - get() = "Javadoc" -} - -private class UpdateDokka( - project: Project, - docsSourceFolder: Path, - repository: Repository, - logger: Logger -) : UpdateDocumentation(project, docsSourceFolder, repository, logger) { - - override val docsDestinationFolder: String - get() = "dokka-reference" - override val toolName: String - get() = "Dokka" -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt deleted file mode 100644 index e339dd4..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPages.kt +++ /dev/null @@ -1,234 +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.gradle.github.pages - -import dokkaHtmlTask -import io.spine.gradle.fs.LazyTempPath -import io.spine.gradle.github.pages.TaskName.copyDokka -import io.spine.gradle.github.pages.TaskName.copyJavadoc -import io.spine.gradle.github.pages.TaskName.updateGitHubPages -import io.spine.gradle.isSnapshot -import io.spine.gradle.javadoc.ExcludeInternalDoclet -import io.spine.gradle.javadoc.javadocTask -import java.io.File -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers the `updateGitHubPages` task which performs the update of the GitHub - * Pages with the documentation generated by Javadoc and Dokka for a particular - * Gradle project. The generated documentation is appended to the `spine.io` site - * via GitHub pages by pushing commits to the `gh-pages` branch. - * - * Please note that the update is only performed for the projects which are - * NOT snapshots. - * - * Users may supply [allowInternalJavadoc][UpdateGitHubPagesExtension.allowInternalJavadoc] - * to configure documentation generated by Javadoc. The documentation for the code - * marked `@Internal` is included when the option is set to `true`. By default, this - * option is `false`. - * - * Usage: - * ``` - * updateGitHubPages { - * - * // Include `@Internal`-annotated code. - * allowInternalJavadoc.set(true) - * - * // Propagate the full path to the local folder of the repository root. - * rootFolder.set(rootDir.absolutePath) - * } - * ``` - * - * In order to work, the script needs a `deploy_key_rsa` private RSA key file in the - * repository root. It is recommended to encrypt it in the repository and then decrypt - * it on CI upon publication. Also, the script uses the `FORMAL_GIT_HUB_PAGES_AUTHOR` - * environment variable to set the author email for the commits. The `gh-pages` - * branch itself should exist before the plugin is run. - * - * NOTE: when changing the value of "FORMAL_GIT_HUB_PAGES_AUTHOR", one also must change - * the SSH private (encrypted `deploy_key_rsa`) and the public - * ("GitHub Pages publisher" on GitHub) keys. - * - * Another requirement is an environment variable `REPO_SLUG`, which is set by the CI - * environment, such as `Publish` GitHub Actions workflow. It points to the repository - * for which the update is executed. E.g.: - * - * ``` - * REPO_SLUG: SpineEventEngine/base - * ``` - * - * @see UpdateGitHubPagesExtension for the extension which is used to configure - * this plugin - */ -class UpdateGitHubPages : Plugin { - - /** - * Root folder of the repository, to which this `Project` belongs. - */ - internal lateinit var rootFolder: File - - /** - * The external inputs to include into the publishing. - * - * The inputs are evaluated according to [Copy.from] specification. - */ - private lateinit var includedInputs: Set - - /** - * Path to the temp folder used to gather the Javadoc output before submitting it - * to the GitHub Pages update. - */ - internal val javadocOutputFolder = LazyTempPath("javadoc") - - /** - * Path to the temp folder used to gather the documentation generated by Dokka - * before submitting it to the GitHub Pages update. - */ - internal val dokkaOutputFolder = LazyTempPath("dokka") - - /** - * Applies the plugin to the specified [project]. - * - * If the project version says it is a snapshot, the plugin registers a no-op task. - * - * Even in such a case, the extension object is still created in the given project - * to allow customization of the parameters in its build script for later usage - * when the project version changes to non-snapshot. - */ - override fun apply(project: Project) { - val extension = UpdateGitHubPagesExtension.createIn(project) - project.afterEvaluate { - val projectVersion = project.version.toString() - if (projectVersion.isSnapshot()) { - registerNoOpTask() - } else { - registerTasks(extension) - } - } - } - - /** - * Registers `updateGitHubPages` task which performs no actual update, but prints - * the message telling the update is skipped, since the project is in - * its `SNAPSHOT` version. - */ - private fun Project.registerNoOpTask() { - tasks.register(updateGitHubPages) { - doLast { - val project = this@registerNoOpTask - println( - "GitHub Pages update will be skipped since this project is a snapshot: " + - "`${project.name}-${project.version}`." - ) - } - } - } - - private fun Project.registerTasks(extension: UpdateGitHubPagesExtension) { - val allowInternalJavadoc = extension.allowInternalJavadoc() - rootFolder = extension.rootFolder() - includedInputs = extension.includedInputs() - - if (!allowInternalJavadoc) { - val doclet = ExcludeInternalDoclet() - doclet.registerTaskIn(this) - } - - tasks.registerCopyJavadoc(allowInternalJavadoc) - tasks.registerCopyDokka() - - val updatePagesTask = tasks.registerUpdateTask() - updatePagesTask.configure { - dependsOn(copyJavadoc) - dependsOn(copyDokka) - } - } - - private fun TaskContainer.registerCopyJavadoc(allowInternalJavadoc: Boolean) { - val inputs = composeJavadocInputs(allowInternalJavadoc) - - register(copyJavadoc, Copy::class.java) { - inputs.forEach { from(it) } - into(javadocOutputFolder) - } - } - - private fun TaskContainer.composeJavadocInputs(allowInternalJavadoc: Boolean): List { - val inputs = mutableListOf() - if (allowInternalJavadoc) { - inputs.add(javadocTask()) - } else { - inputs.add(javadocTask(ExcludeInternalDoclet.taskName)) - } - inputs.addAll(includedInputs) - return inputs - } - - private fun TaskContainer.registerCopyDokka() { - val inputs = composeDokkaInputs() - - register(copyDokka, Copy::class.java) { - inputs.forEach { from(it) } - into(dokkaOutputFolder) - } - } - - private fun TaskContainer.composeDokkaInputs(): List { - val inputs = mutableListOf() - - dokkaHtmlTask()?.let { - inputs.add(it) - } - inputs.addAll(includedInputs) - - return inputs - } - - private fun TaskContainer.registerUpdateTask(): TaskProvider { - return register(updateGitHubPages) { - doLast { - try { - updateGhPages(project) - } finally { - cleanup() - } - } - } - } - - private fun cleanup() { - val folders = listOf(dokkaOutputFolder, javadocOutputFolder) - folders.forEach { - it.toFile().deleteRecursively() - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPagesExtension.kt b/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPagesExtension.kt deleted file mode 100644 index 90eebc2..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/github/pages/UpdateGitHubPagesExtension.kt +++ /dev/null @@ -1,131 +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.gradle.github.pages - -import java.io.File -import org.gradle.api.Project -import org.gradle.api.provider.Property -import org.gradle.api.provider.SetProperty -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.getByType -import org.gradle.kotlin.dsl.property - -/** - * Configures the `updateGitHubPages` extension. - */ -@Suppress("unused") -fun Project.updateGitHubPages(excludeInternalDocletVersion: String, - action: UpdateGitHubPagesExtension.() -> Unit) { - apply() - - val extension = extensions.getByType(UpdateGitHubPagesExtension::class) - extension.excludeInternalDocletVersion = excludeInternalDocletVersion - extension.action() -} - -/** - * The extension for configuring the [UpdateGitHubPages] plugin. - */ -class UpdateGitHubPagesExtension -private constructor( - - /** - * Tells whether the types marked `@Internal` should be included into - * the doc generation. - */ - val allowInternalJavadoc: Property, - - /** - * The root folder of the repository to which the updated `Project` belongs. - */ - var rootFolder: Property, - - /** - * The external inputs, which output should be included into - * the GitHub Pages update. - * - * The values are interpreted according to - * [org.gradle.api.tasks.Copy.from] specification. - * - * This property is optional. - */ - var includeInputs: SetProperty -) { - - /** - * The version of the - * [ExcludeInternalDoclet][io.spine.gradle.javadoc.ExcludeInternalDoclet] - * used when updating documentation at GitHub Pages. - * - * This value is used when adding dependency on the doclet when the plugin tasks - * are registered. Since the doclet dependency is required, its value passed as - * a parameter for the extension, rather than a property. - */ - internal lateinit var excludeInternalDocletVersion: String - - internal companion object { - - /** The name of the extension. */ - const val name = "updateGitHubPages" - - /** Creates a new extension and adds it to the passed project. */ - fun createIn(project: Project): UpdateGitHubPagesExtension { - val factory = project.objects - val result = UpdateGitHubPagesExtension( - allowInternalJavadoc = factory.property(Boolean::class), - rootFolder = factory.property(File::class), - includeInputs = factory.setProperty(Any::class.java) - ) - project.extensions.add(result.javaClass, name, result) - return result - } - } - - /** - * Returns `true` if the `@Internal`-annotated code should be included into the - * generated documentation, `false` otherwise. - */ - fun allowInternalJavadoc(): Boolean { - return allowInternalJavadoc.get() - } - - /** - * Returns the local root folder of the repository, to which the handled Gradle - * Project belongs. - */ - fun rootFolder(): File { - return rootFolder.get() - } - - /** - * Returns the external inputs, which results should be included into the - * GitHub Pages update. - */ - fun includedInputs(): Set { - return includeInputs.get() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/Encoding.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/Encoding.kt deleted file mode 100644 index 052a1aa..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/Encoding.kt +++ /dev/null @@ -1,32 +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.gradle.javadoc - -/** - * The encoding to use in Javadoc processing. - */ -data class Encoding(val name: String) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt deleted file mode 100644 index c42c65c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/ExcludeInternalDoclet.kt +++ /dev/null @@ -1,115 +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.gradle.javadoc - -import io.spine.dependency.local.ToolBase -import io.spine.gradle.javadoc.ExcludeInternalDoclet.Companion.taskName -import io.spine.gradle.sourceSets -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.api.tasks.javadoc.Javadoc -import org.gradle.external.javadoc.StandardJavadocDocletOptions - -/** - * The doclet which removes Javadoc for `@Internal` things in the Java code. - */ -@Suppress("ConstPropertyName") -class ExcludeInternalDoclet { - - private val dependency = ToolBase.JavadocFilter.artifact - - companion object { - - /** - * The name of the custom configuration in scope of which the exclusion of - * `@Internal` types is performed. - */ - private const val configurationName = "excludeInternalDoclet" - - /** - * The fully-qualified class name of the doclet. - */ - const val className = "io.spine.tools.javadoc.ExcludeInternalDoclet" - - /** - * The name of the helper task which configures the Javadoc processing - * to exclude `@Internal` types. - */ - const val taskName = "noInternalJavadoc" - - private fun createConfiguration(project: Project): Configuration { - return project.configurations.create(configurationName) - } - } - - /** - * Creates a custom Javadoc task for the [project] which excludes the types - * annotated as `@Internal`. - * - * The task is registered under [taskName]. - */ - fun registerTaskIn(project: Project) { - val configuration = addTo(project) - project.appendCustomJavadocTask(configuration) - } - - /** - * Creates a configuration for the doclet in the given project and adds it to its dependencies. - * - * @return added configuration - */ - private fun addTo(project: Project): Configuration { - val configuration = createConfiguration(project) - project.dependencies.add(configuration.name, dependency) - return configuration - } -} - -private fun Project.appendCustomJavadocTask(excludeInternalDoclet: Configuration) { - val javadocTask = tasks.javadocTask() - tasks.register(taskName, Javadoc::class.java) { - - source = sourceSets.getByName("main").allJava.filter { - !it.absolutePath.contains("generated") - }.asFileTree - - classpath = javadocTask.classpath - - options { - encoding = JavadocConfig.encoding.name - - // Doclet fully qualified name. - doclet = ExcludeInternalDoclet.className - - // Path to the JAR containing the doclet. - docletpath = excludeInternalDoclet.files.toList() - } - - val docletOptions = options as StandardJavadocDocletOptions - JavadocConfig.registerCustomTags(docletOptions) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt deleted file mode 100644 index 9616e99..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocConfig.kt +++ /dev/null @@ -1,160 +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.gradle.javadoc - -import io.spine.gradle.javadoc.JavadocConfig.tags -import java.io.File -import org.gradle.api.JavaVersion -import org.gradle.api.Project -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.javadoc.Javadoc -import org.gradle.external.javadoc.StandardJavadocDocletOptions -import productionModules - -/** - * Finds a [Javadoc] Gradle task by the passed name. - */ -fun TaskContainer.javadocTask(named: String) = this.getByName(named) as Javadoc - -/** - * Finds a default [Javadoc] Gradle task. - */ -fun TaskContainer.javadocTask() = this.getByName("javadoc") as Javadoc - -/** - * Javadoc processing settings. - * - * This type is named with `Config` suffix to avoid its confusion with the standard `Javadoc` type. - */ -@Suppress("unused") -object JavadocConfig { - - /** - * Link to the documentation for Java 11 Standard Library API. - * - * Oracle JDK SE 11 is used for the reference. - */ - private const val standardLibraryAPI = "https://docs.oracle.com/en/java/javase/11/docs/api/" - - @Suppress("MemberVisibilityCanBePrivate") // opened to be visible from docs. - val tags = listOf( - JavadocTag("apiNote", "API Note"), - JavadocTag("implSpec", "Implementation Requirements"), - JavadocTag("implNote", "Implementation Note") - ) - - val encoding = Encoding("UTF-8") - - fun applyTo(project: Project) { - val javadocTask = project.tasks.javadocTask() - if (!isProductionModule(project)) { - javadocTask.enabled = false - return - } - discardJavaModulesInLinks(javadocTask) - val docletOptions = javadocTask.options as StandardJavadocDocletOptions - configureDoclet(docletOptions) - } - - private fun isProductionModule(project: Project) = project.run { - rootProject.productionModules.contains(this) - } - - /** - * Discards using of Java 9 modules in URL links generated by Javadoc for our codebase. - * - * This fixes navigation to classes through the search results. - * - * The issue appeared after migration to Java 11. When Javadoc is generated for a project - * that does not declare Java 9 modules, search results contain broken links with appended - * `undefined` prefix to the URL. This `undefined` was meant to be a name of a Java 9 module. - * - * See: [Issue #334](https://github.com/SpineEventEngine/config/issues/334) - */ - private fun discardJavaModulesInLinks(javadoc: Javadoc) { - - // We ask `Javadoc` task to modify "search.js" and override a method, responsible for - // the formation of URL prefixes. We can't specify the option "--no-module-directories", - // because it leads to discarding of all module prefixes in generated links. - // That means links to the types from the standard library would not work, - // as they are declared within modules since Java 9. - - val discardModulePrefix = """ - - getURLPrefix = function(ui) { - return ""; - }; - """.trimIndent() - - javadoc.doLast { - val destinationDir = javadoc.destinationDir!!.absolutePath - val searchScript = File("$destinationDir/search.js") - searchScript.appendText(discardModulePrefix) - } - } - - private fun configureDoclet(docletOptions: StandardJavadocDocletOptions) { - docletOptions.encoding = encoding.name - reduceParamWarnings(docletOptions) - registerCustomTags(docletOptions) - linkStandardLibraryAPI(docletOptions) - } - - /** - * Configures `javadoc` tool to avoid numerous warnings for missing `@param` tags. - * - * As suggested by Stephen Colebourne: - * [https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html] - * - * See also: - * [https://github.com/GPars/GPars/blob/master/build.gradle#L268] - */ - private fun reduceParamWarnings(docletOptions: StandardJavadocDocletOptions) { - if (JavaVersion.current().isJava8Compatible) { - docletOptions.addStringOption("Xdoclint:none", "-quiet") - } - } - - /** - * Registers custom [tags] for the passed doclet options. - */ - fun registerCustomTags(docletOptions: StandardJavadocDocletOptions) { - docletOptions.tags = tags.map { it.toString() } - } - - /** - * Links the documentation for Java 11 Standard Library API. - * - * This documentation is used to be referenced to when navigating to the types from the - * standard library (`String`, `List`, etc.). - * - * OpenJDK SE 11 is used for the reference. - */ - private fun linkStandardLibraryAPI(docletOptions: StandardJavadocDocletOptions) { - docletOptions.addStringOption("link", standardLibraryAPI) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocTag.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocTag.kt deleted file mode 100644 index a6224a5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javadoc/JavadocTag.kt +++ /dev/null @@ -1,37 +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.gradle.javadoc - -/** - * The Javadoc tag. - */ -class JavadocTag(val name: String, val title: String) { - - override fun toString(): String { - return "${name}:a:${title}:" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsContext.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsContext.kt deleted file mode 100644 index ec5d872..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsContext.kt +++ /dev/null @@ -1,62 +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.gradle.javascript - -import java.io.File -import org.gradle.api.Project -import org.gradle.kotlin.dsl.support.serviceOf -import org.gradle.process.ExecOperations - -/** - * Provides access to the current [JsEnvironment] and shortcuts for running `npm` tool. - */ -open class JsContext(jsEnv: JsEnvironment, internal val project: Project) - : JsEnvironment by jsEnv -{ - /** - * Executes `npm` command in a separate process. - * - * [JsEnvironment.projectDir] is used as a working directory. - */ - fun npm(vararg args: String) = projectDir.npm(*args) - - /** - * Executes `npm` command in a separate process. - * - * This [File] is used as a working directory. - */ - fun File.npm(vararg args: String) = project.serviceOf().exec { - workingDir(this@npm) - commandLine(npmExecutable) - args(*args) - - // Using private packages in a CI/CD workflow | npm Docs - // https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow - - environment["NPM_TOKEN"] = npmAuthToken - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsEnvironment.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsEnvironment.kt deleted file mode 100644 index c2dc68e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsEnvironment.kt +++ /dev/null @@ -1,255 +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.gradle.javascript - -import java.io.File -import org.apache.tools.ant.taskdefs.condition.Os - -/** - * Describes the environment in which JavaScript code is assembled and processed during the build. - * - * Consists of three parts describing: - * - * 1. A module itself. - * 2. Tools and their input/output files. - * 3. Code generation. - */ -interface JsEnvironment { - - /* - * A module itself - ******************/ - - /** - * Module's root catalog. - */ - val projectDir: File - - /** - * Module's version. - */ - val moduleVersion: String - - /** - * Module's production sources directory. - * - * Default value: "$projectDir/main". - */ - val srcDir: File - get() = projectDir.resolve("main") - - /** - * Module's test sources directory. - * - * Default value: "$projectDir/test". - */ - val testSrcDir: File - get() = projectDir.resolve("test") - - /** - * A directory which all artifacts are generated into. - * - * Default value: "$projectDir/build". - */ - val buildDir: File - get() = projectDir.resolve("build") - - /** - * A directory where artifacts for further publishing would be prepared. - * - * Default value: "$buildDir/npm-publication". - */ - val publicationDir: File - get() = buildDir.resolve("npm-publication") - - /* - * Tools and their input/output files - *************************************/ - - /** - * Name of an executable for running `npm`. - * - * Default value: - * - * 1. "nmp.cmd" for Windows. - * 2. "npm" for other OSs. - */ - val npmExecutable: String - get() = if (isWindows()) "npm.cmd" else "npm" - - /** - * An access token that allows installation and/or publishing modules. - * - * During installation a token is required only if dependencies from private - * repositories are used. - * - * Default value is read from the environmental variable - `NPM_TOKEN`. - * "PUBLISHING_FORBIDDEN" stub value would be assigned in case `NPM_TOKEN` variable is not set. - * - * See [Creating and viewing access tokens | npm Docs](https://docs.npmjs.com/creating-and-viewing-access-tokens). - */ - val npmAuthToken: String - get() = System.getenv("NPM_TOKEN") ?: "PUBLISHING_FORBIDDEN" - - /** - * A directory where `npm` puts downloaded module's dependencies. - * - * Default value: "$projectDir/node_modules". - */ - val nodeModules: File - get() = projectDir.resolve("node_modules") - - /** - * Module's descriptor used by `npm`. - * - * Default value: "$projectDir/package.json". - */ - val packageJson: File - get() = projectDir.resolve("package.json") - - /** - * `npm` gets its configuration settings from the command line, environment variables, - * and `npmrc` file. - * - * Default value: "$projectDir/.npmrc". - * - * See [npmrc | npm Docs](https://docs.npmjs.com/cli/v8/configuring-npm/npmrc). - */ - val npmrc: File - get() = projectDir.resolve(".npmrc") - - /** - * A cache directory in which `nyc` tool outputs raw coverage report. - * - * Default value: "$projectDir/.nyc_output". - * - * See [istanbuljs/nyc](https://github.com/istanbuljs/nyc). - */ - val nycOutput: File - get() = projectDir.resolve(".nyc_output") - - /** - * A directory in which `webpack` would put a ready-to-use bundle. - * - * Default value: "$projectDir/dist" - * - * See [webpack - npm](https://www.npmjs.com/package/webpack). - */ - val webpackOutput: File - get() = projectDir.resolve("dist") - - /** - * A directory where bundled artifacts for further publishing would be prepared. - * - * Default value: "$publicationDir/dist". - */ - val webpackPublicationDir: File - get() = publicationDir.resolve("dist") - - /* - * Code generation - ******************/ - - /** - * Name of a directory that contains generated code. - * - * Default value: "proto". - */ - val genProtoDirName: String - get() = "proto" - - /** - * Directory with production Protobuf messages compiled into JavaScript. - * - * Default value: "$srcDir/$genProtoDirName". - */ - val genProtoMain: File - get() = srcDir.resolve(genProtoDirName) - - /** - * Directory with test Protobuf messages compiled into JavaScript. - * - * Default value: "$testSrcDir/$genProtoDirName". - */ - val genProtoTest: File - get() = testSrcDir.resolve(genProtoDirName) -} - -/** - * Allows overriding [JsEnvironment]'s defaults. - * - * All of declared properties can be split into two groups: - * - * 1. The ones that *define* something - can be overridden. - * 2. The ones that *describe* something - can NOT be overridden. - * - * Overriding a "defining" property affects the way `npm` tool works. - * In contrary, overriding a "describing" property does not affect the tool. - * Such properties just describe how the used tool works. - * - * Therefore, overriding of "describing" properties leads to inconsistency with expectations. - * - * The next properties could not be overridden: - * - * 1. [JsEnvironment.nodeModules]. - * 2. [JsEnvironment.packageJson]. - * 3. [JsEnvironment.npmrc]. - * 4. [JsEnvironment.nycOutput]. - */ -class ConfigurableJsEnvironment(initialEnvironment: JsEnvironment) - : JsEnvironment by initialEnvironment -{ - /* - * A module itself - ******************/ - - override var projectDir = initialEnvironment.projectDir - override var moduleVersion = initialEnvironment.moduleVersion - override var srcDir = initialEnvironment.srcDir - override var testSrcDir = initialEnvironment.testSrcDir - override var buildDir = initialEnvironment.buildDir - override var publicationDir = initialEnvironment.publicationDir - - /* - * Tools and their input/output files - *************************************/ - - override var npmExecutable = initialEnvironment.npmExecutable - override var npmAuthToken = initialEnvironment.npmAuthToken - override var webpackOutput = initialEnvironment.webpackOutput - override var webpackPublicationDir = initialEnvironment.webpackPublicationDir - - /* - * Code generation - ******************/ - - override var genProtoDirName = initialEnvironment.genProtoDirName - override var genProtoMain = initialEnvironment.genProtoMain - override var genProtoTest = initialEnvironment.genProtoTest -} - -internal fun isWindows(): Boolean = Os.isFamily(Os.FAMILY_WINDOWS) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsExtension.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsExtension.kt deleted file mode 100644 index 69c3e26..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/JsExtension.kt +++ /dev/null @@ -1,194 +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.gradle.javascript - -import io.spine.gradle.javascript.plugin.JsPlugins -import io.spine.gradle.javascript.task.JsTasks -import org.gradle.api.Project -import org.gradle.kotlin.dsl.create -import org.gradle.kotlin.dsl.extra -import org.gradle.kotlin.dsl.findByType - -/** - * Configures [JsExtension] that facilitates configuration of Gradle tasks and plugins - * to build JavaScripts projects. - * - * The whole structure of the extension looks as follows: - * - * ``` - * javascript { - * environment { - * // ... - * } - * tasks { - * // ... - * } - * plugins { - * // ... - * } - * } - * ``` - * - * ### Environment - * - * One of the main features of this extension is [JsEnvironment]. Environment describes a module - * itself, used tools with their input/output files, code generation. - * - * The extension is shipped with a pre-configured environment. So, no pre-configuration is required. - * Most properties in [JsEnvironment] have calculated defaults right in the interface. - * Only two properties need explicit override. - * - * The extension defines them as follows: - * - * 1. [JsEnvironment.projectDir] –> `project.projectDir`. - * 2. [JsEnvironment.moduleVersion] —> `project.extra["versionToPublishJs"]`. - * - * There are two ways to modify the environment: - * - * 1. Update [JsEnvironment] directly. Go with this option when it is a global change - * that should affect all projects which use this extension. - * 2. Use [JsExtension.environment] scope — for temporary and custom overridings. - * - * An example of a property overriding: - * - * ``` - * javascript { - * environment { - * moduleVersion = "$moduleVersion-SPECIAL_EDITION" - * } - * } - * ``` - * - * Please note, environment should be set up firstly to have the effect on the parts - * of the extension that use it. - * - * ### Tasks and Plugins - * - * The spirit of tasks configuration in this extension is extracting the code that defines and - * registers tasks into extension functions upon `JsTasks` in `buildSrc`. Those extensions should be - * named after a task it registers or a task group if several tasks are registered at once. - * Then this extension is called in a project's `build.gradle.kts`. - * - * `JsTasks` and `JsPlugins` scopes extend [JsContext] which provides access - * to the current [JsEnvironment] and shortcuts for running `npm` tool. - * - * Below is the simplest example of how to create a primitive `printNpmVersion` task. - * - * Firstly, a corresponding extension function should be defined in `buildSrc`: - * - * ``` - * fun JsTasks.printNpmVersion() = - * register("printNpmVersion") { - * doLast { - * npm("--version") - * } - * } - * ``` - * - * Secondly, in a project's `build.gradle.kts` this extension is called: - * - * ``` - * javascript { - * tasks { - * printNpmVersion() - * } - * } - * ``` - * - * An extension function is not restricted to register exactly one task. If several tasks can - * be grouped into a logical bunch, they should be registered together: - * - * ``` - * fun JsTasks.build() { - * assembleJs() - * testJs() - * generateCoverageReport() - * } - * - * private fun JsTasks.assembleJs() = ... - * - * private fun JsTasks.testJs() = ... - * - * private fun JsTasks.generateCoverageReport() = ... - * ``` - * - * This section is mostly dedicated to tasks. But tasks and plugins are configured - * in a very similar way. So, everything above is also applicable to plugins. More detailed - * guides can be found in docs to `JsTasks` and `JsPlugins`. - * - * @see [ConfigurableJsEnvironment] - * @see [JsTasks] - * @see [JsPlugins] - */ -fun Project.javascript(configuration: JsExtension.() -> Unit) { - extensions.run { - configuration.invoke( - findByType() ?: create("jsExtension", project) - ) - } -} - -/** - * Scope for performing JavaScript-related configuration. - * - * @see [javascript] - */ -open class JsExtension(internal val project: Project) { - - private val configurableEnvironment = ConfigurableJsEnvironment( - object : JsEnvironment { - override val projectDir = project.projectDir - override val moduleVersion = project.extra["versionToPublishJs"].toString() - } - ) - - val environment: JsEnvironment = configurableEnvironment - val tasks: JsTasks = JsTasks(environment, project) - val plugins: JsPlugins = JsPlugins(environment, project) - - /** - * Overrides default values of [JsEnvironment]. - * - * Please note, environment should be set up firstly to have the effect on the parts - * of the extension that use it. - */ - fun environment(overridings: ConfigurableJsEnvironment.() -> Unit) = - configurableEnvironment.run(overridings) - - /** - * Configures [JavaScript-related tasks][JsTasks]. - */ - fun tasks(configurations: JsTasks.() -> Unit) = - tasks.run(configurations) - - /** - * Configures [JavaScript-related plugins][JsPlugins]. - */ - fun plugins(configurations: JsPlugins.() -> Unit) = - plugins.run(configurations) - -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Idea.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Idea.kt deleted file mode 100644 index 087dd25..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Idea.kt +++ /dev/null @@ -1,64 +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.gradle.javascript.plugin - -import org.gradle.kotlin.dsl.configure -import org.gradle.plugins.ide.idea.model.IdeaModel - -/** - * Applies and configures `idea` plugin to work with a JavaScript module. - * - * In particular, this method: - * - * 1. Specifies directories for production and test sources. - * 2. Excludes directories with generated code and build artifacts. - * - * @see JsPlugins - */ -fun JsPlugins.idea() { - - plugins { - apply("org.gradle.idea") - } - - extensions.configure { - - module { - sourceDirs.add(srcDir) - testSources.from(testSrcDir) - - excludeDirs.addAll( - listOf( - nodeModules, - nycOutput, - genProtoMain, - genProtoTest - ) - ) - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/JsPlugins.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/JsPlugins.kt deleted file mode 100644 index b478f64..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/JsPlugins.kt +++ /dev/null @@ -1,92 +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.gradle.javascript.plugin - -import io.spine.gradle.javascript.JsContext -import io.spine.gradle.javascript.JsEnvironment -import org.gradle.api.Project -import org.gradle.api.plugins.ExtensionContainer -import org.gradle.api.plugins.PluginContainer -import org.gradle.api.tasks.TaskContainer - -/** - * A scope for applying and configuring JavaScript-related plugins. - * - * The scope extends [JsContext] and provides shortcuts for key project's containers: - * - * 1. [plugins]. - * 2. [extensions]. - * 3. [tasks]. - * - * Let's imagine one wants to apply and configure `FooBar` plugin. To do that, several steps - * should be completed: - * - * 1. Declare the corresponding extension function upon [JsPlugins] named after the plugin. - * 2. Apply and configure the plugin inside that function. - * 3. Call the resulted extension in your `build.gradle.kts` file. - * - * Here's an example of `javascript/plugin/FooBar.kt`: - * - * ``` - * fun JsPlugins.fooBar() { - * plugins.apply("com.fooBar") - * extensions.configure { - * // ... - * } - * } - * ``` - * - * And here's how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.plugins.fooBar - * - * // ... - * - * javascript { - * plugins { - * fooBar() - * } - * } - * ``` - */ -class JsPlugins(jsEnv: JsEnvironment, project: Project) : JsContext(jsEnv, project) { - - internal val plugins = project.plugins - internal val extensions = project.extensions - internal val tasks = project.tasks - - internal fun plugins(configurations: PluginContainer.() -> Unit) = - plugins.run(configurations) - - internal fun extensions(configurations: ExtensionContainer.() -> Unit) = - extensions.run(configurations) - - internal fun tasks(configurations: TaskContainer.() -> Unit) = - tasks.run(configurations) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/McJs.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/McJs.kt deleted file mode 100644 index 2efa4a4..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/McJs.kt +++ /dev/null @@ -1,63 +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.gradle.javascript.plugin - -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.kotlin.dsl.withGroovyBuilder - -/** - * Applies `mc-js` plugin and specifies directories for generated code. - * - * @see JsPlugins - */ -fun JsPlugins.mcJs() { - - plugins { - apply("io.spine.mc-js") - } - - // Temporarily use GroovyInterop. - // Currently, it is not possible to obtain `McJsPlugin` on the classpath of `buildSrc`. - // See issue: https://github.com/SpineEventEngine/config/issues/298 - - project.withGroovyBuilder { - "protoJs" { - setProperty("generatedMainDir", genProtoMain) - setProperty("generatedTestDir", genProtoTest) - } - } -} - -/** - * Locates `generateJsonParsers` in this [TaskContainer]. - * - * The task generates JSON-parsing code for JavaScript messages compiled from Protobuf. - */ -val TaskContainer.generateJsonParsers: TaskProvider - get() = named("generateJsonParsers") diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Protobuf.kt deleted file mode 100644 index c1c2d64..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/plugin/Protobuf.kt +++ /dev/null @@ -1,86 +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.gradle.javascript.plugin - -import com.google.protobuf.gradle.ProtobufExtension -import com.google.protobuf.gradle.id -import com.google.protobuf.gradle.remove -import io.spine.dependency.lib.Protobuf - -/** - * Applies and configures `protobuf` plugin to work with a JavaScript module. - * - * In particular, this method: - * - * 1. Specifies an executable for `protoc` compiler. - * 2. Configures `GenerateProtoTask`. - * - * @see JsPlugins - */ -fun JsPlugins.protobuf() { - - plugins { - apply(Protobuf.GradlePlugin.id) - } - - val protobufExt = project.extensions.getByType(ProtobufExtension::class.java) - protobufExt.apply { - - protoc { - artifact = Protobuf.compiler - } - - generateProtoTasks { - all().forEach { task -> - - task.builtins { - - // Do not use java builtin output in this project. - - remove("java") - - // For information on JavaScript code generation please see - // https://github.com/google/protobuf/blob/master/js/README.md - - id("js") { - option("import_style=commonjs") - outputSubDir = genProtoDirName - } - } - - val sourceSet = task.sourceSet.name - val testClassifier = if (sourceSet == "test") "_test" else "" - val artifact = "${project.group}_${project.name}_${moduleVersion}" - val descriptor = "$artifact$testClassifier.desc" - - task.generateDescriptorSet = true - task.descriptorSetOptions.path = - "${projectDir}/build/descriptors/${sourceSet}/${descriptor}" - } - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Assemble.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Assemble.kt deleted file mode 100644 index 4b57a4e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Assemble.kt +++ /dev/null @@ -1,205 +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.gradle.javascript.task - -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.ObjectNode -import com.google.protobuf.gradle.GenerateProtoTask -import io.spine.gradle.TaskName -import io.spine.gradle.base.assemble -import io.spine.gradle.javascript.plugin.generateJsonParsers -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.kotlin.dsl.withType - -/** - * Registers tasks for assembling JavaScript artifacts. - * - * Please note, this task group depends on [mc-js][io.spine.gradle.javascript.plugin.mcJs] - * and [protobuf][io.spine.gradle.javascript.plugin.protobuf]` plugins. Therefore, - * these plugins should be applied in the first place. - * - * List of tasks to be created: - * - * 1. [TaskContainer.assembleJs]. - * 2. [TaskContainer.compileProtoToJs]. - * 3. [TaskContainer.installNodePackages]. - * 4. [TaskContainer.updatePackageVersion]. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.assemble - * - * // ... - * - * javascript { - * tasks { - * assemble() - * } - * } - * ``` - * - * @param configuration any additional configuration related to the module's assembling. - */ -fun JsTasks.assemble(configuration: JsTasks.() -> Unit = {}) { - - installNodePackages() - - compileProtoToJs().also { - generateJsonParsers.configure { - dependsOn(it) - } - } - - updatePackageVersion() - - assembleJs().also { - assemble.configure { - dependsOn(it) - } - } - - configuration() -} - -private val assembleJsName = TaskName.of("assembleJs") - -/** - * Locates `assembleJs` task in this [TaskContainer]. - * - * It is a lifecycle task that produces consumable JavaScript artifacts. - */ -val TaskContainer.assembleJs: TaskProvider - get() = named(assembleJsName) - -private fun JsTasks.assembleJs() = - register(assembleJsName) { - - description = "Assembles JavaScript sources into consumable artifacts." - group = JsTasks.Group.assemble - - dependsOn( - installNodePackages, - compileProtoToJs, - updatePackageVersion, - generateJsonParsers - ) - } - -private val compileProtoToJsName = TaskName.of("compileProtoToJs") - -/** - * Locates `compileProtoToJs` task in this [TaskContainer]. - * - * The task is responsible for compiling Protobuf messages into JavaScript. It aggregates the tasks - * provided by `protobuf` plugin that perform actual compilation. - */ -val TaskContainer.compileProtoToJs: TaskProvider - get() = named(compileProtoToJsName) - -private fun JsTasks.compileProtoToJs() = - register(compileProtoToJsName) { - - description = "Compiles Protobuf messages into JavaScript." - group = JsTasks.Group.assemble - - withType() - .forEach { dependsOn(it) } - } - -private val installNodePackagesName = TaskName.of("installNodePackages") - -/** - * Locates `installNodePackages` task in this [TaskContainer]. - * - * The task installs Node packages which this module depends on using `npm install` command. - * - * The `npm install` command is executed with the vulnerability check disabled since - * it cannot fail the task execution despite on vulnerabilities found. - * - * To check installed Node packages for vulnerabilities execute - * [TaskContainer.auditNodePackages] task. - * - * See [npm-install | npm Docs](https://docs.npmjs.com/cli/v8/commands/npm-install). - */ -val TaskContainer.installNodePackages: TaskProvider - get() = named(installNodePackagesName) - -private fun JsTasks.installNodePackages() = - register(installNodePackagesName) { - - description = "Installs module`s Node dependencies." - group = JsTasks.Group.assemble - - inputs.file(packageJson) - outputs.dir(nodeModules) - - doLast { - npm("set", "audit", "false") - npm("install") - } - } - -private val updatePackageVersionName = TaskName.of("updatePackageVersion") - -/** - * Locates `updatePackageVersion` task in this [TaskContainer]. - * - * The task sets the module's version in `package.json` to the value of - * [moduleVersion][io.spine.gradle.javascript.JsEnvironment.moduleVersion] - * specified in the current `JsEnvironment`. - */ -val TaskContainer.updatePackageVersion: TaskProvider - get() = named(updatePackageVersionName) - -private fun JsTasks.updatePackageVersion() = - register(updatePackageVersionName) { - - description = "Sets a module's version in `package.json`." - group = JsTasks.Group.assemble - - doLast { - val objectNode = ObjectMapper() - .readValue(packageJson, ObjectNode::class.java) - .put("version", moduleVersion) - - packageJson.writeText( - - // We are going to stick to JSON formatting used by `npm` itself. - // So that modifying the line with the version would ONLY affect a single line - // when comparing two files i.e. in Git. - - (objectNode.toPrettyString() + '\n') - .replace("\" : ", "\": ") - ) - } - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Check.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Check.kt deleted file mode 100644 index d25c3c2..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Check.kt +++ /dev/null @@ -1,197 +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.gradle.javascript.task - -import io.spine.gradle.TaskName -import io.spine.gradle.base.check -import io.spine.gradle.java.test -import io.spine.gradle.javascript.isWindows -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers tasks for verifying a JavaScript module. - * - * Please note, this task group depends on [assemble] tasks. Therefore, assembling tasks should - * be applied in the first place. - * - * List of tasks to be created: - * - * 1. [TaskContainer.checkJs]. - * 2. [TaskContainer.auditNodePackages]. - * 3. [TaskContainer.testJs]. - * 4. [TaskContainer.coverageJs]. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.assemble - * import io.spine.gradle.javascript.task.check - * - * // ... - * - * javascript { - * tasks { - * assemble() - * check() - * } - * } - * ``` - * - * @param configuration any additional configuration related to the module's verification. - */ -fun JsTasks.check(configuration: JsTasks.() -> Unit = {}) { - - auditNodePackages() - coverageJs() - testJs() - - checkJs().also { - check.configure { - dependsOn(it) - } - } - - configuration() -} - -private val checkJsName = TaskName.of("checkJs") - -/** - * Locates `checkJs` task in this [TaskContainer]. - * - * The task runs tests, audits NPM modules and creates a test-coverage report. - */ -val TaskContainer.checkJs: TaskProvider - get() = named(checkJsName) - -private fun JsTasks.checkJs() = - register(checkJsName) { - - description = "Runs tests, audits NPM modules and creates a test-coverage report." - group = JsTasks.Group.check - - dependsOn( - auditNodePackages, - coverageJs, - testJs, - ) - } - -private val auditNodePackagesName = TaskName.of("auditNodePackages") - -/** - * Locates `auditNodePackages` task in this [TaskContainer]. - * - * The task audits the module dependencies using the `npm audit` command. - * - * The `audit` command submits a description of the dependencies configured in the module - * to a public registry and asks for a report of known vulnerabilities. If any are found, - * then the impact and appropriate remediation will be calculated. - * - * @see npm-audit | npm Docs - */ -val TaskContainer.auditNodePackages: TaskProvider - get() = named(auditNodePackagesName) - -private fun JsTasks.auditNodePackages() = - register(auditNodePackagesName) { - - description = "Audits the module's Node dependencies." - group = JsTasks.Group.check - - inputs.dir(nodeModules) - - doLast { - - // `critical` level is set as the minimum level of vulnerability for `npm audit` - // to exit with a non-zero code. - - npm("set", "audit-level", "critical") - - try { - npm("audit") - } catch (ignored: Exception) { - npm("audit", "--registry", "https://registry.npmjs.eu") - } - } - - dependsOn(installNodePackages) - } - -private val coverageJsName = TaskName.of("coverageJs") - -/** - * Locates `coverageJs` task in this [TaskContainer]. - * - * The task runs the JavaScript tests and collects the code coverage. - */ -val TaskContainer.coverageJs: TaskProvider - get() = named(coverageJsName) - -private fun JsTasks.coverageJs() = - register(coverageJsName) { - - description = "Runs the JavaScript tests and collects the code coverage." - group = JsTasks.Group.check - - outputs.dir(nycOutput) - - doLast { - npm("run", if (isWindows()) "coverage:win" else "coverage:unix") - } - - dependsOn(assembleJs) - } - -private val testJsName = TaskName.of("testJs") - -/** - * Locates `testJs` task in this [TaskContainer]. - * - * The task runs JavaScript tests. - */ -val TaskContainer.testJs: TaskProvider - get() = named(testJsName) - -private fun JsTasks.testJs() = - register(testJsName) { - - description = "Runs JavaScript tests." - group = JsTasks.Group.check - - doLast { - npm("run", "test") - } - - dependsOn(assembleJs) - mustRunAfter(test) - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Clean.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Clean.kt deleted file mode 100644 index c5ff835..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Clean.kt +++ /dev/null @@ -1,124 +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.gradle.javascript.task - -import io.spine.gradle.TaskName -import io.spine.gradle.base.clean -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.tasks.Delete -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers tasks for deleting output of JavaScript builds. - * - * Please note, this task group depends on [assemble] tasks. Therefore, assembling tasks should - * be applied in the first place. - * - * List of tasks to be created: - * - * 1. [TaskContainer.cleanJs]. - * 2. [TaskContainer.cleanGenerated]. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.assemble - * import io.spine.gradle.javascript.task.clean - * - * // ... - * - * javascript { - * tasks { - * assemble() - * clean() - * } - * } - * ``` - */ -fun JsTasks.clean() { - - cleanGenerated() - - cleanJs().also { - clean.configure { - dependsOn(it) - } - } -} - -private val cleanJsName = TaskName.of("cleanJs", Delete::class) - -/** - * Locates `cleanJs` task in this [TaskContainer]. - * - * The task deletes output of `assembleJs` task and output of its dependants. - */ -val TaskContainer.cleanJs: TaskProvider - get() = named(cleanJsName) - -private fun JsTasks.cleanJs() = - register(cleanJsName) { - - description = "Cleans output of `assembleJs` task and output of its dependants." - group = JsTasks.Group.clean - - delete( - assembleJs.map { it.outputs }, - compileProtoToJs.map { it.outputs }, - installNodePackages.map { it.outputs }, - ) - - dependsOn( - cleanGenerated - ) - } - -private val cleanGeneratedName = TaskName.of("cleanGenerated", Delete::class) - -/** - * Locates `cleanGenerated` task in this [TaskContainer]. - * - * The task deletes directories with generated code and reports. - */ -val TaskContainer.cleanGenerated: TaskProvider - get() = named(cleanGeneratedName) - -private fun JsTasks.cleanGenerated() = - register(cleanGeneratedName) { - - description = "Cleans generated code and reports." - group = JsTasks.Group.clean - - delete( - genProtoMain, - genProtoTest, - nycOutput, - ) - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/IntegrationTest.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/IntegrationTest.kt deleted file mode 100644 index 227e33e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/IntegrationTest.kt +++ /dev/null @@ -1,128 +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.gradle.javascript.task - -import io.spine.gradle.TaskName -import io.spine.gradle.base.build -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -private val integrationTestName = TaskName.of("integrationTest") - -/** - * Locates `integrationTest` task in this [TaskContainer]. - * - * The task runs integration tests of the `spine-web` library against - * a sample Spine-based application. - * - * A sample Spine-based application is run from the `test-app` module before integration - * tests and is stopped as the tests complete. - * - * See also: `./integration-tests/README.MD` - */ -val TaskContainer.integrationTest: TaskProvider - get() = named(integrationTestName) - -/** - * Registers [TaskContainer.integrationTest] task. - * - * The task runs integration tests of the `spine-web` library against - * a sample Spine-based application. - * - * Please note, this task depends on [assemble] and `client-js:publishJsLocally` tasks. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.integrationTest - * - * // ... - * - * javascript { - * tasks { - * assemble() - * integrationTest() - * } - * } - * ``` - */ -@Suppress("unused") -fun JsTasks.integrationTest() { - - linkSpineWebModule() - - register(integrationTestName) { - - // Find a way to run the same tests against `spine-web` in `client-js` module - // to recover coverage. - // See issue: https://github.com/SpineEventEngine/web/issues/96 - - description = "Runs integration tests of the `spine-web` library " + - "against the sample application." - group = JsTasks.Group.check - - dependsOn(build, linkSpineWebModule, ":test-app:appBeforeIntegrationTest") - - doLast { - npm("run", "test") - } - - finalizedBy(":test-app:appAfterIntegrationTest") - } -} - -private val linkSpineWebModuleName = TaskName.of("linkSpineWebModule") - -/** - * Locates `linkSpineWebModule` task in this [TaskContainer]. - * - * The task installs unpublished artifact of `spine-web` library as a module dependency. - * - * Creates a symbolic link from globally-installed `spine-web` library to `node_modules` of - * the current project. - * - * See also: [npm-link | npm Docs](https://docs.npmjs.com/cli/v8/commands/npm-link) - */ -val TaskContainer.linkSpineWebModule: TaskProvider - get() = named(linkSpineWebModuleName) - -private fun JsTasks.linkSpineWebModule() = - register(linkSpineWebModuleName) { - - description = "Install unpublished artifact of `spine-web` library as a module dependency." - group = JsTasks.Group.assemble - - dependsOn(":client-js:publishJsLocally") - - doLast { - npm("run", "installLinkedLib") - } - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/JsTasks.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/JsTasks.kt deleted file mode 100644 index 3cf6335..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/JsTasks.kt +++ /dev/null @@ -1,118 +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.gradle.javascript.task - -import io.spine.gradle.javascript.JsContext -import io.spine.gradle.javascript.JsEnvironment -import org.gradle.api.Project -import org.gradle.api.tasks.TaskContainer - -/** - * A scope for registering and configuring JavaScript-related tasks. - * - * The scope provides: - * - * 1. Access to the current [JsContext]. - * 2. Project's [TaskContainer]. - * 3. Default task groups. - * - * Supposing, one needs to create a new task that would participate in building. Let the task name - * be `bundleJs`. To do that, several steps should be completed: - * - * 1. Define the task name and type using [TaskName][io.spine.gradle.TaskName]. - * 2. Create a public typed reference for the task upon [TaskContainer]. It would facilitate - * referencing to the new task, so that external tasks could depend on it. This reference - * should be documented. - * 3. Implement an extension upon [JsTasks] to register the task. - * 4. Call the resulted extension from `build.gradle.kts`. - * - * Here's an example of `bundleJs()` extension: - * - * ``` - * import io.spine.gradle.named - * import io.spine.gradle.register - * import io.spine.gradle.TaskName - * import org.gradle.api.Task - * import org.gradle.api.tasks.TaskContainer - * import org.gradle.api.tasks.Exec - * - * // ... - * - * private val bundleJsName = TaskName.of("bundleJs", Exec::class) - * - * /** - * * Locates `bundleJs` task in this [TaskContainer]. - * * - * * The task bundles JS sources using `webpack` tool. - * */ - * val TaskContainer.bundleJs: TaskProvider - * get() = named(bundleJsName) - * - * fun JsTasks.bundleJs() = - * register(bundleJsName) { - * - * description = "Bundles JS sources using `webpack` tool." - * group = JsTasks.Group.build - * - * // ... - * } - * ``` - * - * And here's how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.bundleJs - * - * // ... - * - * javascript { - * tasks { - * bundleJs() - * } - * } - * ``` - * - * Declaring typed references upon [TaskContainer] is optional. But it is highly encouraged - * to reference other tasks by such extensions instead of hard-typed string values. - */ -class JsTasks(jsEnv: JsEnvironment, project: Project) - : JsContext(jsEnv, project), TaskContainer by project.tasks -{ - /** - * Default task groups for tasks that participate in building a JavaScript module. - * - * @see [org.gradle.api.Task.getGroup] - */ - internal object Group { - const val assemble = "JavaScript/Assemble" - const val check = "JavaScript/Check" - const val clean = "JavaScript/Clean" - const val build = "JavaScript/Build" - const val publish = "JavaScript/Publish" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/LicenseReport.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/LicenseReport.kt deleted file mode 100644 index c3b3a6a..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/LicenseReport.kt +++ /dev/null @@ -1,89 +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.gradle.javascript.task - -import io.spine.gradle.TaskName -import io.spine.gradle.named -import io.spine.gradle.register -import io.spine.gradle.report.license.generateLicenseReport -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers [npmLicenseReport] task for including NPM dependencies into license reports. - * - * The task depends on [generateLicenseReport]. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.clean - * - * // ... - * - * javascript { - * tasks { - * licenseReport() - * } - * } - * ``` - */ -@Suppress("unused") -fun JsTasks.licenseReport() { - npmLicenseReport().also { - generateLicenseReport.configure { - finalizedBy(it) - } - } -} - -private val npmLicenseReportName = TaskName.of("npmLicenseReport") - -/** - * Locates `npmLicenseReport` task in this [TaskContainer]. - * - * The task generates the report on NPM dependencies and their licenses. - */ -val TaskContainer.npmLicenseReport: TaskProvider - get() = named(npmLicenseReportName) - -private fun JsTasks.npmLicenseReport() = - register(npmLicenseReportName) { - - description = "Generates the report on NPM dependencies and their licenses." - group = JsTasks.Group.build - - doLast { - - // The script below generates license report for NPM dependencies and appends it - // to the report for Java dependencies generated by `generateLicenseReport` task. - - npm("run", "license-report") - } - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Publish.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Publish.kt deleted file mode 100644 index 7d1baea..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Publish.kt +++ /dev/null @@ -1,194 +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.gradle.javascript.task - -import io.spine.gradle.TaskName -import io.spine.gradle.named -import io.spine.gradle.publish.publish -import io.spine.gradle.register -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Registers tasks for publishing a JavaScript module. - * - * Please note, this task group depends on [assemble] tasks. Therefore, assembling tasks should - * be applied in the first place. - * - * List of tasks to be created: - * - * 1. [TaskContainer.publishJs]. - * 2. [TaskContainer.publishJsLocally]. - * 3. [TaskContainer.prepareJsPublication]. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.assemble - * import io.spine.gradle.javascript.task.publish - * - * // ... - * - * javascript { - * tasks { - * assemble() - * publish() - * } - * } - * ``` - */ -fun JsTasks.publish() { - - transpileSources() - prepareJsPublication() - publishJsLocally() - - publishJs().also { - publish.configure { - dependsOn(it) - } - } -} - -private val transpileSourcesName = TaskName.of("transpileSources") - -/** - * Locates `transpileSources` task in this [TaskContainer]. - * - * The task transpiles JavaScript sources using Babel before their publishing. - */ -val TaskContainer.transpileSources: TaskProvider - get() = named(transpileSourcesName) - -private fun JsTasks.transpileSources() = - register(transpileSourcesName) { - - description = "Transpiles JavaScript sources using Babel before their publishing." - group = JsTasks.Group.publish - - doLast { - npm("run", "transpile-before-publish") - } - } - -private val prepareJsPublicationName = TaskName.of("prepareJsPublication") - -/** - * Locates `prepareJsPublication` task in this [TaskContainer]. - * - * This is a lifecycle task that prepares the NPM package in - * [publicationDirectory][io.spine.gradle.javascript.JsEnvironment.publicationDir] - * of the current `JsEnvironment`. - */ -val TaskContainer.prepareJsPublication: TaskProvider - get() = named(prepareJsPublicationName) - -private fun JsTasks.prepareJsPublication() = - register(prepareJsPublicationName) { - - description = "Prepares the NPM package for publishing." - group = JsTasks.Group.publish - - // We need to copy two files into a destination directory without overwriting its content. - // Default `Copy` task is not used since it overwrites the content of a destination - // when copying there. - // See issue: https://github.com/gradle/gradle/issues/1012 - - doLast { - project.copy { - from( - packageJson, - npmrc - ) - - into(publicationDir) - } - } - - dependsOn( - assembleJs, - transpileSources - ) - } - -private val publishJsLocallyName = TaskName.of("publishJsLocally") - -/** - * Locates `publishJsLocally` task in this [TaskContainer]. - * - * The task publishes the prepared NPM package locally using `npm link`. - * - * @see npm-link | npm Docs - */ -val TaskContainer.publishJsLocally: TaskProvider - get() = named(publishJsLocallyName) - -private fun JsTasks.publishJsLocally() = - register(publishJsLocallyName) { - - description = "Publishes the NPM package locally with `npm link`." - group = JsTasks.Group.publish - - doLast { - publicationDir.npm("link") - } - - dependsOn(prepareJsPublication) - } - -private val publishJsName = TaskName.of("publishJs") - -/** - * Locates `publishJs` task in this [TaskContainer]. - * - * The task publishes the prepared NPM package from - * [publicationDirectory][io.spine.gradle.javascript.JsEnvironment.publicationDir] - * using `npm publish`. - * - * Please note, in order to publish an NMP package, a valid - * [npmAuthToken][io.spine.gradle.javascript.JsEnvironment.npmAuthToken] should be - * set. If no token is set, a default dummy value is quite enough for the local development. - * - * @see npm-publish | npm Docs - */ -val TaskContainer.publishJs: TaskProvider - get() = named(publishJsName) - -private fun JsTasks.publishJs() = - register(publishJsName) { - - description = "Publishes the NPM package with `npm publish`." - group = JsTasks.Group.publish - - doLast { - publicationDir.npm("publish") - } - - dependsOn(prepareJsPublication) - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Webpack.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Webpack.kt deleted file mode 100644 index 7c82ad7..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javascript/task/Webpack.kt +++ /dev/null @@ -1,108 +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.gradle.javascript.task - -import io.spine.gradle.TaskName -import io.spine.gradle.named -import io.spine.gradle.register -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Configures `assembleJs` task and creates `copyBundledJs` task to work with `webpack` bundler. - * - * Please note, this task group depends on [assemble] and [publish] tasks. Therefore, those tasks - * should be applied in the first place. - * - * In particular, this method: - * - * 1. Extends `assembleJs` task to bundle sources during assembling. - * 2. Creates `copyBundledJs` task and binds it to `prepareJsPublication` task execution. - * - * Here's an example of how to apply it in `build.gradle.kts`: - * - * ``` - * import io.spine.gradle.javascript.javascript - * import io.spine.gradle.javascript.task.assemble - * import io.spine.gradle.javascript.task.publish - * import io.spine.gradle.javascript.task.webpack - * - * // ... - * - * javascript { - * tasks { - * assemble() - * publish() - * webpack() - * } - * } - * ``` - */ -@Suppress("unused") -fun JsTasks.webpack() { - - assembleJs.configure { - - outputs.dir(webpackOutput) - - doLast { - npm("run", "build") - npm("run", "build-dev") - } - } - - // Temporarily don't publish a bundle. - // See: https://github.com/SpineEventEngine/web/issues/61 - - copyBundledJs()/*.also { - prepareJsPublication.configure { - dependsOn(it) - } - }*/ -} - -private val copyBundledJsName = TaskName.of("copyBundledJs", Copy::class) - -/** - * Locates `copyBundledJs` task in this [TaskContainer]. - * - * The task copies bundled JavaScript sources to the publication directory. - */ -@Suppress("unused") -val TaskContainer.copyBundledJs: TaskProvider - get() = named(copyBundledJsName) - -private fun JsTasks.copyBundledJs() = - register(copyBundledJsName) { - - description = "Copies bundled JavaScript sources to the NPM publication directory." - group = JsTasks.Group.publish - - from(assembleJs.map { it.outputs }) - into(webpackPublicationDir) - } diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt deleted file mode 100644 index 1492075..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CheckVersionIncrement.kt +++ /dev/null @@ -1,147 +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.gradle.publish - -import com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES -import com.fasterxml.jackson.dataformat.xml.XmlMapper -import io.spine.gradle.repo.Repository -import java.io.FileNotFoundException -import java.net.URI -import java.net.URL -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.Project -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.TaskAction - -/** - * A task which verifies that the current version of the library has not been published to the given - * Maven repository yet. - */ -open class CheckVersionIncrement : DefaultTask() { - - /** - * The Maven repository in which to look for published artifacts. - * - * We check both the `releases` and `snapshots` repositories. Artifacts in either of these repos - * may not be overwritten. - */ - @Input - lateinit var repository: Repository - - @Input - val version: String = project.version as String - - @TaskAction - fun fetchAndCheck() { - val artifact = "${project.artifactPath()}/${MavenMetadata.FILE_NAME}" - val snapshots = repository.target(snapshots = true) - checkInRepo(snapshots, artifact) - - if (!repository.hasOneTarget()) { - checkInRepo(repository.target(snapshots = false), artifact) - } - } - - private fun checkInRepo(repoUrl: String, artifact: String) { - val metadata = fetch(repoUrl, artifact) - val versions = metadata?.versioning?.versions - val versionExists = versions?.contains(version) ?: false - if (versionExists) { - throw GradleException( - """ - The version `$version` is already published to the Maven repository `$repoUrl`. - Try incrementing the library version. - All available versions are: ${versions?.joinToString(separator = ", ")}. - - To disable this check, run Gradle with `-x $name`. - """.trimIndent() - ) - } - } - - private fun fetch(repository: String, artifact: String): MavenMetadata? { - val url = URI("$repository/$artifact").toURL() - return MavenMetadata.fetchAndParse(url) - } - - private fun Project.artifactPath(): String { - val group = this.group as String - val name = "${artifactPrefix()}${this.name}" - - val pathElements = ArrayList(group.split('.')) - pathElements.add(name) - val path = pathElements.joinToString(separator = "/") - return path - } - - /** - * Returns the artifact prefix used for the publishing of this project. - * - * All current Spine modules should be using `SpinePublishing`. - * Therefore, the corresponding extension should be present in the root project. - * However, just in case, we define the "standard" prefix here as well. - * - * This value MUST be the same as defined by the defaults in `SpinePublishing`. - */ - private fun Project.artifactPrefix(): String { - val ext = rootProject.extensions.findByType(SpinePublishing::class.java) - val result = ext?.artifactPrefix ?: SpinePublishing.DEFAULT_PREFIX - return result - } -} - -private data class MavenMetadata(var versioning: Versioning = Versioning()) { - - companion object { - - const val FILE_NAME = "maven-metadata.xml" - - private val mapper = XmlMapper() - - init { - mapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false) - } - - /** - * Fetches the metadata for the repository and parses the document. - * - *

If the document could not be found, assumes that the module was never - * released and thus has no metadata. - */ - fun fetchAndParse(url: URL): MavenMetadata? { - return try { - val metadata = mapper.readValue(url, MavenMetadata::class.java) - metadata - } catch (_: FileNotFoundException) { - null - } - } - } -} - -private data class Versioning(var versions: List = listOf()) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt deleted file mode 100644 index 624f5cb..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CloudRepo.kt +++ /dev/null @@ -1,69 +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.gradle.publish - -import io.spine.gradle.repo.Repository - -/** - * CloudRepo Maven repository. - * - * There is a special treatment for this repository. Usually, fetching and publishing of artifacts - * is performed via the same URL. But it is not true for CloudRepo. Fetching is performed via - * the public repository and publishing via the private one. Their URLs differ in `/public` infix. - */ -@Deprecated(message = "Please use `PublishingRepos.cloudArtifactRegistry` instead.") -internal object CloudRepo { - - private const val name = "CloudRepo" - private const val credentialsFile = "cloudrepo.properties" - private const val publicUrl = "https://spine.mycloudrepo.io/public/repositories" - private val privateUrl = publicUrl.replace("/public", "") - - /** - * CloudRepo repository for fetching of artifacts. - * - * Use this instance to depend on artifacts from this repository. - */ - val published = Repository( - name = name, - releases = "$publicUrl/releases", - snapshots = "$publicUrl/snapshots", - credentialsFile = credentialsFile - ) - - /** - * CloudRepo repository for publishing of artifacts. - * - * Use this instance to push new artifacts to this repository. - */ - val destination = Repository( - name = name, - releases = "$privateUrl/releases", - snapshots = "$privateUrl/snapshots", - credentialsFile = credentialsFile - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt deleted file mode 100644 index 152455d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/CustomPublicationHandler.kt +++ /dev/null @@ -1,70 +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.gradle.publish - -import io.spine.gradle.repo.Repository -import org.gradle.api.Project -import org.gradle.api.publish.maven.MavenPublication - -/** - * A handler for custom publications, which are declared under the [publications] - * section of a module. - * - * Such publications should be treated differently than [StandardJavaPublicationHandler], - * which is created for a module. Instead, since the publications are already declared, - * this class only [assigns Maven coordinates][copyProjectAttributes]. - * - * A module which declares custom publications must be specified in - * the [SpinePublishing.modulesWithCustomPublishing] property. - * - * If a module with [publications] declared locally is not specified as one with custom publishing, - * it may cause a name clash between an artifact produced by - * the [standard][org.gradle.api.publish.maven.MavenPublication] publication, and custom ones. - * To have both standard and custom publications, please specify custom artifact IDs or - * classifiers for each custom publication. - * - * @see StandardJavaPublicationHandler - */ -internal class CustomPublicationHandler private constructor( - project: Project, - destinations: Set -) : PublicationHandler(project, destinations) { - - override fun handlePublications() { - project.publications.forEach { - (it as MavenPublication).copyProjectAttributes() - } - } - - companion object : HandlerFactory() { - override fun create( - project: Project, - destinations: Set, - vararg params: Any - ): CustomPublicationHandler = CustomPublicationHandler(project, destinations) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/IncrementGuard.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/IncrementGuard.kt deleted file mode 100644 index b6683fa..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/IncrementGuard.kt +++ /dev/null @@ -1,109 +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. - */ - -@file:Suppress("unused") - -package io.spine.gradle.publish - -import org.gradle.api.Plugin -import org.gradle.api.Project - -/** - * Gradle plugin which adds a [CheckVersionIncrement] task. - * - * The task is called `checkVersionIncrement` inserted before the `check` task. - */ -class IncrementGuard : Plugin { - - companion object { - const val taskName = "checkVersionIncrement" - } - - /** - * Adds the [CheckVersionIncrement] task to the project. - * - * The task is created anyway, but it is enabled only if: - * 1. The project is built on GitHub CI, and - * 2. The job is a pull request. - * - * The task only runs on non-master branches on GitHub Actions. - * This is done to prevent unexpected CI fails when re-building `master` multiple times, - * creating git tags, and in other cases that go outside the "usual" development cycle. - */ - override fun apply(target: Project) { - val tasks = target.tasks - tasks.register(taskName, CheckVersionIncrement::class.java) { - repository = CloudArtifactRegistry.repository - tasks.getByName("check").dependsOn(this) - - if (!shouldCheckVersion()) { - logger.info( - "The build does not represent a GitHub Actions feature branch job, " + - "the `checkVersionIncrement` task is disabled." - ) - this.enabled = false - } - } - } - - /** - * Returns `true` if the current build is a GitHub Actions build which represents a push - * to a feature branch. - * - * Returns `false` if the associated reference is not a branch (e.g., a tag) or if it has - * the name which ends with `master` or `main`. - * - * For example, on the following branches the method would return `false`: - * - * 1. `master`. - * 2. `main`. - * 3. `2.x-jdk8-master`. - * 4. `2.x-jdk8-main`. - * - * @see - * List of default environment variables provided for GitHub Actions builds - */ - private fun shouldCheckVersion(): Boolean { - val event = System.getenv("GITHUB_EVENT_NAME") - val reference = System.getenv("GITHUB_REF") - if (event != "push" || reference == null) { - return false - } - val branch = branchName(reference) - return when { - branch == null -> false - branch.endsWith("master") -> false - branch.endsWith("main") -> false - else -> true - } - } - - private fun branchName(gitHubRef: String): String? { - val matches = Regex("refs/heads/(.+)").matchEntire(gitHubRef) - val branch = matches?.let { it.groupValues[1] } - return branch - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt deleted file mode 100644 index 75c5413..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublicationHandler.kt +++ /dev/null @@ -1,250 +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.gradle.publish - -import LicenseSettings -import io.spine.gradle.isSnapshot -import io.spine.gradle.repo.Repository -import org.gradle.api.Project -import org.gradle.api.artifacts.dsl.RepositoryHandler -import org.gradle.api.invocation.BuildInvocationDetails -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.support.serviceOf - -/** - * The name of the Maven Publishing Gradle plugin. - */ -private const val MAVEN_PUBLISH = "maven-publish" - -/** - * Abstract base for handlers of publications in a project - * with [spinePublishing] settings declared. - * - * @param project The project to which the handler is applied. - * @param destinations The repositories for publishing artifacts of this project. - * In a multi-module project the destinations can be re-defined by - * specifying custom values in - * the [`spinePublishing`][io.spine.gradle.publish.SpinePublishing.destinations] - * extension applied to the subproject. - */ -internal sealed class PublicationHandler( - protected val project: Project, - protected var destinations: Set -) { - /** - * Remembers if the [apply] function was called by this handler. - */ - private var applied: Boolean = false - - /** - * Overwrites the [destinations] property with the given set. - */ - fun publishTo(alternativeDestinations: Set) { - if (alternativeDestinations.isEmpty()) { - project.logger.info( - "The project ${project.path} is not going to be published because" + - " the publication handler `${this@PublicationHandler}`" + - " got an empty set of new `destinations`." - ) - } - destinations = alternativeDestinations - } - - /** - * Configures the publication of the associated [project]. - */ - fun apply() { - synchronized(project) { - if (applied) { - return - } - project.run { - // We apply the `maven-publish` plugin for modules with standard - // publishing automatically because they don't need custom DSL - // in their `build.gradle.kts` files. - // All the job is done by the `SpinePublishing` extension and - // `StandardPublicationHandler` instance associated with this project. - if (!hasCustomPublishing) { - apply(plugin = MAVEN_PUBLISH) - } - // And we do not apply the plugin for modules with custom publishing - // because they will need the `maven-publish` DSL to tune the publishing. - // Therefore, we only arrange the execution of our code when the plugin - // is applied. - pluginManager.withPlugin(MAVEN_PUBLISH) { - handlePublications() - registerDestinations() - configurePublishTask(destinations) - applied = true - } - } - } - } - - /** - * Either handles publications already declared in the associated [project] - * or creates new ones. - */ - abstract fun handlePublications() - - /** - * Goes through the [destinations] and registers each as a repository for publishing - * in the given Gradle project. - */ - private fun registerDestinations() { - val repositories = project.publishingExtension.repositories - destinations.forEach { destination -> - repositories.register(project, destination) - } - } - - /** - * Copies the attributes of Gradle [Project] to this [MavenPublication]. - * - * The following project attributes are copied: - * * [group][Project.getGroup]; - * * [version][Project.getVersion]; - * * [description][Project.getDescription]. - * - * Also, this function adds the [artifactPrefix][SpinePublishing.artifactPrefix] to - * the [artifactId][MavenPublication.setArtifactId] of this publication, - * if the prefix is not added yet. - * - * Finally, the Apache Software License 2.0 is set as the only license - * under which the published artifact is distributed. - */ - protected fun MavenPublication.copyProjectAttributes() { - groupId = project.group.toString() - val prefix = project.spinePublishing.artifactPrefix - if (!artifactId.startsWith(prefix)) { - artifactId = prefix + artifactId - } - version = project.version.toString() - pom.description.set(project.description) - - pom.licenses { - license { - name.set(LicenseSettings.name) - url.set(LicenseSettings.url) - } - } - } - - /** - * The abstract base for factories producing instances of classes - * derived from [io.spine.gradle.publish.PublicationHandler]. - * - * The factory maintains associations between a path of the project to - * its publication handler. - * - * If the handler already exists, its settings are updated when - * the [serving] factory method is called. - * - * Otherwise, a new handler is created and associated with the project. - * - * @param H The type of the publication handlers produced by this repository. - * @see serving - */ - abstract class HandlerFactory { - - /** - * Maps a project path suffixed with build start time to the associated publication handler. - * - * The suffix after the project path is needed to create a new handler - * for each build. We do not use Guava or other cache expecting the small amount - * of memory consumption of each publication handler. - */ - private val handlers = mutableMapOf() - - /** - * Computes the key for a publication handler taking the [project] and - * its build start time. - */ - private fun createKey(project: Project): String { - val buildService = project.gradle.serviceOf() - val buildStartedMillis = buildService.buildStartedTime - val localTime = java.time.Instant.ofEpochMilli(buildStartedMillis) - val key = "${project.path}-at-$localTime" - return key - } - - /** - * Obtains an instance of [PublicationHandler] for the given project. - * - * If the handler for the given [project] was already created, the handler - * gets new [destinations], [overwriting][publishTo] previously specified. - * - * @return the handler for the given project which would handle publishing to - * the specified [destinations]. - */ - fun serving(project: Project, destinations: Set, vararg params: Any): H { - synchronized(handlers) { - val key = createKey(project) - var handler = handlers[key] - if (handler == null) { - handler = create(project, destinations, *params) - handlers[key] = handler - } else { - handler.publishTo(destinations) - } - return handler - } - } - - /** - * Creates a new publication handler for the given project. - * - * @param project The project to which the handler applies. - * @param destinations The repositories for publishing artifacts of this project. - * @param params Optional parameters to be passed as constructor parameters for - * classes of the type [H]. - */ - protected abstract fun create( - project: Project, - destinations: Set, - vararg params: Any - ): H - } -} - -/** - * Adds a Maven repository to the project specifying credentials, if they are - * [available][Repository.credentials] from the root project. - */ -private fun RepositoryHandler.register(project: Project, repository: Repository) { - val isSnapshot = project.version.toString().isSnapshot() - val credentials = repository.credentials(project.rootProject) - maven { - name = repository.name(isSnapshot) - url = project.uri(repository.target(isSnapshot)) - credentials { - username = credentials?.username - password = credentials?.password - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt deleted file mode 100644 index 0a24b56..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/PublishingExts.kt +++ /dev/null @@ -1,323 +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.gradle.publish - -import dokkaKotlinJar -import io.spine.gradle.isSnapshot -import io.spine.gradle.repo.Repository -import io.spine.gradle.sourceSets -import java.util.* -import org.gradle.api.InvalidUserDataException -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.api.publish.PublicationContainer -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Jar -import org.gradle.kotlin.dsl.findByType -import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.getByType -import org.gradle.kotlin.dsl.named -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.withType - -/** - * Obtains [PublishingExtension] of this project. - */ -internal val Project.publishingExtension: PublishingExtension - get() = extensions.getByType() - -/** - * Obtains [PublicationContainer] of this project. - */ -internal val Project.publications: PublicationContainer - get() = publishingExtension.publications - -/** - * Obtains an instance, if available, of [SpinePublishing] extension - * applied to this project. - */ -internal val Project.localSpinePublishing: SpinePublishing? - get() = extensions.findByType() - -/** - * Obtains [SpinePublishing] extension from this [Project]. - * - * If this [Project] doesn't have one, it returns [SpinePublishing] - * declared in the root project. - */ -internal val Project.spinePublishing: SpinePublishing - get() { - val local = localSpinePublishing - if (local != null) { - return local - } - val fromRoot = this.rootProject.extensions.findByType() - if (fromRoot != null) { - return fromRoot - } - error("`SpinePublishing` is not found in `${project.name}`.") - } - -/** - * Tells if this project has custom publishing. - * - * For a multi-module project this is checked by presence of this project - * in the list of [SpinePublishing.modulesWithCustomPublishing] of the root project. - * - * In a single-module project, the value of the [SpinePublishing.customPublishing] - * property is returned. - */ -internal val Project.hasCustomPublishing: Boolean - get() = rootProject.spinePublishing.modulesWithCustomPublishing.contains(name) - || spinePublishing.customPublishing - -private const val PUBLISH_TASK = "publish" - -/** - * Locates `publish` task in this [TaskContainer]. - * - * This task publishes all defined publications to all defined repositories. To achieve that, - * the task depends on all `publish`*PubName*`PublicationTo`*RepoName*`Repository` tasks. - * - * Please note, task execution would not copy publications to the local Maven cache. - * - * @see - * Tasks | The Maven Publish Plugin - */ -internal val TaskContainer.publish: TaskProvider - get() = named(PUBLISH_TASK) - -/** - * Sets dependencies for `publish` task in this [Project]. - * - * This method performs the following: - * - * 1. When this [Project] is not a root, makes `publish` task in a root project - * depend on a local `publish`. - * 2. Makes local `publish` task verify that credentials are present for each - * of destination repositories. - */ -internal fun Project.configurePublishTask(destinations: Set) { - attachCredentialsVerification(destinations) - bindToRootPublish() -} - -private fun Project.attachCredentialsVerification(destinations: Set) { - val checkCredentials = tasks.registerCheckCredentialsTask(destinations) - val localPublish = tasks.publish - localPublish.configure { dependsOn(checkCredentials) } -} - -private fun Project.bindToRootPublish() { - if (project == rootProject) { - return - } - - val localPublish = tasks.publish - val rootPublish = rootProject.tasks.getOrCreatePublishTask() - rootPublish.configure { dependsOn(localPublish) } -} - -/** - * Use this task accessor when it is not guaranteed that the task is present - * in this [TaskContainer]. - */ -private fun TaskContainer.getOrCreatePublishTask(): TaskProvider = - if (names.contains(PUBLISH_TASK)) { - named(PUBLISH_TASK) - } else { - register(PUBLISH_TASK) - } - -@Suppress( - /* Several types of exceptions may be thrown, - and Kotlin does not have a multi-catch support yet. */ - "TooGenericExceptionCaught" -) -private fun TaskContainer.registerCheckCredentialsTask( - destinations: Set, -): TaskProvider { - val checkCredentials = "checkCredentials" - try { - // The result of this call is ignored intentionally. - // - // We expect this line to fail with the exception - // in case the task with this name is NOT registered. - // - // Otherwise, we need to replace the existing task - // to avoid checking the credentials - // for some previously asked `destinations`. - named(checkCredentials) - val toConfigure = replace(checkCredentials) - toConfigure.doLastCredentialsCheck(destinations) - return named(checkCredentials) - } catch (_: Exception) { - return register(checkCredentials) { doLastCredentialsCheck(destinations) } - } -} - -private fun Task.doLastCredentialsCheck(destinations: Set) { - doLast { - if (logger.isDebugEnabled) { - val isSnapshot = project.version.toString().isSnapshot() - val destinationsStr = destinations.joinToString(", ") { it.target(isSnapshot) } - logger.debug( - "Project '${project.name}': checking the credentials for repos: $destinationsStr." - ) - } - destinations.forEach { it.ensureCredentials(project) } - } -} - -private fun Repository.ensureCredentials(project: Project) { - val credentials = credentials(project) - if (Objects.isNull(credentials)) { - throw InvalidUserDataException( - "No valid credentials for repository `${this}`. Please make sure " + - "to pass username/password or a valid `.properties` file." - ) - } -} - -/** - * Excludes Google `.proto` sources from all artifacts. - * - * Goes through all registered `Jar` tasks and filters out Google's files. - */ -@Suppress("unused") -fun TaskContainer.excludeGoogleProtoFromArtifacts() { - withType().configureEach { - exclude { it.isGoogleProtoSource() } - } -} - -/** - * Locates or creates `sourcesJar` task in this [Project]. - * - * The output of this task is a `jar` archive. The archive contains sources from `main` source set. - * The task makes sure that sources from the directories below will be included - * in the resulting archive: - * - * - Kotlin - * - Java - * - Proto - * - * Java and Kotlin sources are default to `main` source set since it is created by `java` plugin. - * For Proto sources to be included – [special treatment][protoSources] is needed. - */ -internal fun Project.sourcesJar(): TaskProvider = tasks.getOrCreate("sourcesJar") { - dependOnGenerateProto() - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) // Puts Java and Kotlin sources. - from(protoSources()) // Puts Proto sources. - exclude("desc.ref", "*.desc") // Exclude descriptor files and the descriptor reference. -} - -/** - * Locates or creates `protoJar` task in this [Project]. - * - * The output of this task is a `jar` archive. The archive contains only - * [Proto sources][protoSources] from `main` source set. - */ -internal fun Project.protoJar(): TaskProvider = tasks.getOrCreate("protoJar") { - dependOnGenerateProto() - archiveClassifier.set("proto") - from(protoSources()) -} - -/** - * Locates or creates `testJar` task in this [Project]. - * - * The output of this task is a `jar` archive. The archive contains compilation output - * of `test` source set. - */ -internal fun Project.testJar(): TaskProvider = tasks.getOrCreate("testJar") { - archiveClassifier.set("test") - from(sourceSets["test"].output) -} - -/** - * Locates or creates `javadocJar` task in this [Project]. - * - * The output of this task is a `jar` archive. The archive contains Javadoc, - * generated upon Java sources from `main` source set. If Javadoc for Kotlin is also needed, - * apply the Dokka plugin. It tunes `javadoc` task to generate docs upon Kotlin sources as well. - */ -fun Project.javadocJar(): TaskProvider = tasks.getOrCreate("javadocJar") { - archiveClassifier.set("javadoc") - val javadocFiles = layout.buildDirectory.files("/docs/javadoc") - from(javadocFiles) - dependsOn("javadoc") -} - -internal fun TaskContainer.getOrCreate(name: String, init: Jar.() -> Unit): TaskProvider = - if (names.contains(name)) { - named(name) - } else { - register(name) { - init() - } - } - -/** - * Obtains as a set of [Jar] tasks, output of which is used as Maven artifacts. - * - * By default, only a jar with Java compilation output is included into publication. This method - * registers tasks which produce additional artifacts according to the values of [jarFlags]. - * - * @return the list of the registered tasks. - */ -internal fun Project.artifacts(jarFlags: JarFlags): Set> { - val tasks = mutableSetOf>() - - if (jarFlags.sourcesJar) { - tasks.add(sourcesJar()) - } - - if (jarFlags.javadocJar) { - tasks.add(javadocJar()) - } - - // We don't want to have an empty "proto.jar" when a project doesn't have any Proto files. - if (hasProto() && jarFlags.publishProtoJar) { - tasks.add(protoJar()) - } - - // Here, we don't have the corresponding `hasTests()` check, since this artifact is disabled - // by default. And turning it on means "We have tests and need them to be published." - if (jarFlags.publishTestJar) { - tasks.add(testJar()) - } - - if (jarFlags.publishDokkaKotlinJar) { - tasks.add(dokkaKotlinJar()) - } - - return tasks -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt deleted file mode 100644 index e2e67e0..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/ShadowJarExts.kt +++ /dev/null @@ -1,77 +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.gradle.publish - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar - -/** - * Calls [ShadowJar.mergeServiceFiles] for the files we use in the Spine SDK. - */ -fun ShadowJar.handleMergingServiceFiles() { - ServiceFiles.all.forEach { - mergeServiceFiles(it) - } -} - -@Suppress("ConstPropertyName") -private object ServiceFiles { - - /** - * Files containing references to descriptor set files. - */ - private const val descriptorSetReferences = "desc.ref" - - private const val servicesDir = "META-INF/services" - /** - * Providers of custom Protobuf options introduced by the libraries. - */ - private const val optionProviders = "$servicesDir/io.spine.option.OptionsProvider" - - /** - * KSP symbol processor provider. - */ - private const val kspSymbolProcessorProviders = - "$servicesDir/com.google.devtools.ksp.KspSymbolProcessorProvider" - - /** - * Message routing setup classes generated by the Compiler for JVM. - */ - private const val routeSetupPackage = "io.spine.server.route.setup" - private const val routeSetupPrefix = "$servicesDir/$routeSetupPackage" - private const val commandRoutingSetupClasses = "$routeSetupPrefix.CommandRoutingSetup" - private const val eventRoutingSetupClasses = "$routeSetupPrefix.EventRoutingSetup" - private const val stateRoutingSetupClasses = "$routeSetupPrefix.StateRoutingSetup" - - val all = arrayOf( - descriptorSetReferences, - optionProviders, - kspSymbolProcessorProviders, - commandRoutingSetupClasses, - eventRoutingSetupClasses, - stateRoutingSetupClasses - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt deleted file mode 100644 index 9dc7d7c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/SpinePublishing.kt +++ /dev/null @@ -1,535 +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. - */ - -@file:Suppress("TooManyFunctions") - -package io.spine.gradle.publish - -import io.spine.gradle.repo.Repository -import org.gradle.api.Project -import org.gradle.api.publish.maven.plugins.MavenPublishPlugin -import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.create -import org.gradle.kotlin.dsl.findByType - -/** - * Configures [SpinePublishing] extension. - * - * This extension sets up publishing of artifacts to Maven repositories. - * - * The extension can be configured for single- and multi-module projects. - * - * ## Using in a multi-module project - * - * When used with a multi-module project, the extension should be opened in a root project's - * build file. The published modules are specified explicitly by their names: - * - * ```kotlin - * spinePublishing { - * modules = setOf( - * "subprojectA", - * "subprojectB", - * ) - * destinations = PublishingRepos.run { setOf( - * cloudArtifactRegistry, - * gitHub("") // The name of the GitHub repository of the project. - * )} - * } - * ``` - * - * ### Filtering out test-only modules - * - * Sometimes a functional or an integration test requires a significant amount of - * configuration code which is better understood when isolated into a separate module. - * Conventionally, we use the `-tests` suffix for naming such modules. - * - * In order to avoid publishing of such a test-only module, we use the following extensions - * for the Gradle [Project] class: [productionModules], [productionModuleNames]. - * So the above code for specifying the modules to publish could be rewritten as follows: - * - * ```kotlin - * spinePublishing { - * modules = productionModuleNames.toSet() - * } - * ``` - * This code works for most of the projects. - * - * ### Arranging custom publishing for a module - * ```kotlin - * - * 1. Modify the list of standardly published modules in the root project like this: - * - * ```kotlin - * spinePublishing { - * modules = productionModuleNames - * .minus("my-custom-module") - * .toSet() - * - * modulesWithCustomPublishing = setOf( - * "my-custom-module" - * ) - * - * // ... - * } - * ``` - * 2. Arrange the custom publishing in the `my-custom-module` project. - * - * ## Using in a single-module project - * - * When used with a single-module project, the extension should be opened in a project's build file. - * Only destinations should be specified: - * - * ```kotlin - * spinePublishing { - * destinations = PublishingRepos.run { setOf( - * cloudArtifactRegistry, - * gitHub("") - * )} - * } - * ``` - * - * ## Publishing modules - * - * It is worth mentioning that publishing of a module can be configured only from a single place. - * For example, declaring `subprojectA` as published in a root project and opening - * `spinePublishing` extension within `subprojectA` itself would lead to an exception. - * - * In Gradle, in order to publish something somewhere, one should create a publication. In each - * of published modules, the extension will create a [publication][StandardJavaPublicationHandler] - * named "mavenJava". All artifacts published by this extension belong to this publication. - * - * ## Published artifacts - * - * By default, along with the compilation output of the `main` source set, the extension publishes - * the following artifacts: - * - * 1. [sourcesJar] — sources from the `main` source set. Includes handcrafted and generated - * code in Java, Kotlin, and `.proto` files. - * - * 2. [protoJar] – only `.proto` sources from the `main` source set. It's published only if - * Proto files are actually present in the source set. Publication of this artifact is optional - * and can be disabled via [SpinePublishing.protoJar]. - * - * 3. [javadocJar] — Javadoc, generated upon Java sources from the `main` source set. - * If Javadoc for Kotlin is also needed, apply the Dokka plugin. - * It tunes the `javadoc` task to generate docs upon Kotlin sources as well. - * - * 4. [dokkaKotlinJar] — documentation generated by Dokka for Kotlin and Java sources - * using the Kotlin API mode. - * - * 5. [dokkaJavaJar] — documentation generated by Dokka for Kotlin and Java sources - * using the Java API mode. - * - * Additionally, [testJar] artifact can be published. This artifact contains compilation output - * of the `test` source set. Use [SpinePublishing.testJar] to enable its publishing. - * - * @see [artifacts] - * @see SpinePublishing - */ -fun Project.spinePublishing(block: SpinePublishing.() -> Unit) { - apply() - val name = SpinePublishing::class.java.simpleName - val extension = with(extensions) { - findByType() ?: create(name, project) - } - extension.run { - block() - configured() - } -} - -/** - * A Gradle extension for setting up publishing of modules of Spine SDK modules - * using `maven-publish` plugin. - * - * ### Implementation Note - * - * This extension is overloaded with responsibilities. - * It basically does what an extension AND a Gradle plugin would normally do. - * - * We [should introduce a plugin class](https://github.com/SpineEventEngine/config/issues/562) - * and move the code related to creating tasks or setting dependencies between them into the plugin. - * - * @param project The project in which the extension is opened. By default, this project will be - * published as long as a [set][modules] of modules to publish is not specified explicitly. - * - * @see spinePublishing - */ -open class SpinePublishing(private val project: Project) { - - companion object { - - /** - * The default prefix added before a module name when publishing artifacts. - */ - const val DEFAULT_PREFIX = "spine-" - } - - private val protoJar = ProtoJar() - private val testJar = TestJar() - private val dokkaJar = DokkaJar() - - /** - * Set of modules to be published. - * - * Both the module's name or path can be used. - * - * Use this property if the extension is configured from a root project's build file. - * - * If left empty, the [project], in which the extension is opened, will be published. - * - * Empty by default. - */ - var modules: Set = emptySet() - - /** - * Controls whether the [module][project] needs standard publications. - * - * Default value is `false`. - * - * In a single module [project], settings this property to `true` it tells - * that the project configures the publication in a specific way and - * [CustomPublicationHandler] should be used. - * Otherwise, the extension will configure the - * [standard publication][StandardJavaPublicationHandler]. - * - * This property is an analogue of [modulesWithCustomPublishing] in - * [multi-module][Project.getSubprojects] projects, - * for which [spinePublishing] is configured individually. - * - * Setting of this property to `true` and having a non-empty [modules] property - * in the project to which the extension is applied will lead to [IllegalStateException]. - * - * Settings this property to `true` in a subproject serves only the documentation purposes. - * This subproject still must be listed in the [modulesWithCustomPublishing] property in - * the extension of the [rootProject][Project.getRootProject], so that its publication - * can be configured in a specific way. - */ - var customPublishing = false - - /** - * Set of modules that have custom publications and do not need standard ones. - * - * Empty by default. - */ - var modulesWithCustomPublishing: Set = emptySet() - - /** - * Set of repositories, to which the resulting artifacts will be sent. - * - * Usually, Spine-related projects are published to one or more repositories, - * declared in [PublishingRepos]: - * - * ```kotlin - * destinations = PublishingRepos.run { setOf( - * cloudArtifactRegistry, - * gitHub("") // The name of the GitHub repository of the project. - * )} - * ``` - * - * If the property is not initialized, the destinations will be taken from - * the parent project. - */ - lateinit var destinations: Set - - /** - * A prefix to be added before the name of each artifact. - */ - var artifactPrefix: String = DEFAULT_PREFIX - - /** - * Allows disabling publishing of [protoJar] artifact, containing all Proto sources - * from `sourceSets.main.proto`. - * - * Here's an example of how to disable it for some of the published modules: - * - * ```kotlin - * spinePublishing { - * modules = setOf( - * "subprojectA", - * "subprojectB", - * ) - * protoJar { - * exclusions = setOf( - * "subprojectB", - * ) - * } - * } - * ``` - * - * For all modules, or when the extension is configured within a published module itself: - * - * ``` - * spinePublishing { - * protoJar { - * disabled = true - * } - * } - * ``` - * - * The resulting artifact is available under the "proto" classifier. - * For example, in Gradle 7+, one could depend on it like this: - * - * ``` - * implementation("io.spine:spine-client:$version@proto") - * ``` - */ - fun protoJar(block: ProtoJar.() -> Unit) = protoJar.run(block) - - /** - * Allows enabling publishing of [testJar] artifact, containing compilation output - * of "test" source set. - * - * Here's an example of how to enable it for some of the published modules: - * - * ``` - * spinePublishing { - * modules = setOf( - * "subprojectA", - * "subprojectB", - * ) - * testJar { - * inclusions = setOf( - * "subprojectB", - * ) - * } - * } - * ``` - * - * For all modules, or when the extension is configured within a published module itself: - * - * ``` - * spinePublishing { - * testJar { - * enabled = true - * } - * } - * ``` - * - * The resulting artifact is available under the "test" classifier. - * For example, in Gradle 7+, one could depend on it like this: - * - * ``` - * implementation("io.spine:spine-client:$version@test") - * ``` - */ - fun testJar(block: TestJar.() -> Unit) = testJar.run(block) - - /** - * Configures publishing of [dokkaKotlinJar] and [dokkaJavaJar] artifacts, - * containing Dokka-generated documentation. - * - * By default, publishing of the [dokkaKotlinJar] artifact is enabled, and [dokkaJavaJar] - * is disabled. - * - * Remember that the Dokka Gradle plugin should be applied to publish this artifact as it is - * produced by the `dokkaHtml` task. It can be done by using the - * [io.spine.dependency.build.Dokka] dependency object or by applying the - * `buildSrc/src/main/kotlin/dokka-for-kotlin` or - * `buildSrc/src/main/kotlin/dokka-for-java` script plugins. - * - * Here's an example of how to use this option: - * - * ``` - * spinePublishing { - * dokkaJar { - * kotlin = false - * java = true - * } - * } - * ``` - * - * The resulting artifact is available under the "dokka" classifier. - */ - fun dokkaJar(block: DokkaJar.() -> Unit) = dokkaJar.run(block) - - /** - * Called to notify the extension that its configuration is completed. - * - * On this stage the extension will validate the received configuration and set up - * `maven-publish` plugin for each published module. - */ - internal fun configured() { - ensureProtoJarExclusionsArePublished() - ensureTestJarInclusionsArePublished() - ensureModulesNotDuplicated() - ensureCustomPublishingNotMisused() - - val projectsToPublish = projectsToPublish() - projectsToPublish.forEach { project -> - val jarFlags = JarFlags.create(project.name, protoJar, testJar, dokkaJar) - project.setUpPublishing(jarFlags) - } - } - - /** - * Maps the names of published modules to [Project] instances. - * - * The method considers two options: - * - * 1. The [set][modules] of subprojects to publish is not empty. It means that the extension - * is opened from a root project. - * 2. The [set][modules] is empty. Then, the [project] in which the extension is opened - * will be published. - * - * @see modules - */ - private fun projectsToPublish(): Collection { - if (project.subprojects.isEmpty()) { - return setOf(project) - } - return modules.union(modulesWithCustomPublishing) - .map { name -> project.project(name) } - .ifEmpty { setOf(project) } - } - - /** - * Sets up `maven-publish` plugin for the given project. - * - * Firstly, an instance of [PublicationHandler] is created for the project depending - * on the nature of the publication process configured. - * Then, this the handler is scheduled to apply on [Project.afterEvaluate]. - * - * General rule of thumb is to avoid using [Project.afterEvaluate] of this closure, - * as it configures a project when its configuration is considered completed. - * Which is quite counter-intuitive. - * - * We selected to use [Project.afterEvaluate] so that we can configure publishing of multiple - * modules from a root project. When we do this, we configure publishing for a module, - * a build file of which has not been even evaluated yet. - * - * The simplest example here is specifying of `version` and `group` for Maven coordinates. - * Let's suppose they are declared in a module's build file. It is a common practice. - * But publishing of the module is configured from a root project's build file. - * By the time when we need to specify them, we just don't know them. - * As the result, we have to use [Project.afterEvaluate] in order to guarantee that - * the module will be configured by the time we configure publishing for it. - */ - private fun Project.setUpPublishing(jarFlags: JarFlags) { - val customPublishing = modulesWithCustomPublishing.contains(name) || customPublishing - val destinations = project.publishTo() - val handler = if (customPublishing) { - CustomPublicationHandler.serving(project, destinations) - } else { - StandardJavaPublicationHandler.serving(project, destinations, jarFlags) - } - afterEvaluate { - handler.apply() - } - } - - /** - * Obtains the set of repositories for publishing. - * - * If there is a local instance of [io.spine.gradle.publish.SpinePublishing] extension, - * the [destinations] are obtained from this instance. - * Otherwise, the function attempts to obtain it from a [parent project][Project.getParent]. - * If there is no a parent project, an empty set is returned. - * - * The normal execution should end up at the root project of a multi-module project - * if there are no custom destinations specified by the local extension. - */ - private fun Project.publishTo(): Set { - val ext = localSpinePublishing - if (ext != null && ext::destinations.isInitialized) { - return destinations - } - return parent?.publishTo() ?: emptySet() - } - - /** - * Obtains an artifact ID for the given project. - * - * It consists of a project's name and [prefix][artifactPrefix]: - * ``. - */ - fun artifactId(project: Project): String = "$artifactPrefix${project.name}" - - /** - * Ensures that all modules, marked as excluded from [protoJar] publishing, - * are actually published. - * - * It makes no sense to tell a module don't publish [protoJar] artifact, if the module is not - * published at all. - */ - private fun ensureProtoJarExclusionsArePublished() { - val nonPublishedExclusions = protoJar.exclusions.minus(modules) - if (nonPublishedExclusions.isNotEmpty()) { - error( - "One or more modules are marked as" + - " `excluded from proto JAR publication`," + - " but they are not even published: $nonPublishedExclusions." - ) - } - } - - /** - * Ensures that all modules, marked as included into [testJar] publishing, - * are actually published. - * - * It makes no sense to tell a module publish [testJar] artifact, if the module is not - * published at all. - */ - private fun ensureTestJarInclusionsArePublished() { - val nonPublishedInclusions = testJar.inclusions.minus(modules) - if (nonPublishedInclusions.isNotEmpty()) { - error( - "One or more modules are marked as `included into test JAR publication`," + - " but they are not even published: $nonPublishedInclusions." - ) - } - } - - /** - * Ensures that publishing of a module is configured only from a single place. - * - * We allow configuration of publishing from two places - a root project and the module itself. - * Here we verify that publishing of a module is not configured in both places simultaneously. - */ - private fun ensureModulesNotDuplicated() { - val rootProject = project.rootProject - if (rootProject == project) { - return - } - - val rootExtension = with(rootProject.extensions) { findByType() } - rootExtension?.let { rootPublishing -> - val thisProject = setOf(project.name, project.path) - if (thisProject.minus(rootPublishing.modules).size != 2) { - error( - "Publishing of `$thisProject` module is already configured in a root project!" - ) - } - } - } - - private fun ensureCustomPublishingNotMisused() { - if (modules.isNotEmpty() && customPublishing) { - error("`customPublishing` property can be set only if `spinePublishing` extension " + - "is open in an individual module, so `modules` property should be empty.") - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt b/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt deleted file mode 100644 index 06d78c1..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/publish/StandardJavaPublicationHandler.kt +++ /dev/null @@ -1,133 +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.gradle.publish - -import io.spine.gradle.repo.Repository -import org.gradle.api.Project -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.bundling.Jar -import org.gradle.kotlin.dsl.create - -/** - * A publication for a typical Java project. - * - * In Gradle, to publish something, one should create a publication. - * A publication has a name and consists of one or more artifacts plus information about - * those artifacts – the metadata. - * - * An instance of this class represents - * [MavenPublication][org.gradle.api.publish.maven.MavenPublication] - * named [`"mavenJava"`][PUBLICATION_NAME]. - * It is generally accepted that a publication with this name contains a Java project - * published to one or more Maven repositories. - * - * By default, only a jar with the compilation output of `main` source set and its - * metadata files are published. Other artifacts are specified through the - * [constructor parameter][jarFlags]. - * Please take a look on [specifyArtifacts] for additional info. - * - * @param jarFlags The flags for additional JARs published along with the compilation output. - * @param destinations Maven repositories to which the produced artifacts will be sent. - * @see - * The Maven Publish Plugin | Publications - * @see CustomPublicationHandler - */ -internal class StandardJavaPublicationHandler private constructor( - project: Project, - private val jarFlags: JarFlags, - destinations: Set, -) : PublicationHandler(project, destinations) { - - companion object : HandlerFactory() { - - /** - * The name of the publication created by [StandardJavaPublicationHandler]. - */ - const val PUBLICATION_NAME = "mavenJava" - - override fun create( - project: Project, - destinations: Set, - vararg params: Any - ): StandardJavaPublicationHandler { - return StandardJavaPublicationHandler(project, params[0] as JarFlags, destinations) - } - } - - /** - * Creates a new `"mavenJava"` [MavenPublication][org.gradle.api.publish.maven.MavenPublication] - * in the [project] associated with this publication handler. - */ - override fun handlePublications() { - val jars = project.artifacts(jarFlags) - val publications = project.publications - publications.create(PUBLICATION_NAME) { - copyProjectAttributes() - specifyArtifacts(jars) - } - } - - /** - * Specifies which artifacts this [MavenPublication] will contain. - * - * A typical Maven publication contains: - * - * 1. Jar archives. For example, compilation output, sources, javadoc, etc. - * 2. Maven metadata file that has the ".pom" extension. - * 3. Gradle's metadata file that has the ".module" extension. - * - * Metadata files contain information about a publication itself, its artifacts, and their - * dependencies. Presence of ".pom" file is mandatory for publication to be consumed by - * `mvn` build tool itself or other build tools that understand Maven notation (Gradle, Ivy). - * The presence of ".module" is optional, but useful when a publication is consumed by Gradle. - * - * @see Maven – POM Reference - * @see - * Understanding Gradle Module Metadata - */ - private fun MavenPublication.specifyArtifacts(jars: Set>) { - - /* - "java" component provides a jar with compilation output of "main" source set. - It is NOT defined as another `Jar` task intentionally. Doing that will leave the - publication without correct ".pom" and ".module" metadata files generated. - */ - val javaComponent = project.components.findByName("java") - javaComponent?.let { - from(it) - } - - /* - Other artifacts are represented by `Jar` tasks. Those artifacts do not bring any other - metadata in comparison with `Component` (such as the `dependencies` notation). - */ - jars.forEach { - artifact(it) - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt index 43abe47..a713f32 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/repo/Repositories.kt @@ -107,8 +107,6 @@ fun RepositoryHandler.standardToSpineSdk() { @Suppress("DEPRECATION") // Still use `CloudRepo` for earlier versions. val spineRepos = listOf( - Repos.spine, - Repos.spineSnapshots, Repos.artifactRegistry, Repos.artifactRegistrySnapshots ) @@ -146,16 +144,9 @@ fun RepositoryHandler.applyStandard() = this.standardToSpineSdk() * @see [applyStandard] */ @Suppress( - "DEPRECATION" /* Still need to use `CloudRepo` for older versions. */, "ConstPropertyName" // https://bit.ly/kotlin-prop-names ) private object Repos { - @Deprecated(message = "Please use `cloudArtifactRegistry.releases` instead.") - val spine = io.spine.gradle.publish.CloudRepo.published.target(snapshots = false) - - @Deprecated(message = "Please use `artifactRegistry.snapshots` instead.") - val spineSnapshots = io.spine.gradle.publish.CloudRepo.published.target(snapshots = true) - val artifactRegistry = PublishingRepos.cloudArtifactRegistry.target(snapshots = false) val artifactRegistrySnapshots = PublishingRepos.cloudArtifactRegistry.target(snapshots = true) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt deleted file mode 100644 index efdf605..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/CodebaseFilter.kt +++ /dev/null @@ -1,112 +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.gradle.report.coverage - -import com.google.errorprone.annotations.CanIgnoreReturnValue -import io.spine.gradle.report.coverage.FileFilter.generatedOnly -import java.io.File -import org.gradle.api.Project -import org.gradle.api.file.ConfigurableFileTree -import org.gradle.api.file.FileTree -import org.gradle.api.tasks.SourceSetOutput - -/** - * Serves to distinguish the `.java` and `.class` files built on top of the Protobuf definitions - * from the human-created production code. - * - * Works on top of the passed [source][srcDirs] and [output][outputDirs] directories, by analyzing - * the source file names and finding the corresponding compiler output. - */ -internal class CodebaseFilter( - private val project: Project, - private val srcDirs: Set, - private val outputDirs: Set -) { - - /** - * Returns the file tree containing the compiled `.class` files which were produced - * from the human-written production code. - * - * Such filtering excludes the output obtained from the generated sources. - */ - internal fun humanProducedCompiledFiles(): List { - log("Source dirs for the code coverage calculation:") - this.srcDirs.forEach { - log(" - $it") - } - - val generatedClassNames = generatedClassNames() - val humanProducedTree = outputDirs - .stream() - .flatMap { it.classesDirs.files.stream() } - .map { srcFile -> - log("Filtering out the generated classes for ${srcFile}.") - project.fileTree(srcFile).without(generatedClassNames) - }.toList() - return humanProducedTree - } - - private fun generatedClassNames(): List { - val generatedSourceFiles = generatedOnly(srcDirs) - val generatedNames = mutableListOf() - generatedSourceFiles - .filter { it.exists() && it.isDirectory } - .forEach { folder -> - folder.walk() - .filter { !it.isDirectory } - .forEach { file -> - file.parseName( - File::asJavaClassName, - File::asGrpcClassName, - File::asSpineClassName - )?.let { clsName -> - generatedNames.add(clsName) - } - } - } - return generatedNames - } - - private fun log(message: String) { - project.logger.info(message) - } -} - -/** - * Excludes the elements which [Java compiled file names][File.asJavaCompiledClassName] - * are present among the passed [names]. - * - * Returns the same instance of `ConfigurableFileTree`, for call chaining. - */ -@CanIgnoreReturnValue -private fun ConfigurableFileTree.without(names: List): ConfigurableFileTree { - this.exclude { element -> - val className = element.file.asJavaCompiledClassName() - names.contains(className) - } - return this -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtension.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtension.kt deleted file mode 100644 index ae4734c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtension.kt +++ /dev/null @@ -1,49 +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.gradle.report.coverage - -/** - * File extensions. - */ -internal enum class FileExtension(val value: String) { - - /** - * Extension of a Java source file. - */ - JAVA_SOURCE(".java"), - - /** - * Extension of a Java compiled file. - */ - COMPILED_CLASS(".class"); - - /** - * The number of symbols in the extension. - */ - val length: Int - get() = this.value.length -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtensions.kt deleted file mode 100644 index 89c8789..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileExtensions.kt +++ /dev/null @@ -1,129 +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.gradle.report.coverage - -import io.spine.gradle.report.coverage.FileExtension.COMPILED_CLASS -import io.spine.gradle.report.coverage.FileExtension.JAVA_SOURCE -import io.spine.gradle.report.coverage.PathMarker.ANONYMOUS_CLASS -import io.spine.gradle.report.coverage.PathMarker.GENERATED -import io.spine.gradle.report.coverage.PathMarker.GRPC_SRC_FOLDER -import io.spine.gradle.report.coverage.PathMarker.JAVA_OUTPUT_FOLDER -import io.spine.gradle.report.coverage.PathMarker.JAVA_SRC_FOLDER -import io.spine.gradle.report.coverage.PathMarker.SPINE_JAVA_SRC_FOLDER -import java.io.File - -/** - * This file contains extension methods and properties for `java.io.File`. - */ - -/** - * Parses the name of a class from the absolute path of this file. - * - * Treats the fragment between the [precedingMarker] and [extension] as the value to look for. - * In case the fragment is located and it contains `/` symbols, they are treated - * as Java package delimiters and are replaced by `.` symbols before returning the value. - * - * If the absolute path of this file has either no [precedingMarker] or no [extension], - * returns `null`. - */ -internal fun File.parseClassName( - precedingMarker: PathMarker, - extension: FileExtension -): String? { - val index = this.absolutePath.lastIndexOf(precedingMarker.infix) - return if (index > 0) { - var inFolder = this.absolutePath.substring(index + precedingMarker.length) - if (inFolder.endsWith(extension.value)) { - inFolder = inFolder.substring(0, inFolder.length - extension.length) - inFolder.replace('/', '.') - } else { - null - } - } else { - null - } -} - -/** - * Attempts to parse the file name with either of the specified [parsers], - * in their respective order. - * - * Returns the first non-`null` parsed value. - * - * If none of the parsers returns non-`null` value, returns `null`. - */ -internal fun File.parseName(vararg parsers: (file: File) -> String?): String? { - for (parser in parsers) { - val className = parser.invoke(this) - if (className != null) { - return className - } - } - return null -} - -/** - * Attempts to parse the Java fully-qualified class name from the absolute path of this file, - * treating it as a path to a human-produced `.java` file. - */ -internal fun File.asJavaClassName(): String? = - this.parseClassName(JAVA_SRC_FOLDER, JAVA_SOURCE) - -/** - * Attempts to parse the Java fully-qualified class name from the absolute path of this file, - * treating it as a path to a compiled `.class` file. - * - * If the `.class` file corresponds to the anonymous class, only the name of the parent - * class is returned. - */ -internal fun File.asJavaCompiledClassName(): String? { - var className = this.parseClassName(JAVA_OUTPUT_FOLDER, COMPILED_CLASS) - if (className != null && className.contains(ANONYMOUS_CLASS.infix)) { - className = className.split(ANONYMOUS_CLASS.infix)[0] - } - return className -} - -/** - * Attempts to parse the Java fully-qualified class name from the absolute path of this file, - * treating it as a path to a gRPC-generated `.java` file. - */ -internal fun File.asGrpcClassName(): String? = - this.parseClassName(GRPC_SRC_FOLDER, JAVA_SOURCE) - -/** - * Attempts to parse the Java fully-qualified class name from the absolute path of this file, - * treating it as a path to a Spine-generated `.java` file. - */ -internal fun File.asSpineClassName(): String? = - this.parseClassName(SPINE_JAVA_SRC_FOLDER, JAVA_SOURCE) - -/** - * Tells whether this file is a part of the generated sources, and not produced by a human. - */ -internal val File.isGenerated - get() = this.absolutePath.contains(GENERATED.infix) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileFilter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileFilter.kt deleted file mode 100644 index 5b26cc7..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/FileFilter.kt +++ /dev/null @@ -1,50 +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.gradle.report.coverage - -import java.io.File - -/** - * Utilities for filtering the groups of `File`s. - */ -internal object FileFilter { - - /** - * Excludes the generated files from this file collection, leaving only those which were - * created by human beings. - */ - fun producedByHuman(files: Iterable): Iterable { - return files.filter { !it.isGenerated } - } - - /** - * Filters this file collection so that only generated files are present. - */ - fun generatedOnly(files: Iterable): Iterable { - return files.filter { it.isGenerated } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt deleted file mode 100644 index 5114add..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/JacocoConfig.kt +++ /dev/null @@ -1,245 +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.gradle.report.coverage - -import io.spine.dependency.test.Jacoco -import io.spine.gradle.applyPlugin -import io.spine.gradle.getTask -import io.spine.gradle.report.coverage.TaskName.check -import io.spine.gradle.report.coverage.TaskName.copyReports -import io.spine.gradle.report.coverage.TaskName.jacocoRootReport -import io.spine.gradle.report.coverage.TaskName.jacocoTestReport -import io.spine.gradle.sourceSets -import java.io.File -import java.util.* -import org.gradle.api.Project -import org.gradle.api.file.ConfigurableFileCollection -import org.gradle.api.plugins.BasePlugin -import org.gradle.api.tasks.Copy -import org.gradle.api.tasks.SourceSetContainer -import org.gradle.api.tasks.SourceSetOutput -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.the -import org.gradle.testing.jacoco.plugins.JacocoPlugin -import org.gradle.testing.jacoco.plugins.JacocoPluginExtension -import org.gradle.testing.jacoco.tasks.JacocoReport - -/** - * Configures JaCoCo plugin to produce `jacocoRootReport` task which accumulates - * the test coverage results from all subprojects in a multi-project Gradle build. - * - * Users must apply `jacoco` plugin to all the subprojects, for which the report aggregation - * is required. - * - * In a single-module Gradle project, this utility is NOT needed. Just a plain `jacoco` plugin - * applied to the project is sufficient. - * - * Therefore, tn case this utility is applied to a single-module Gradle project, - * an `IllegalStateException` is thrown. - */ -@Suppress("unused") -class JacocoConfig( - private val rootProject: Project, - private val reportsDir: File, - private val projects: Iterable -) { - - companion object { - - /** - * A folder under the `buildDir` of the [rootProject] to which the reports will - * be copied when aggregating the coverage reports. - * - * If it does not exist, it will be created. - */ - private const val reportsDirSuffix = "subreports/jacoco/" - - /** - * Applies the JaCoCo plugin to the Gradle project. - * - * If the passed project has no subprojects, an `IllegalStateException` is thrown, - * telling that this utility should NOT be used. - * - * Registers `jacocoRootReport` task which aggregates all coverage reports - * from the subprojects. - */ - fun applyTo(project: Project) { - project.applyPlugin(BasePlugin::class.java) - val javaProjects: Iterable = eligibleProjects(project) - val reportsDir = project.rootProject.layout - .buildDirectory.dir(reportsDirSuffix).get().asFile - JacocoConfig( - project.rootProject, - reportsDir, - javaProjects - ).configure() - } - - /** - * For a multi-module Gradle project, returns those subprojects of the passed [project] - * which have JaCoCo plugin applied. - * - * Throws an exception in case this project has no subprojects. - */ - private fun eligibleProjects(project: Project): Iterable { - val projects: Iterable = - if (project.subprojects.isNotEmpty()) { - project.subprojects.filter { - it.pluginManager.hasPlugin(JacocoPlugin.PLUGIN_EXTENSION_NAME) - } - } else { - throw IllegalStateException( - "In a single-module Gradle project, `JacocoConfig` is NOT needed." + - " Please apply `jacoco` plugin instead." - ) - } - return projects - } - } - - private fun configure() { - configureVersion() - configureTask() - } - - private fun configureVersion() { - val jacoco = rootProject.the() - jacoco.toolVersion = Jacoco.version - } - - private fun configureTask() { - val tasks = rootProject.tasks - val copyReports = registerCopy(tasks) - val rootReport = registerRootReport(tasks, copyReports) - tasks.named(check.name) { - dependsOn(rootReport) - } - } - - private fun registerRootReport( - tasks: TaskContainer, - copyReports: TaskProvider? - ): TaskProvider { - val allSourceSets = Projects(projects).sourceSets() - val mainJavaSrcDirs = allSourceSets.mainJavaSrcDirs() - val humanProducedSourceFolders = - FileFilter.producedByHuman(mainJavaSrcDirs) - - val filter = CodebaseFilter( - rootProject, - mainJavaSrcDirs, - allSourceSets.mainOutputs() - ) - val humanProducedCompiledFiles = filter.humanProducedCompiledFiles() - - val rootReport = tasks.register(jacocoRootReport.name, JacocoReport::class.java) { - dependsOn(copyReports) - - additionalSourceDirs.from(humanProducedSourceFolders) - sourceDirectories.from(humanProducedSourceFolders) - executionData.from(rootProject.fileTree(reportsDir)) - - classDirectories.from(humanProducedCompiledFiles) - additionalClassDirs.from(humanProducedCompiledFiles) - - reports { - html.required.set(true) - xml.required.set(true) - csv.required.set(false) - } - onlyIf { true } - } - return rootReport - } - - private fun registerCopy(tasks: TaskContainer): TaskProvider { - val everyExecData = mutableListOf() - projects.forEach { project -> - val jacocoTestReport = project.getTask(jacocoTestReport.name) - val executionData = jacocoTestReport.executionData - everyExecData.add(executionData) - } - - val originalLocation = rootProject.files(everyExecData) - - val copyReports = tasks.register(copyReports.name, Copy::class.java) { - from(originalLocation) - into(reportsDir) - rename { - "${UUID.randomUUID()}.exec" - } - dependsOn(projects.map { it.getTask(jacocoTestReport.name) }) - } - return copyReports - } -} - -/** - * Extensions for working with groups of Gradle `Project`s. - */ -private class Projects( - private val projects: Iterable -) { - - /** - * Returns all source sets for this group of projects. - */ - fun sourceSets(): SourceSets { - val sets = projects.asSequence().map { it.sourceSets }.toList() - return SourceSets(sets) - } -} - -/** - * Extensions for working with several of Gradle `SourceSetContainer`s. - */ -private class SourceSets( - private val sourceSets: Iterable -) { - - /** - * Returns all Java source folders corresponding to the `main` source set type. - */ - fun mainJavaSrcDirs(): Set { - return sourceSets - .asSequence() - .flatMap { it["main"].allJava.srcDirs } - .toSet() - } - - /** - * Returns all source set outputs corresponding to the `main` source set type. - */ - fun mainOutputs(): Set { - return sourceSets - .asSequence() - .map { it["main"].output } - .toSet() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/PathMarker.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/PathMarker.kt deleted file mode 100644 index 26bb135..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/PathMarker.kt +++ /dev/null @@ -1,70 +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.gradle.report.coverage - -/** - * Fragments of file path which allow to detect the type of the file. - */ -internal enum class PathMarker(val infix: String) { - - /** - * Generated files. - */ - GENERATED("generated"), - - /** - * Files produced by humans and written in Java. - */ - JAVA_SRC_FOLDER("/java/"), - - /** - * Java source files generated by Spine framework. - */ - SPINE_JAVA_SRC_FOLDER("main/spine/"), - - /** - * Java source files generated by gRPC plugin. - */ - GRPC_SRC_FOLDER("/main/grpc/"), - - /** - * Among compiler output folders, highlights those containing the compilation result - * of human-produced Java files. - */ - JAVA_OUTPUT_FOLDER("/main/"), - - /** - * Anonymous class. - */ - ANONYMOUS_CLASS("$"); - - /** - * The number of symbols in the marker. - */ - val length: Int - get() = this.infix.length -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/TaskName.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/TaskName.kt deleted file mode 100644 index 7c0e386..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/coverage/TaskName.kt +++ /dev/null @@ -1,39 +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.gradle.report.coverage - -/** - * The names of Gradle tasks involved in the JaCoCo reporting. - */ -@Suppress("EnumEntryName", "EnumNaming") /* Dubbing the actual values in Gradle. */ -internal enum class TaskName { - jacocoRootReport, - copyReports, - - check, - jacocoTestReport -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Configuration.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Configuration.kt deleted file mode 100644 index f6e06fd..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Configuration.kt +++ /dev/null @@ -1,51 +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.gradle.report.license - -import com.github.jk1.license.ConfigurationData - -/** - * The names of Gradle `Configuration`s. - */ -@Suppress("EnumEntryName", "EnumNaming") -/* Dubbing the actual values in Gradle. */ -internal enum class Configuration { - runtime, - runtimeClasspath -} - -/** - * Tells whether this configuration data is one of the passed `Configuration` types. - */ -internal fun ConfigurationData.isOneOf(vararg configs: Configuration): Boolean { - configs.forEach { - if (it.name == this.name) { - return true - } - } - return false -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt deleted file mode 100644 index ec86eb5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/LicenseReporter.kt +++ /dev/null @@ -1,163 +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.gradle.report.license - -import com.github.jk1.license.LicenseReportExtension -import com.github.jk1.license.LicenseReportExtension.ALL -import com.github.jk1.license.LicenseReportPlugin -import io.spine.gradle.applyPlugin -import io.spine.gradle.getTask -import java.io.File -import org.gradle.api.Project -import org.gradle.api.Task -import org.gradle.kotlin.dsl.the - -/** - * Generates the license report for all Java dependencies used in a single Gradle project - * and in a repository. - * - * Transitive dependencies are included. - * - * The output file is placed to the root folder of the root Gradle project. - * - * Usage: - * - * ``` - * // ... - * subprojects { - * - * LicenseReporter.generateReportIn(project) - * } - * - * // ... - * - * LicenseReporter.mergeAllReports(project) - * - * ``` - */ -object LicenseReporter { - - /** - * The name of the Gradle task which generates the reports for a specific Gradle project. - */ - private const val projectTaskName = "generateLicenseReport" - - /** - * The name of the Gradle task merging the license reports across all Gradle projects - * in the repository into a single report file. - */ - private const val mergeTaskName = "mergeAllLicenseReports" - - /** - * Enables the generation of the license report for a single Gradle project. - * - * Registers `generateLicenseReport` task, which is later picked up - * by the [merge task][mergeAllReports]. - */ - fun generateReportIn(project: Project) { - project.applyPlugin(LicenseReportPlugin::class.java) - val reportOutputDir = project.layout.buildDirectory.dir(Paths.relativePath).get().asFile - - with(project.the()) { - outputDir = reportOutputDir.absolutePath - excludeGroups = arrayOf( - "io.spine", - "io.spine.gcloud", - "io.spine.protodata", - "io.spine.tools", - "io.spine.validation" - ) - configurations = ALL - - renderers = arrayOf(MarkdownReportRenderer(Paths.outputFilename)) - } - } - - /** - * Tells to merge all per-project reports that were previously [generated][generateReportIn] - * for each of the subprojects of the root Gradle project. - * - * The merge result is placed according to [Paths]. - * - * Registers a `mergeAllLicenseReports` which is specified to be executed after `build`. - */ - fun mergeAllReports(project: Project) { - val rootProject = project.rootProject - val mergeTask = rootProject.tasks.register(mergeTaskName) { - val consolidationTask = this - val assembleTask = project.getTask("assemble") - val sourceProjects: Iterable = sourceProjects(rootProject) - sourceProjects.forEach { - val perProjectTask = it.getTask(projectTaskName) - consolidationTask.dependsOn(perProjectTask) - perProjectTask.dependsOn(assembleTask) - } - doLast { - mergeReports(sourceProjects, rootProject) - } - dependsOn(assembleTask) - } - project.getTask("build") - .finalizedBy(mergeTask) - } - - /** - * Determines the source projects for which the resulting report will be produced. - */ - private fun Task.sourceProjects(rootProject: Project): Iterable { - val targetProjects: Iterable = if (rootProject.subprojects.isEmpty()) { - rootProject.logger.debug( - "The license report will be produced for a single root project." - ) - listOf(this.project) - } else { - rootProject.logger.debug( - "The license report will be produced for all subprojects of a root project." - ) - rootProject.subprojects - } - return targetProjects - } - - /** - * Merges the license reports from all [sourceProjects] into a single file under - * the [rootProject]'s root directory. - */ - private fun mergeReports( - sourceProjects: Iterable, - rootProject: Project - ) { - val paths = sourceProjects.map { - val buildDir = it.layout.buildDirectory.asFile.get() - "$buildDir/${Paths.relativePath}/${Paths.outputFilename}" - } - println("Merging the license reports from the all projects.") - val mergedContent = paths.joinToString("\n\n\n") { (File(it)).readText() } - val output = File("${rootProject.rootDir}/${Paths.outputFilename}") - output.writeText(mergedContent) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/MarkdownReportRenderer.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/MarkdownReportRenderer.kt deleted file mode 100644 index b158210..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/MarkdownReportRenderer.kt +++ /dev/null @@ -1,61 +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.gradle.report.license - -import com.github.jk1.license.LicenseReportExtension -import com.github.jk1.license.ProjectData -import com.github.jk1.license.render.ReportRenderer -import io.spine.docs.MarkdownDocument -import java.io.File -import org.gradle.api.Project - -/** - * Renders the dependency report for a single [project][ProjectData] in Markdown. - */ -internal class MarkdownReportRenderer( - private val filename: String -) : ReportRenderer { - - override fun render(data: ProjectData) { - val project = data.project - val outputFile = outputFile(project) - val document = MarkdownDocument() - val template = Template(project, document) - - template.writeHeader() - ProjectDependencies.of(data).printTo(document) - template.writeFooter() - - document.writeToFile(outputFile) - } - - private fun outputFile(project: Project): File { - val ext = project.extensions.findByName("licenseReport") as LicenseReportExtension - return File(ext.outputDir).resolve(filename) - } -} - diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt deleted file mode 100644 index 91247e2..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ModuleDataExtensions.kt +++ /dev/null @@ -1,168 +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.gradle.report.license - -import com.github.jk1.license.ModuleData -import io.spine.docs.MarkdownDocument -import kotlin.reflect.KCallable - -/** - * This file declares the Kotlin extensions that help printing `ModuleData` in Markdown format. - */ - -/** - * Prints several of the module data dependencies under the section with the passed [title]. - */ -internal fun MarkdownDocument.printSection( - title: String, - modules: Iterable -): MarkdownDocument { - this.h2(title) - modules.forEach { - printModule(it) - } - return this -} - -/** - * Prints the module metadata to this [MarkdownDocument]. - */ -private fun MarkdownDocument.printModule(module: ModuleData) { - ol() - - this.print(ModuleData::getGroup, module, "Group") - .print(ModuleData::getName, module, "Name") - .print(ModuleData::getVersion, module, "Version") - - val projectUrl = module.projectUrl() - val licenses = module.licenses() - - if (projectUrl.isNullOrEmpty() && licenses.isEmpty()) { - bold("No license information found") - return - } - - @SuppressWarnings("MagicNumber") /* As per the original document layout. */ - val listIndent = 5 - printProjectUrl(projectUrl, listIndent) - printLicenses(licenses, listIndent) - - nl() -} - -/** - * Prints the value of the [ModuleData] property by the passed [getter]. - * - * The property is printed with the passed [title]. - */ -private fun MarkdownDocument.print( - getter: KCallable<*>, - module: ModuleData, - title: String -): MarkdownDocument { - val value = getter.call(module) - if (value != null) { - space().bold(title).and().text(": $value.") - } - return this -} - -/** - * Prints the URL to the project which provides the dependency. - * - * If the passed project URL is `null` or empty, it is not printed. - */ -@Suppress("SameParameterValue" /* Indentation is consistent across the list. */) -private fun MarkdownDocument.printProjectUrl(projectUrl: String?, indent: Int) { - if (!projectUrl.isNullOrEmpty()) { - ul(indent).bold("Project URL:").and().link(projectUrl) - } -} - -/** - * Prints the links to the source code licenses. - */ -@Suppress("SameParameterValue" /* Indentation is consistent across the list. */) -private fun MarkdownDocument.printLicenses(licenses: Set, indent: Int) { - for (license in licenses) { - ul(indent).bold("License:").and() - if (license.url.isNullOrEmpty()) { - text(license.text) - } else { - link(license.text, license.url) - } - } -} - -/** - * Searches for the URL of the project in the module's metadata. - * - * Returns `null` if none is found. - */ -private fun ModuleData.projectUrl(): String? { - val pomUrl = this.poms.firstOrNull()?.projectUrl - if (!pomUrl.isNullOrBlank()) { - return pomUrl - } - return this.manifests.firstOrNull()?.url -} - -/** - * Collects the links to the source code licenses, under which the module dependency is distributed. - */ -private fun ModuleData.licenses(): Set { - val result = mutableSetOf() - - val manifestLicense: License? = manifests.firstOrNull()?.let { manifest -> - val value = manifest.license - if (!value.isNullOrBlank()) { - if (value.startsWith("http")) { - License(value, value) - } else { - License(value, manifest.url) - } - } - null - } - manifestLicense?.let { result.add(it) } - - val pomLicenses = poms.firstOrNull()?.licenses?.map { license -> - License(license.name, license.url) - } - pomLicenses?.let { - result.addAll(it) - } - return result.toSet() -} - -/** - * The source code license with the URL leading to the license text, as defined - * by the project's dependency. - * - * The URL to the license text may be not defined. - */ -private data class License(val text: String, val url: String?) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Paths.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Paths.kt deleted file mode 100644 index 975a73b..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Paths.kt +++ /dev/null @@ -1,49 +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.gradle.report.license - -/** - * Filesystem paths used by [LicenseReporter]. - */ -internal object Paths { - - /** - * The output filename of the license report. - * - * The file with this name is placed to the root folder of the root Gradle project — - * as the result of the [LicenseReporter] work. - * - * Its contents describe the licensing information for each of the Java dependencies - * which are referenced by Gradle projects in the repository. - */ - internal const val outputFilename = "dependencies.md" - - /** - * The path to a directory, to which a per-project report is generated. - */ - internal const val relativePath = "reports/dependency-license/dependency" -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ProjectDependencies.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ProjectDependencies.kt deleted file mode 100644 index d9e569c..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/ProjectDependencies.kt +++ /dev/null @@ -1,70 +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.gradle.report.license - -import com.github.jk1.license.ModuleData -import com.github.jk1.license.ProjectData -import io.spine.docs.MarkdownDocument - -/** - * Dependencies of some [Gradle project][ProjectData] classified by the Gradle configuration - * (such as "runtime") to which they are bound. - */ -internal class ProjectDependencies -private constructor( - private val runtime: Iterable, - private val compileTooling: Iterable -) { - - internal companion object { - - /** - * Creates an instance of [ProjectDependencies] by sorting the module dependencies. - */ - fun of(data: ProjectData): ProjectDependencies { - val runtimeDeps = mutableListOf() - val compileToolingDeps = mutableListOf() - data.configurations.forEach { config -> - if (config.isOneOf(Configuration.runtime, Configuration.runtimeClasspath)) { - runtimeDeps.addAll(config.dependencies) - } else { - compileToolingDeps.addAll(config.dependencies) - } - } - return ProjectDependencies(runtimeDeps.toSortedSet(), compileToolingDeps.toSortedSet()) - } - } - - /** - * Prints the project dependencies along with the licensing information, - * splitting them into "Runtime" and "Compile, tests, and tooling" sections. - */ - internal fun printTo(out: MarkdownDocument) { - out.printSection("Runtime", runtime) - .printSection("Compile, tests, and tooling", compileTooling) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Tasks.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Tasks.kt deleted file mode 100644 index 05df91a..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Tasks.kt +++ /dev/null @@ -1,40 +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.gradle.report.license - -import org.gradle.api.Task -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider - -/** - * Locates `generateLicenseReport` in this [TaskContainer]. - * - * The task generates a license report for a specific Gradle project. License report includes - * information of all dependencies and their licenses. - */ -val TaskContainer.generateLicenseReport: TaskProvider - get() = named("generateLicenseReport") diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt deleted file mode 100644 index 15bd24d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/license/Template.kt +++ /dev/null @@ -1,76 +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.gradle.report.license - -import io.spine.docs.MarkdownDocument -import io.spine.gradle.artifactId -import java.util.Date -import org.gradle.api.Project - -/** - * The template text pieces of the license report. - */ -internal class Template( - private val project: Project, - private val out: MarkdownDocument -) { - - private companion object { - @Suppress("ConstPropertyName") - private const val longBreak = "\n\n" - } - - internal fun writeHeader() = with(project) { - out.nl() - .h1("Dependencies of `$group:$artifactId:$version`") - .nl() - } - - internal fun writeFooter() { - val currentTime = Date() - out.text(longBreak) - .text("The dependencies distributed under several licenses, ") - .text("are used according their commercial-use-friendly license.") - .text(longBreak) - .text("This report was generated on ") - .bold("$currentTime") - .text(" using ") - .nl() - .link( - "Gradle-License-Report plugin", - "https://github.com/jk1/Gradle-License-Report" - ) - .text(" by Evgeny Naumenko, ") - .text("licensed under ") - .nl() - .link( - "Apache 2.0 License", - "https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE" - ) - .text(".") - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyScope.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyScope.kt deleted file mode 100644 index 1b4f478..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyScope.kt +++ /dev/null @@ -1,45 +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.gradle.report.pom - -/** - * A Maven dependency scope. - */ -@Suppress("EnumEntryName", "EnumNaming") /* Dubbing the actual values in Gradle. */ -enum class DependencyScope { - undefined, - compile, - provided, - runtime, - test, - system - - /** - `import` is also a scope, however, it can't be used outside the `` - section, which is outside of the scope of this script - **/ -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt deleted file mode 100644 index eda2493..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/DependencyWriter.kt +++ /dev/null @@ -1,207 +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.gradle.report.pom - -import groovy.xml.MarkupBuilder -import java.io.Writer -import java.util.* -import kotlin.reflect.full.isSubclassOf -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.Dependency -import org.gradle.api.internal.artifacts.dependencies.AbstractExternalModuleDependency -import org.gradle.kotlin.dsl.withGroovyBuilder - -/** - * Writes the dependencies of a Gradle project in a `pom.xml` format. - * - * Includes the dependencies of the subprojects. Does not include - * the transitive dependencies. - * - * ``` - * - * - * io.spine - * base - * 2.0.0-pre1 - * - * ... - * - * ``` - * - * When there are several versions of the same dependency, only the one with - * the newest version is retained. - * - * @see PomGenerator - */ -internal class DependencyWriter -private constructor( - private val dependencies: SortedSet -) { - internal companion object { - - /** - * Creates the `ProjectDependenciesAsXml` for the passed [project]. - */ - fun of(project: Project): DependencyWriter { - return DependencyWriter(project.dependencies()) - } - } - - /** - * Writes the dependencies in their `pom.xml` format to the passed [out] writer. - * - *

Used writer will not be closed. - */ - fun writeXmlTo(out: Writer) { - val xml = MarkupBuilder(out) - xml.withGroovyBuilder { - "dependencies" { - dependencies.forEach { scopedDep -> - val dependency = scopedDep.dependency() - "dependency" { - "groupId" { xml.text(dependency.group) } - "artifactId" { xml.text(dependency.name) } - "version" { xml.text(dependency.version) } - if (scopedDep.hasDefinedScope()) { - "scope" { xml.text(scopedDep.scopeName()) } - } - } - } - } - } - } -} - -/** - * Returns the [scoped dependencies][ScopedDependency] of a Gradle project. - */ -fun Project.dependencies(): SortedSet { - val dependencies = mutableSetOf() - dependencies.addAll(this.depsFromAllConfigurations()) - - this.subprojects.forEach { subproject -> - val subprojectDeps = subproject.depsFromAllConfigurations() - dependencies.addAll(subprojectDeps) - } - - val result = deduplicate(dependencies) - .map { it.scoped } - .toSortedSet() - return result -} - -/** - * Returns the external dependencies of the project from all the project configurations. - */ -private fun Project.depsFromAllConfigurations(): Set { - val result = mutableSetOf() - this.configurations.forEach { configuration -> - if (configuration.isCanBeResolved) { - // Force resolution of the configuration. - configuration.resolvedConfiguration - } - configuration.dependencies.filter { it.isExternal() } - .forEach { dependency -> - val forcedVersion = configuration.forcedVersionOf(dependency) - val moduleDependency = - if (forcedVersion != null) { - ModuleDependency(project, configuration, dependency, forcedVersion) - } else { - ModuleDependency(project, configuration, dependency) - } - result.add(moduleDependency) - } - } - return result -} - -/** - * Searches for a forced version of given [dependency] in this [Configuration]. - * - * Returns `null`, if it wasn't forced. - */ -private fun Configuration.forcedVersionOf(dependency: Dependency): String? { - val forcedModules = resolutionStrategy.forcedModules - val maybeForced = forcedModules.firstOrNull { - it.group == dependency.group - && it.name == dependency.name - && it.version != null - } - return maybeForced?.version -} - -/** - * Tells whether the dependency is an external module dependency. - */ -private fun Dependency.isExternal(): Boolean { - return this.javaClass.kotlin.isSubclassOf(AbstractExternalModuleDependency::class) -} - -/** - * Filters out duplicated dependencies by group and name. - * - * When there are several versions of the same dependency, the method will retain only - * the one with the newest version. - * - * Sometimes, a project uses several versions of the same dependency. This may happen - * when different modules of the project use different versions of the same dependency. - * But for our `pom.xml`, which has clearly representative character, a single version - * of a dependency is quite enough. - * - * The rejected duplicates are logged. - */ -private fun Project.deduplicate(dependencies: Set): List { - val groups = dependencies.distinctBy { it.gav } - .groupBy { it.run { "$group:$name" } } - - logDuplicates(groups) - - val filtered = groups.map { group -> - group.value.maxByOrNull { dep -> dep.version ?: "" } - }.filterNotNull() - return filtered -} - -private fun Project.logDuplicates(dependencies: Map>) { - dependencies.filter { it.value.size > 1 } - .forEach { (dependency, versions) -> logDuplicate(dependency, versions) } -} - -private fun Project.logDuplicate(dependency: String, versions: List) { - logger.lifecycle("") - logger.lifecycle("The project uses several versions of `$dependency` dependency.") - - versions.forEach { - logger.lifecycle( - "module: {}, configuration: {}, version: {}", - it.project.name, - it.configuration.name, - it.version - ) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/InceptionYear.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/InceptionYear.kt deleted file mode 100644 index cb25b3d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/InceptionYear.kt +++ /dev/null @@ -1,51 +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.gradle.report.pom - -import groovy.xml.MarkupBuilder -import java.io.StringWriter -import org.gradle.kotlin.dsl.withGroovyBuilder - -/** - * Information about the Spine's inception year. - */ -internal object InceptionYear { - - private const val SPINE_INCEPTION_YEAR = "2015" - - /** - * Returns a string containing the inception year of Spine in a `pom.xml` format. - */ - override fun toString(): String { - val writer = StringWriter() - val xml = MarkupBuilder(writer) - xml.withGroovyBuilder { - "inceptionYear" { xml.text(SPINE_INCEPTION_YEAR) } - } - return writer.toString() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/MarkupExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/MarkupExtensions.kt deleted file mode 100644 index 0612f2e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/MarkupExtensions.kt +++ /dev/null @@ -1,38 +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.gradle.report.pom - -import groovy.xml.MarkupBuilder - -/** - * This file contains extension methods and properties for the Groovy's `MarkupBuilder`. - */ - -/** - * Yields a [value] to the document by converting it to string. - */ -fun MarkupBuilder.text(value: Any?) = this.mkp.yield(value.toString()) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt deleted file mode 100644 index 3d72de1..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ModuleDependency.kt +++ /dev/null @@ -1,95 +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.gradle.report.pom - -import org.gradle.api.Project -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.Dependency - -/** - * A module's dependency. - * - * Contains information about a module and configuration, from which - * the dependency comes. - */ -internal class ModuleDependency( - val project: Project, - val configuration: Configuration, - private val dependency: Dependency, - private val factualVersion: String? = dependency.version - -) : Dependency by dependency, Comparable { - - companion object { - private val COMPARATOR = compareBy { it.project } - .thenBy { it.configuration.name } - .thenBy { it.group } - .thenBy { it.name } - .thenBy { it.factualVersion } - } - - override fun getVersion(): String? = factualVersion - - /** - * A project dependency with its [scope][DependencyScope]. - * - * Doesn't contain any info about an origin module and configuration. - */ - val scoped = ScopedDependency.of(this, configuration) - - /** - * GAV coordinates of this dependency. - * - * Gradle's [Dependency] is a mutable object. Its properties can change their - * values with time. In particular, the version can be changed as more - * configurations are getting resolved. This is why this property is calculated. - */ - val gav: String - get() = "$group:$name:$factualVersion" - - override fun compareTo(other: ModuleDependency): Int = COMPARATOR.compare(this, other) - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as ModuleDependency - - if (project != other.project) return false - if (configuration != other.configuration) return false - if (gav != other.gav) return false - - return true - } - - override fun hashCode(): Int { - var result = project.hashCode() - result = 31 * result + configuration.hashCode() - result = 31 * result + gav.hashCode() - return result - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt deleted file mode 100644 index 15059ea..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomFormatting.kt +++ /dev/null @@ -1,111 +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.gradle.report.pom - -import java.io.StringWriter -import java.lang.System.lineSeparator -import java.util.* - -/** - * Helps to format the `pom.xml` file according to its expected XML structure. - */ -internal object PomFormatting { - - private val NL = lineSeparator() - private const val XML_METADATA = "" - private const val PROJECT_SCHEMA_LOCATION = "" - private const val MODEL_VERSION = "4.0.0" - private const val CLOSING_PROJECT_TAG = "" - - /** - * Writes the starting segment of `pom.xml`. - */ - internal fun writeStart(dest: StringWriter) { - dest.write( - XML_METADATA, - NL, - PROJECT_SCHEMA_LOCATION, - NL, - MODEL_VERSION, - NL, - describingComment(), - NL - ) - } - - /** - * Obtains a description comment that describes the nature of the generated `pom.xml` file. - */ - private fun describingComment(): String { - val description = NL + - "This file was generated using the Gradle `generatePom` task. " + - NL + - "This file is not suitable for `maven` build tasks. It only describes the " + - "first-level dependencies of " + - NL + - "all modules and does not describe the project " + - "structure per-subproject." + - NL - return String.format( - Locale.US, - "", - NL, description, NL - ) - } - - /** - * Writes the closing segment of `pom.xml`. - */ - internal fun writeEnd(dest: StringWriter) { - dest.write(CLOSING_PROJECT_TAG) - } - - /** - * Writes the specified lines using the specified [destination], dividing them - * by platform-specific line separator. - * - * Each written line is followed by two platform-specific line separators. - */ - internal fun writeBlocks(destination: StringWriter, vararg lines: String) { - lines.iterator().forEach { - destination.write(it, NL, NL) - } - } - - /** - * Writes each of the passed sequences. - */ - private fun StringWriter.write(vararg content: String) { - content.forEach { - this.write(it) - } - } -} 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 deleted file mode 100644 index 6e986e1..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomGenerator.kt +++ /dev/null @@ -1,99 +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.gradle.report.pom - -import org.gradle.api.Project -import org.gradle.api.plugins.BasePlugin - -/** - * Generates a `pom.xml` file that contains dependencies of the root project as - * well as the dependencies of its subprojects. - * - * Usage: - * ``` - * PomGenerator.applyTo(project) - * ``` - * - * The generated `pom.xml` is not usable for Maven build tasks and is merely a - * description of project dependencies. - * - * Configures the `build` task to generate the `pom.xml` file. - * - * Note that the generated `pom.xml` includes the group ID, artifact ID and the version of the - * project this script was applied to. In case you want to override the default values, do so in - * the `ext` block like so: - * - * ``` - * ext { - * groupId = 'custom-group-id' - * artifactId = 'custom-artifact-id' - * version = 'custom-version' - * } - * ``` - * - * By default, those values are taken from the `project` object, which may or may not include - * them. If the project does not have these values, and they are not specified in the `ext` - * block, the resulting `pom.xml` file is going to contain empty blocks, - * e.g., ``. - */ -@Suppress("unused") -object PomGenerator { - - /** - * Configures the generator for the passed [project]. - */ - fun applyTo(project: Project) { - - /** - * In some cases, the `base` plugin, which by default is added by e.g. `java`, - * is not yet added. - * - * The `base` plugin defines the `build` task. - * This generator needs it. - */ - project.apply { - plugin(BasePlugin::class.java) - } - - 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 assembleTask = project.tasks.findByName("assemble")!! - dependsOn(assembleTask) - } - - val buildTask = project.tasks.findByName("build")!! - buildTask.finalizedBy(task) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt deleted file mode 100644 index a0b1ade..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/PomXmlWriter.kt +++ /dev/null @@ -1,84 +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.gradle.report.pom - -import io.spine.gradle.report.pom.PomFormatting.writeBlocks -import io.spine.gradle.report.pom.PomFormatting.writeStart -import java.io.File -import java.io.FileWriter -import java.io.StringWriter - -/** - * Writes the dependencies of a Gradle project and its subprojects as a `pom.xml` file. - * - * The resulting file is not usable for `maven` build tasks but serves as a description - * of the first-level dependencies for each project or subproject. - * Their transitive dependencies are not included in the result. - */ -internal class PomXmlWriter -internal constructor( - private val projectMetadata: ProjectMetadata -) { - - /** - * Writes the `pom.xml` file containing dependencies of this project - * and its subprojects to the specified location. - * - *

If a file with the specified location exists, its contents will be substituted - * with a new `pom.xml`. - * - * @param file a file to write `pom.xml` contents to. - */ - fun writeTo(file: File) { - val out = StringWriter() - writeStart(out) - writeBlocks( - out, - projectMetadata.toString(), - InceptionYear.toString(), - SpineLicense.toString(), - projectDependencies() - ) - PomFormatting.writeEnd(out) - - FileWriter(file).use { - it.write(out.toString()) - } - } - - /** - * Obtains a string that contains project dependencies as XML. - * - *

Obtained string also contains a closing project tag. - */ - private fun projectDependencies(): String { - val destination = StringWriter() - val dependencyWriter = DependencyWriter.of(projectMetadata.project) - dependencyWriter.writeXmlTo(destination) - return destination.toString() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ProjectMetadata.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ProjectMetadata.kt deleted file mode 100644 index ffb89a2..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ProjectMetadata.kt +++ /dev/null @@ -1,103 +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.gradle.report.pom - -import groovy.xml.MarkupBuilder -import java.io.StringWriter -import kotlin.reflect.KProperty -import org.gradle.api.Project -import org.gradle.kotlin.dsl.PropertyDelegate -import org.gradle.kotlin.dsl.extra -import org.gradle.kotlin.dsl.provideDelegate -import org.gradle.kotlin.dsl.withGroovyBuilder - -/** - * Information about the Gradle project. - * - * Includes group ID, artifact name, and the version. - */ -@Suppress("MemberVisibilityCanBePrivate") /* Property values accessed via `KProperty`. */ -internal class ProjectMetadata -internal constructor( - internal val project: Project, - internal val groupId: String, - internal val artifactId: String, - internal val version: String -) { - - /** - * Returns an XML string containing the project metadata. - * - * The XML format is compatible with the one defined for Maven's `pom.xml`. - */ - override fun toString(): String { - val writer = StringWriter() - MarkupBuilder(writer).tagsFor(::groupId, ::artifactId, ::version) - return writer.toString() - } - - private fun MarkupBuilder.tagsFor(vararg property: KProperty<*>) { - property.forEach { - this.withGroovyBuilder { - it.name { this@tagsFor.text(it.call()) } - } - } - } -} - -/** - * Creates a new instance of [ProjectMetadata]. - * - * The required information is first retrieved from the project. - * And if a property is missing from the `project`, it is taken from the `extra` extension - * of project's root project. - */ -internal fun Project.metadata(): ProjectMetadata { - val groupId: String by nonEmptyValue(group) - val artifactId: String by nonEmptyValue(name) - val version: String by project.nonEmptyValue(this.version) - return ProjectMetadata(project, groupId, artifactId, version) -} - -private fun Project.nonEmptyValue(prop: Any): NonEmptyValue { - return NonEmptyValue(prop.toString(), this) -} - -private class NonEmptyValue( - private val defaultValue: String, - private val project: Project -) : PropertyDelegate { - - @Suppress("UNCHECKED_CAST") - override fun getValue(receiver: Any?, property: KProperty<*>): T { - if (defaultValue.isNotEmpty()) { - return defaultValue as T - } - val result = project.rootProject.extra[property.name] - return result as T - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ScopedDependency.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ScopedDependency.kt deleted file mode 100644 index 7c67a32..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/ScopedDependency.kt +++ /dev/null @@ -1,179 +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.gradle.report.pom - -import io.spine.gradle.report.pom.DependencyScope.compile -import io.spine.gradle.report.pom.DependencyScope.provided -import io.spine.gradle.report.pom.DependencyScope.runtime -import io.spine.gradle.report.pom.DependencyScope.test -import io.spine.gradle.report.pom.DependencyScope.undefined -import org.gradle.api.artifacts.Configuration -import org.gradle.api.artifacts.Dependency - -/** - * A project dependency with its [scope][DependencyScope]. - * - * See [More on dependency scopes](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope). - */ -class ScopedDependency -private constructor( - private val dependency: Dependency, - private val scope: DependencyScope -) : Comparable { - - internal companion object { - - /** - * A map that contains the relations of known Gradle configuration names - * to their Maven dependency scope equivalents. - */ - private val CONFIG_TO_SCOPE = mapOf( - - /** - * Configurations from the Gradle Java plugin that are known to be mapped - * to the `compile` scope. - * - * Dependencies with the `compile` Maven scope are propagated to dependent projects. - * - * More on that in the [Gradle docs](https://docs.gradle.org/current/userguide/java_plugin.html#tab:configurations). - */ - "compile" to compile, - "implementation" to compile, - "api" to compile, - - /** - * Configurations from the Gradle Java plugin that are known to be mapped - * to the `runtime` scope. - * - * Dependencies with the `runtime` Maven scopes are required for execution only. - */ - "runtime" to runtime, - "runtimeOnly" to runtime, - "runtimeClasspath" to runtime, - "default" to runtime, - - /** - * Configurations from the Gradle Java plugin that are known to be mapped - * to the `provided` scope. - * - * Dependencies with the `provided` Maven scope are not propagated to dependent projects - * but are required during the compilation. - */ - "compileOnly" to provided, - "compileOnlyApi" to provided, - "annotationProcessor" to provided - ) - - /** - * Creates a `ScopedDependency` for the given [dependency] - * judging on the passed [configuration]. - */ - fun of(dependency: Dependency, configuration: Configuration): ScopedDependency { - val configurationName = configuration.name - val knownScope = CONFIG_TO_SCOPE[configurationName] - return when { - knownScope != null -> ScopedDependency(dependency, knownScope) - isTestsRelated(configurationName) -> ScopedDependency(dependency, test) - else -> ScopedDependency(dependency, undefined) - } - } - - private fun isTestsRelated(configurationName: String): Boolean = - configurationName.startsWith("test", ignoreCase = true) - - /** - * Performs comparison of {@code DependencyWithScope} instances according to these rules: - * - * * Compares the scope of the dependency first. Dependency with lower scope priority - * number goes first. - * - * * For dependencies with same scope, does the lexicographical group name comparison. - * - * * For dependencies within the same group, does the lexicographical artifact - * name comparison. - * - * * For dependencies with the same artifact name, does the lexicographical artifact - * version comparison. - */ - private val COMPARATOR: Comparator = - compareBy { it.dependencyPriority() } - .thenBy { it.dependency.group } - .thenBy { it.dependency.name } - .thenBy { it.dependency.version } - } - - /** - * Returns `true` if this dependency has a defined scope, returns `false` otherwise. - */ - fun hasDefinedScope(): Boolean { - return scope != undefined - } - - /** Obtains the Gradle dependency. */ - fun dependency(): Dependency { - return dependency - } - - /** Obtains the scope name of this dependency .*/ - fun scopeName(): String { - return scope.name - } - - /** - * Obtains the layout priority of a scope. - * - * Layout priority determines what scopes come first in the generated `pom.xml` file. - * Dependencies with a lower priority number go on top. - */ - internal fun dependencyPriority(): Int { - return when (scope) { - compile -> 0 - runtime -> 1 - test -> 2 - else -> 3 - } - } - - override fun compareTo(other: ScopedDependency): Int { - return COMPARATOR.compare(this, other) - } - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is ScopedDependency) return false - - if (dependency.group != other.dependency.group) return false - if (dependency.name != other.dependency.name) return false - if (dependency.version != other.dependency.version) return false - - return true - } - - override fun hashCode(): Int { - return dependency.hashCode() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/SpineLicense.kt b/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/SpineLicense.kt deleted file mode 100644 index 114395e..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/report/pom/SpineLicense.kt +++ /dev/null @@ -1,59 +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.gradle.report.pom - -import groovy.xml.MarkupBuilder -import java.io.StringWriter -import org.gradle.kotlin.dsl.withGroovyBuilder - -/** - * The licensing information of Spine. - */ -internal object SpineLicense { - - private const val NAME = "Apache License, Version 2.0" - private const val URL = "https://www.apache.org/licenses/LICENSE-2.0.txt" - private const val DISTRIBUTION = "repo" - - /** - * Returns the licensing information as an XML fragment compatible with `pom.xml` format. - */ - override fun toString(): String { - val result = StringWriter() - val xml = MarkupBuilder(result) - xml.withGroovyBuilder { - "licenses" { - "license" { - "name" { xml.text(NAME) } - "url" { xml.text(URL) } - "distribution" { xml.text(DISTRIBUTION) } - } - } - } - return result.toString() - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt index 1f5ed49..f8635e5 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt @@ -26,7 +26,6 @@ package io.spine.gradle.testing -import io.spine.gradle.publish.testJar import org.gradle.api.Project /** @@ -68,8 +67,5 @@ fun Project.exposeTestConfiguration() { configurations.create("testArtifacts") { extendsFrom(configurations.getByName("testRuntimeClasspath")) - outgoing { - artifact(testJar()) - } } } diff --git a/buildSrc/src/main/kotlin/jacoco-kotlin-jvm.gradle.kts b/buildSrc/src/main/kotlin/jacoco-kotlin-jvm.gradle.kts deleted file mode 100644 index 48fb126..0000000 --- a/buildSrc/src/main/kotlin/jacoco-kotlin-jvm.gradle.kts +++ /dev/null @@ -1,67 +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. - */ - -import io.spine.gradle.buildDirectory - -plugins { - jacoco -} - -/** - * Configures [JacocoReport] task to run in a Kotlin Multiplatform project for - * `commonMain` and `jvmMain` source sets. - * - * This script plugin must be applied using the following construct at the end of - * a `build.gradle.kts` file of a module: - * - * ```kotlin - * apply(plugin="jacoco-kotlin-jvm") - * ``` - * Please do not apply this script plugin in the `plugins {}` block because `jacocoTestReport` - * task is not yet available at this stage. - */ -@Suppress("unused") -private val about = "" - -/** - * Configure Jacoco task with custom input from this Kotlin Multiplatform project. - */ -@Suppress("unused") -val jacocoTestReport: JacocoReport by tasks.getting(JacocoReport::class) { - - val classFiles = File("$buildDirectory/classes/kotlin/jvm/") - .walkBottomUp() - .toSet() - classDirectories.setFrom(classFiles) - - val coverageSourceDirs = arrayOf( - "src/commonMain", - "src/jvmMain" - ) - sourceDirectories.setFrom(files(coverageSourceDirs)) - - executionData.setFrom(files("$buildDirectory/jacoco/jvmTest.exec")) -} diff --git a/buildSrc/src/main/kotlin/jvm-module.gradle.kts b/buildSrc/src/main/kotlin/jvm-module.gradle.kts deleted file mode 100644 index c409950..0000000 --- a/buildSrc/src/main/kotlin/jvm-module.gradle.kts +++ /dev/null @@ -1,203 +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. - */ - -import BuildSettings.javaVersion -import io.spine.dependency.build.CheckerFramework -import io.spine.dependency.build.Dokka -import io.spine.dependency.build.ErrorProne -import io.spine.dependency.lib.Guava -import io.spine.dependency.lib.JavaX -import io.spine.dependency.lib.Protobuf -import io.spine.dependency.local.Logging -import io.spine.dependency.local.Reflect -import io.spine.dependency.local.TestLib -import io.spine.dependency.test.JUnit -import io.spine.dependency.test.Jacoco -import io.spine.dependency.test.Kotest -import io.spine.gradle.checkstyle.CheckStyleConfig -import io.spine.gradle.github.pages.updateGitHubPages -import io.spine.gradle.javac.configureErrorProne -import io.spine.gradle.javac.configureJavac -import io.spine.gradle.javadoc.JavadocConfig -import io.spine.gradle.kotlin.applyJvmToolchain -import io.spine.gradle.kotlin.setFreeCompilerArgs -import io.spine.gradle.report.license.LicenseReporter -import io.spine.gradle.testing.configureLogging -import io.spine.gradle.testing.registerTestTasks - -plugins { - `java-library` - idea - id("net.ltgt.errorprone") - id("pmd-settings") - id("project-report") - id("dokka-for-java") - kotlin("jvm") - id("io.kotest") - id("org.jetbrains.kotlinx.kover") - id("detekt-code-analysis") - id("dokka-for-kotlin") -} - -LicenseReporter.generateReportIn(project) -JavadocConfig.applyTo(project) -CheckStyleConfig.applyTo(project) - -project.run { - configureJava(javaVersion) - configureKotlin(javaVersion) - addDependencies() - forceConfigurations() - - val generatedDir = "$projectDir/generated" - setTaskDependencies(generatedDir) - setupTests() - - configureGitHubPages() -} - -typealias Module = Project - -fun Module.configureJava(javaVersion: JavaLanguageVersion) { - java { - toolchain.languageVersion.set(javaVersion) - } - - tasks { - withType().configureEach { - configureJavac() - configureErrorProne() - } - } -} - -fun Module.configureKotlin(javaVersion: JavaLanguageVersion) { - kotlin { - applyJvmToolchain(javaVersion.asInt()) - explicitApi() - compilerOptions { - jvmTarget.set(BuildSettings.jvmTarget) - setFreeCompilerArgs() - } - } - - kover { - useJacoco(version = Jacoco.version) - } - - koverReport { - defaults { - xml { - onCheck = true - } - } - } -} - -/** - * These dependencies are applied to all subprojects and do not have to - * be included explicitly. - * - * We expose production code dependencies as API because they are used - * by the framework parts that depend on `base`. - */ -fun Module.addDependencies() = dependencies { - errorprone(ErrorProne.core) - - Protobuf.libs.forEach { api(it) } - api(Guava.lib) - - compileOnlyApi(CheckerFramework.annotations) - compileOnlyApi(JavaX.annotations) - ErrorProne.annotations.forEach { compileOnlyApi(it) } - - implementation(Logging.lib) - - testImplementation(Guava.testLib) - testImplementation(JUnit.runner) - testImplementation(JUnit.pioneer) - JUnit.api.forEach { testImplementation(it) } - - testImplementation(TestLib.lib) - testImplementation(Kotest.frameworkEngine) - testImplementation(Kotest.datatest) - testImplementation(Kotest.runnerJUnit5Jvm) - testImplementation(JUnit.runner) -} - -fun Module.forceConfigurations() { - with(configurations) { - forceVersions() - excludeProtobufLite() - all { - resolutionStrategy { - force( - JUnit.bom, - JUnit.runner, - Dokka.BasePlugin.lib, - Reflect.lib, - ) - } - } - } -} - -fun Module.setupTests() { - tasks { - registerTestTasks() - test.configure { - useJUnitPlatform { - includeEngines("junit-jupiter") - } - configureLogging() - } - } -} - -fun Module.setTaskDependencies(generatedDir: String) { - tasks { - val cleanGenerated by registering(Delete::class) { - delete(generatedDir) - } - clean.configure { - dependsOn(cleanGenerated) - } - - project.afterEvaluate { - val publish = tasks.findByName("publish") - publish?.dependsOn("${project.path}:updateGitHubPages") - } - } - configureTaskDependencies() -} - -fun Module.configureGitHubPages() { - val docletVersion = project.version.toString() - updateGitHubPages(docletVersion) { - allowInternalJavadoc.set(true) - rootFolder.set(rootDir) - } -} diff --git a/buildSrc/src/main/kotlin/pmd-settings.gradle.kts b/buildSrc/src/main/kotlin/pmd-settings.gradle.kts deleted file mode 100644 index 0373ee0..0000000 --- a/buildSrc/src/main/kotlin/pmd-settings.gradle.kts +++ /dev/null @@ -1,56 +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. - */ - -import io.spine.dependency.build.Pmd - -plugins { - pmd -} - -pmd { - toolVersion = Pmd.version - isConsoleOutput = true - incrementalAnalysis.set(true) - - // The build is going to fail in case of violations. - isIgnoreFailures = false - - // Disable the default rule set to use the custom rules (see below). - ruleSets = listOf() - - // Load PMD settings. - val pmdSettings = file("$rootDir/config/quality/pmd.xml") - val textResource: TextResource = resources.text.fromFile(pmdSettings) - ruleSetConfig = textResource - - reportsDir = file("build/reports/pmd") - - // Just analyze the main sources; do not analyze tests. - val javaExtension: JavaPluginExtension = - project.extensions.getByType(JavaPluginExtension::class.java) - val mainSourceSet = javaExtension.sourceSets.getByName("main") - sourceSets = listOf(mainSourceSet) -} diff --git a/buildSrc/src/main/kotlin/write-manifest.gradle.kts b/buildSrc/src/main/kotlin/write-manifest.gradle.kts deleted file mode 100644 index b63d327..0000000 --- a/buildSrc/src/main/kotlin/write-manifest.gradle.kts +++ /dev/null @@ -1,165 +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. - */ - -import io.spine.gradle.publish.SpinePublishing -import java.nio.file.Files.createDirectories -import java.nio.file.Files.createFile -import java.text.SimpleDateFormat -import java.util.* -import java.util.jar.Attributes.Name.IMPLEMENTATION_TITLE -import java.util.jar.Attributes.Name.IMPLEMENTATION_VENDOR -import java.util.jar.Attributes.Name.IMPLEMENTATION_VERSION -import java.util.jar.Attributes.Name.MANIFEST_VERSION -import java.util.jar.Manifest - -plugins { - java -} - -/** - * Obtains a string value of a [System] property with the given key. - */ -fun prop(key: String): String = System.getProperties()[key].toString() - -/** - * Obtains the current time in UTC using ISO 8601 format. - */ -fun currentTime(): String = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(Date()) - -/** - * Obtains the information on the JDK used for the build. - */ -fun buildJdk(): String = - "${prop("java.version")} (${prop("java.vendor")} ${prop("java.vm.version")})" - -/** - * Obtains the information on the operating system used for the build. - */ -fun buildOs(): String = - "${prop("os.name")} ${prop("os.arch")} ${prop("os.version")}" - -/** The publishing settings from the root project. */ -val spinePublishing = rootProject.the() -val artifactPrefix = spinePublishing.artifactPrefix - -/** - * Obtains the implementation title for the project using project group, - * artifact prefix from [SpinePublishing], and the name of the project to which - * this script plugin is applied. - */ -fun implementationTitle() = "${project.group}:$artifactPrefix${project.name}" - -/** - * The name of the manifest attribute holding the timestamp of the build. - */ -val buildTimestampAttr = "Build-Timestamp" - -/** - * The attributes we put into the JAR manifest. - * - * This map is shared between the [exposeManifestForTests] task and the action which - * customizes the [Jar] task below. - */ -val manifestAttributes = mapOf( - "Built-By" to prop("user.name"), - buildTimestampAttr to currentTime(), - "Created-By" to "Gradle ${gradle.gradleVersion}", - "Build-Jdk" to buildJdk(), - "Build-OS" to buildOs(), - IMPLEMENTATION_TITLE.toString() to implementationTitle(), - IMPLEMENTATION_VERSION.toString() to project.version, - IMPLEMENTATION_VENDOR.toString() to "TeamDev", - "Bundle-License" to "https://www.apache.org/licenses/LICENSE-2.0.txt" -) - -/** - * Creates a manifest file in `resources` so that it is available for the tests. - * - * This task does the same what does the block which configures the `tasks.jar` below. - * We cannot use the manifest file created by the `Jar` task because it's not visible - * when running tests. We cannot depend on the `Jar` from `resources` because it would - * form a circular dependency. - */ -val exposeManifestForTests by tasks.registering { - - val outputFile = layout.buildDirectory.file("resources/main/META-INF/MANIFEST.MF") - outputs.file(outputFile).withPropertyName("manifestFile") - - fun createManifest(): Manifest { - val manifest = Manifest() - - // The manifest version attribute is crucial for writing. - // If it's absent, nothing would be written. - manifest.mainAttributes[MANIFEST_VERSION] = "1.0" - - manifestAttributes.forEach { entry -> - manifest.mainAttributes.putValue(entry.key, entry.value.toString()) - } - return manifest - } - - fun writeManifest(manifest: Manifest) { - val file = outputFile.get().getAsFile() - val path = file.toPath() - createDirectories(path.parent) - if (!file.exists()) { - createFile(path) - } - val stream = file.outputStream() - stream.use { - manifest.write(stream) - } - } - - doLast { - val manifest = createManifest() - writeManifest(manifest) - } -} - -tasks.processResources { - dependsOn(exposeManifestForTests) -} - -tasks.jar { - manifest { - attributes(manifestAttributes) - } -} - -/** - * Makes Gradle ignore the [buildTimestampAttr] attribute during normalization. - * - * See [Java META-INF normalization](https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:meta_inf_normalization) - * section of the Gradle documentation for details. - */ -normalization { - runtimeClasspath { - metaInf { - ignoreAttribute(buildTimestampAttr) - } - } -} diff --git a/gradle.properties b/gradle.properties index 86386ff..652083b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,4 +26,4 @@ org.gradle.jvmargs=-XX:+UseParallelGC -Xmx4096M -org.gradle.debug=true +# org.gradle.debug=true From 0bb3ef6c2f794c18df5f8daccb1e1c4a10d2a227 Mon Sep 17 00:00:00 2001 From: Alexander Yevsyukov Date: Sun, 28 Sep 2025 19:44:08 +0100 Subject: [PATCH 14/25] Trim down `buildSrc` more --- .../kotlin/io/spine/docs/MarkdownDocument.kt | 119 ----- .../kotlin/io/spine/gradle/java/Linters.kt | 61 --- .../main/kotlin/io/spine/gradle/java/Tasks.kt | 45 -- .../io/spine/gradle/javac/ErrorProne.kt | 89 ---- .../kotlin/io/spine/gradle/javac/Javac.kt | 74 --- .../io/spine/gradle/kotlin/KotlinConfig.kt | 71 --- .../gradle/protobuf/ProtoTaskExtensions.kt | 456 ------------------ 7 files changed, 915 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/io/spine/docs/MarkdownDocument.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/java/Tasks.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javac/ErrorProne.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/javac/Javac.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt diff --git a/buildSrc/src/main/kotlin/io/spine/docs/MarkdownDocument.kt b/buildSrc/src/main/kotlin/io/spine/docs/MarkdownDocument.kt deleted file mode 100644 index 23937bd..0000000 --- a/buildSrc/src/main/kotlin/io/spine/docs/MarkdownDocument.kt +++ /dev/null @@ -1,119 +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.docs - -import java.io.File - -/** - * A virtual document written in Markdown. - * - * After it's finished, end-users would typically write it to a [real file][writeToFile]. - */ -@Suppress("TooManyFunctions") -class MarkdownDocument { - - private val builder: StringBuilder = StringBuilder() - - /** - * Appends the document with some plain text. - */ - fun text(value: String): MarkdownDocument { - builder.append(value) - return this - } - - /** - * Appends the document with a new line symbol. - */ - fun nl(): MarkdownDocument = text(System.lineSeparator()) - - /** - * Appends the document with a single space. - */ - fun space(): MarkdownDocument = text(" ") - - /** - * Appends the document with a number of space symbols. - */ - private fun space(count: Int): MarkdownDocument { - repeat(count) { - space() - } - return this - } - - /** - * Appends the document with a space symbol. - * - * A DSL-style shortcut for [space]. - */ - fun and(): MarkdownDocument = space() - - /** - * Adds some text rendered in bold. - */ - fun bold(text: String): MarkdownDocument = text("**$text**") - - /** - * Adds a heading of level 1. - */ - fun h1(text: String): MarkdownDocument = nl().text("# $text") - - /** - * Adds a heading of level 2. - */ - fun h2(text: String): MarkdownDocument = nl().text("## $text") - - /** - * Adds a link. - */ - fun link(text: String, url: String): MarkdownDocument = text("[$text](${url})") - - /** - * Adds a link and uses the passed [url] value as both text and a navigation destination. - */ - fun link(url: String): MarkdownDocument = link(url, url) - - /** - * Renders the item of an unordered list, also indenting it by the specified number of spaces. - */ - fun ul(indent: Int): MarkdownDocument = nl().space(indent).text("* ") - - /** - * Renders the item of an ordered list. - */ - fun ol(): MarkdownDocument = nl().text("1. ") - - /** - * Writes the content of this document to the passed file. - * - * If the file exists, it becomes overwritten. - */ - fun writeToFile(file: File) { - file.writeText(builder.toString()) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt b/buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt deleted file mode 100644 index fc00555..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/java/Linters.kt +++ /dev/null @@ -1,61 +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.gradle.java - -import net.ltgt.gradle.errorprone.errorprone -import org.gradle.api.Project -import org.gradle.api.tasks.compile.JavaCompile -import org.gradle.kotlin.dsl.invoke -import org.gradle.kotlin.dsl.named - -/** - * Disables Java linters in this [Project]. - * - * In particular, the following linters will be disabled: - * - * 1. CheckStyle. - * 2. PMD. - * 3. ErrorProne. - * - * Apply this configuration for modules that have original Flogger sources, - * which have not been migrated to Kotlin yet. They produce a lot of - * errors/warnings failing the build. - * - * Our own sources are mostly in Kotlin (as for `spine-logging` repo), - * so this action seems quite safe. - */ -// TODO:2023-09-22:yevhenii.nadtochii: Remove this piece of configuration. -// See issue: https://github.com/SpineEventEngine/logging/issues/56 -fun Project.disableLinters() { - tasks { - named("checkstyleMain") { enabled = false } - named("pmdMain") { enabled = false } - named("compileJava") { - options.errorprone.isEnabled.set(false) - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/java/Tasks.kt b/buildSrc/src/main/kotlin/io/spine/gradle/java/Tasks.kt deleted file mode 100644 index 12d4d56..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/java/Tasks.kt +++ /dev/null @@ -1,45 +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.gradle.java - -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.TaskProvider -import org.gradle.api.tasks.testing.Test -import org.gradle.kotlin.dsl.named - -/** - * Locates `test` task in this [TaskContainer]. - * - * Runs the unit tests using JUnit or TestNG. - * - * Depends on `testClasses`, and all tasks which produce the test runtime classpath. - * - * @see - * Tasks | The Java Plugin - */ -val TaskContainer.test: TaskProvider - get() = named("test") diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javac/ErrorProne.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javac/ErrorProne.kt deleted file mode 100644 index 84c6bcb..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javac/ErrorProne.kt +++ /dev/null @@ -1,89 +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.gradle.javac - -import net.ltgt.gradle.errorprone.errorprone -import org.gradle.api.tasks.compile.JavaCompile -import org.gradle.process.CommandLineArgumentProvider - -/** - * Configures Error Prone for this `JavaCompile` task. - * - * Specifies the arguments for the compiler invocations. In particular, this configuration - * overrides a number of Error Prone defaults. See [ErrorProneConfig] for the details. - * - * Please note that while `ErrorProne` is a standalone Gradle plugin, - * it still has to be configured through `JavaCompile` task options. - * - * Here's an example of how to use it: - * - * ``` - * tasks { - * withType { - * configureErrorProne() - * } - * } - *``` - */ -@Suppress("unused") -fun JavaCompile.configureErrorProne() { - options.compilerArgs.add("--should-stop=ifError=FLOW") - options.errorprone - .errorproneArgumentProviders - .add(ErrorProneConfig.ARGUMENTS) -} - -/** - * The knowledge that is required to set up `Error Prone`. - */ -private object ErrorProneConfig { - - /** - * Command line options for the `Error Prone` compiler. - */ - val ARGUMENTS = CommandLineArgumentProvider { - listOf( - - // Exclude generated sources from being analyzed by ErrorProne. - // Include all directories started from `generated`, such as `generated-proto`. - "-XepExcludedPaths:.*/generated.*/.*", - - // Turn the check off until ErrorProne can handle `@Nested` JUnit classes. - // See issue: https://github.com/google/error-prone/issues/956 - "-Xep:ClassCanBeStatic:OFF", - - // Turn off checks that report unused methods and method parameters. - // See issue: https://github.com/SpineEventEngine/config/issues/61 - "-Xep:UnusedMethod:OFF", - "-Xep:UnusedVariable:OFF", - - "-Xep:CheckReturnValue:OFF", - "-Xep:FloggerSplitLogStatement:OFF", - "-Xep:FloggerLogString:OFF" - ) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/javac/Javac.kt b/buildSrc/src/main/kotlin/io/spine/gradle/javac/Javac.kt deleted file mode 100644 index 44223cb..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/javac/Javac.kt +++ /dev/null @@ -1,74 +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.gradle.javac - -import org.gradle.api.tasks.compile.JavaCompile -import org.gradle.process.CommandLineArgumentProvider - -/** - * Configures the `javac` tool through this `JavaCompile` task. - * - * The following steps are performed: - * - * 1. Passes a couple of arguments to the compiler. See [JavacConfig] for more details; - * 2. Sets the UTF-8 encoding to be used when reading Java source files. - * - * Here's an example of how to use it: - * - *``` - * tasks { - * withType { - * configureJavac() - * } - * } - *``` - */ -@Suppress("unused") -fun JavaCompile.configureJavac() { - with(options) { - encoding = JavacConfig.SOURCE_FILES_ENCODING - compilerArgumentProviders.add(JavacConfig.COMMAND_LINE) - } -} - -/** - * The knowledge that is required to set up `javac`. - */ -private object JavacConfig { - const val SOURCE_FILES_ENCODING = "UTF-8" - val COMMAND_LINE = CommandLineArgumentProvider { - listOf( - - // Protobuf Compiler generates the code, which uses the deprecated `PARSER` field. - // See issue: https://github.com/SpineEventEngine/config/issues/173 - // "-Werror", - - "-Xlint:unchecked", - "-Xlint:deprecation", - ) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt b/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt deleted file mode 100644 index ea47967..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/kotlin/KotlinConfig.kt +++ /dev/null @@ -1,71 +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.gradle.kotlin - -import org.gradle.jvm.toolchain.JavaLanguageVersion -import org.jetbrains.kotlin.gradle.dsl.KotlinCommonCompilerOptions -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension - -/** - * Sets [Java toolchain](https://kotlinlang.org/docs/gradle.html#gradle-java-toolchains-support) - * to the specified version (e.g., 11 or 8). - */ -fun KotlinJvmProjectExtension.applyJvmToolchain(version: Int) { - jvmToolchain { - languageVersion.set(JavaLanguageVersion.of(version)) - } -} - -/** - * Sets [Java toolchain](https://kotlinlang.org/docs/gradle.html#gradle-java-toolchains-support) - * to the specified version (e.g. "11" or "8"). - */ -@Suppress("unused") -fun KotlinJvmProjectExtension.applyJvmToolchain(version: String) = - applyJvmToolchain(version.toInt()) - -/** - * Opts-in to experimental features that we use in our codebase. - */ -@Suppress("unused") -fun KotlinCommonCompilerOptions.setFreeCompilerArgs() { - freeCompilerArgs.addAll( - listOf( - "-Xskip-prerelease-check", - "-Xjvm-default=all", - "-Xinline-classes", - "-Xexpect-actual-classes", - "-Xcontext-receivers", - "-opt-in=" + - "kotlin.contracts.ExperimentalContracts," + - "kotlin.io.path.ExperimentalPathApi," + - "kotlin.ExperimentalUnsignedTypes," + - "kotlin.ExperimentalStdlibApi," + - "kotlin.experimental.ExperimentalTypeInference", - ) - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt b/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt deleted file mode 100644 index b8439a0..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/protobuf/ProtoTaskExtensions.kt +++ /dev/null @@ -1,456 +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. - */ - -@file:Suppress("unused", "UnusedReceiverParameter") /* Extensions declared in this file - are used in the modules that build proto files without using the Spine Compiler. */ - -package io.spine.gradle.protobuf - -import com.google.protobuf.gradle.GenerateProtoTask -import com.google.protobuf.gradle.ProtobufExtension -import io.spine.gradle.sourceSets -import java.io.File -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardOpenOption.TRUNCATE_EXISTING -import kotlin.io.path.Path -import org.gradle.api.Project -import org.gradle.api.file.SourceDirectorySet -import org.gradle.api.tasks.SourceSet -import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.getByType -import org.gradle.plugins.ide.idea.GenerateIdeaModule -import org.gradle.plugins.ide.idea.model.IdeaModel -import org.gradle.plugins.ide.idea.model.IdeaModule -import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask -import titleCaseFirstChar - -/** - * Obtains the path of the `generated` directory under the project root directory. - */ -private val Project.generatedDir: Path - get() = projectDir.resolve("generated").toPath() - -/** - * Obtains the `generated` directory for the source set of the task. - * - * If [language] is specified returns the subdirectory for this language. - */ -private fun GenerateProtoTask.generatedDir(language: String = ""): File { - val path = "${project.generatedDir}/${sourceSet.name}/$language" - return File(path) -} - -/** - * Configures a [GenerateProtoTask] for the code which cannot use Spine Model Compiler - * (e.g., Spine Base or Spine Validation modules). - * - * The task configuration consists of the following steps: - * - * 1. Adding `"kotlin"` to the list of involved `protoc` builtins. - * - * 2. Turning on the generation of a descriptor set file for each source set. - * These files are placed under the `build/descriptors` directory. - * - * 3. Removing source code generated for `com.google` package for both Java and Kotlin. - * This is done at the final steps of the code generation. - * - * 4. Making `processResource` tasks depend on corresponding `generateProto` tasks. - * If the source set of the configured task isn't `main`, appropriate infix for - * the task names is used. - * - * The usage of this extension in a module build file would be: - * ``` - * protobuf { - * generateProtoTasks.all().configureEach { - * setup() - * } - * } - * ``` - * Using the same code under `subprojects` in a root build file does not seem to work because - * test descriptor set files are not copied to resources. Performing this configuration from - * a module build script solves the issue. - * - * IMPORTANT: In addition to calling `setup`, a submodule must contain a descriptor set reference - * file (`desc.ref`) files placed under `resources`. The descriptor reference file must contain - * a reference to the descriptor set file generated by the corresponding `GenerateProtoTask`. - * - * For example, for the `test` source set, the reference would be `known_types_test.desc`, and - * for the `main` source set, the reference would be `known_types_main.desc`. - * - * See `io.spine.code.proto.DescriptorReference` and `io.spine.code.proto.FileDescriptors` classes - * under the `base` project for more details. - */ -@Suppress("unused") -fun GenerateProtoTask.setup() { - builtins.maybeCreate("kotlin") - setupDescriptorSetFileCreation() - excludeProtocOutput() - doLast { - copyGeneratedFiles() - } - setupKotlinCompile() - dependOnProcessResourcesTask() - makeDirsForIdeaModule() -} - -/** - * Tell `protoc` to generate descriptor set files under the project build dir. - * - * The name of the descriptor set file to be generated - * is made to be unique via the project's Maven coordinates. - * - * As the last step of this task, writes a `desc.ref` file - * for the contextual source set, pointing to the generated descriptor set file. - * This is needed to allow other Spine libraries to locate and load the generated - * descriptor set files properly. - * - * Such a job is usually performed by Spine McJava plugin; - * however, it is not possible to use this plugin (or its code) - * in this repository due to cyclic dependencies. - */ -@Suppress( - "TooGenericExceptionCaught" /* Handling all file-writing failures in the same way.*/ -) -fun GenerateProtoTask.setupDescriptorSetFileCreation() { - // Tell `protoc` generate a descriptor set file. - // The name of the generated file reflects the Maven coordinates of the project. - val ssn = sourceSet.name - generateDescriptorSet = true - val buildDir = project.layout.buildDirectory.asFile.get().path - val descriptorsDir = "$buildDir/descriptors/${ssn}" - val descriptorName = project.descriptorSetName(sourceSet) - with(descriptorSetOptions) { - path = "$descriptorsDir/$descriptorName" - includeImports = true - includeSourceInfo = true - } - - // Add the descriptor set file into the resources. - project.sourceSets.named(ssn) { - resources.srcDirs(descriptorsDir) - } - - // Create a `desc.ref` in the same resource folder, - // with the name of the descriptor set file created above. - this.doLast { - val descRefFile = File(descriptorsDir, "desc.ref") - descRefFile.createNewFile() - try { - Files.write(descRefFile.toPath(), setOf(descriptorName), TRUNCATE_EXISTING) - } catch (e: Exception) { - project.logger.error("Error writing `${descRefFile.absolutePath}`.", e) - throw e - } - } -} - -/** - * Returns a name of the descriptor file for the given [sourceSet], - * reflecting the Maven coordinates of Gradle artifact, and the source set - * for which the descriptor set name is to be generated. - * - * The returned value is just a file name and does not contain a file path. - */ -private fun Project.descriptorSetName(sourceSet: SourceSet) = - arrayOf( - group.toString(), - name, - sourceSet.name, - version.toString() - ).joinToString(separator = "_", postfix = ".desc") - -/** - * Copies files from the [outputBaseDir][GenerateProtoTask.outputBaseDir] into - * a subdirectory of [generatedDir][Project.generatedDir] for - * the current [sourceSet][GenerateProtoTask.sourceSet]. - * - * Also removes sources belonging to the `com.google` package in the target directory. - */ -private fun GenerateProtoTask.copyGeneratedFiles() { - project.copy { - from(outputBaseDir) - into(generatedDir()) - } - deleteComGoogle("java") - deleteComGoogle("kotlin") -} - -/** - * Remove the code generated for Google Protobuf library types. - * - * Java code for the `com.google` package was generated because we wanted - * to have descriptors for all the types, including those from Google Protobuf library. - * We want all the descriptors so that they are included into the resources used by - * the `io.spine.type.KnownTypes` class. - * - * Now, as we have the descriptors _and_ excessive Java or Kotlin code, we delete it to avoid - * classes that duplicate those coming from Protobuf library JARs. - */ -private fun GenerateProtoTask.deleteComGoogle(language: String) { - val comDirectory = generatedDir(language).resolve("com") - val googlePackage = comDirectory.resolve("google") - - project.delete(googlePackage) - - // If the `com` directory becomes empty, delete it too. - if (comDirectory.exists() && comDirectory.isDirectory && comDirectory.list()!!.isEmpty()) { - project.delete(comDirectory) - } -} - -/** - * Exclude [GenerateProtoTask.outputBaseDir] from Java source set directories to avoid - * duplicated source code files. - */ -fun GenerateProtoTask.excludeProtocOutput() { - val protocOutputDir = File(outputBaseDir).parentFile - - /** - * Filter out directories belonging to `build/generated/source/proto`. - */ - fun filterFor(directorySet: SourceDirectorySet) { - val newSourceDirectories = directorySet.sourceDirectories - .filter { !it.residesIn(protocOutputDir) } - .toSet() - // Make sure we start from scratch. - // Not doing this failed the following, real, assignment sometimes. - directorySet.setSrcDirs(listOf()) - directorySet.srcDirs(newSourceDirectories) - } - - val java: SourceDirectorySet = sourceSet.java - filterFor(java) - // Add copied files to the Java source set. - java.srcDir(generatedDir("java")) - - val kotlin = sourceSet.kotlin - filterFor(kotlin) - // Add copied files to the Kotlin source set. - kotlin.srcDir(generatedDir("kotlin")) -} - -private val SourceSet.kotlin: SourceDirectorySet get() = - (this as org.gradle.api.plugins.ExtensionAware).extensions.getByName("kotlin") - as SourceDirectorySet - -/** - * Make sure Kotlin compilation explicitly depends on this `GenerateProtoTask` to avoid racing. - */ -fun GenerateProtoTask.setupKotlinCompile() { - val kotlinCompile = project.kotlinCompilationTaskFor(sourceSet) - kotlinCompile?.dependsOn(this) -} - -/** - * Make the tasks `processResources` depend on `generateProto` tasks explicitly so that: - * 1) Descriptor set files get into resources, avoiding the racing conditions - * during the build. - * - * 2) We don't have the warning "Execution optimizations have been disabled..." issued - * by Gradle during the build because Protobuf Gradle Plugin does not set - * dependencies between `generateProto` and `processResources` tasks. - */ -fun GenerateProtoTask.dependOnProcessResourcesTask() { - val processResources = processResourceTaskName(sourceSet.name) - project.tasks[processResources].dependsOn(this) -} - -/** - * Obtains the name of the `processResource` task for the given source set name. - */ -private fun processResourceTaskName(sourceSetName: String): String { - val infix = - if (sourceSetName == "main") "" - else sourceSetName.titleCaseFirstChar() - return "process${infix}Resources" -} - -private fun Project.kotlinCompilationTaskFor(sourceSet: SourceSet): KotlinCompilationTask<*>? { - val taskName = sourceSet.getCompileTaskName("Kotlin") - return tasks.named(taskName, KotlinCompilationTask::class.java).orNull -} - -private fun File.residesIn(directory: File): Boolean = - canonicalFile.startsWith(directory.absolutePath) - -/** - * Ensures that generated directories for Java and Kotlin are created before [GenerateIdeaModule]. - * - * This works as advised by `Utils.groovy` from Protobuf Gradle plugin: - * ``` - * This is required because the IntelliJ IDEA plugin does not allow adding source directories - * that do not exist. The IntelliJ IDEA config files should be valid from the start even if - * a user runs './gradlew idea' before running './gradlew generateProto'. - * ``` - */ -fun GenerateProtoTask.makeDirsForIdeaModule() { - project.plugins.withId("idea") { - val javaDir = generatedDir("java") - val kotlinDir = generatedDir("kotlin") - project.tasks.withType(GenerateIdeaModule::class.java).forEach { - it.doFirst { - javaDir.mkdirs() - kotlinDir.mkdirs() - } - } - } -} - -/** - * Prints diagnostic output of `sourceDirs` and `generatedSourceDirs` of an [IdeaModule]. - * - * To get a handle on [IdeaModule] please use the following code: - * - * ```kotlin - * val module = project.extensions.findByType(IdeaModel::class.java)!!.module - * ``` - */ -@Suppress("unused") // To be used when debugging build scripts. -fun IdeaModule.printSourceDirectories() { - println("**** [IDEA] Source directories:") - sourceDirs.forEach { println(it) } - println() - println("**** [IDEA] Generated source directories:") - generatedSourceDirs.forEach { println(it) } - println() - println("**** [IDEA] Excluded directories:") - excludeDirs.forEach { println(it) } -} - -/** - * Obtains the extension of Protobuf Gradle Plugin in the given project. - */ -val Project.protobufExtension: ProtobufExtension? - get() = extensions.findByType(ProtobufExtension::class.java) - -/** - * Obtains the directory where the Protobuf Gradle Plugin should place the generated code. - * - * The directory is fixed to be `$buildDir/generated/source/proto` in versions pre v0.9.5 - * and cannot be changed by the settings of the plugin. - * In the v0.9.5 the path was changed to - * [`$buildDir/generated/sources/proto`](https://github.com/google/protobuf-gradle-plugin/releases/tag/v0.9.5). - * - * Even though [ProtobufExtension] has a property - * [generatedFilesBaseDir][ProtobufExtension.getGeneratedFilesBaseDir], which is supposed - * to be used for this purpose, it is declared with `@PackageScope` (again in earlier versions) - * and thus cannot be accessed from outside the plugin. - * The Protobuf Gradle Plugin (at v0.9.2) does not modify the value of the property either. - * Therefore, we try getting the path using the newer version API and resort to the "legacy" - * convention if the call fails. - */ -val Project.generatedSourceProtoDir: Path - get() { - val legacyPath = layout.buildDirectory.dir("generated/source/proto").get().asFile.toPath() - protobufExtension?.let { - return try { - it.generatedFilesBaseDir.let { Path(it) } - } catch (_: Throwable) { - // Probably we're running on an older version of the Protobuf Gradle Plugin - // which has `package-access` for the `getGeneratedFilesDir()` method. - legacyPath - } - } - return legacyPath - } - -/** - * Ensures that the sources generated by Protobuf Gradle Plugin - * are not included in the IDEA project. - * - * IDEA should only see the sources generated by ProtoData as - * we define in [GenerateProtoTask.excludeProtocOutput]. - */ -@Suppress("unused") -fun Project.configureIdea() { - - fun filterSources(sources: Set, excludeDir: File): Set = - sources.filter { !it.residesIn(excludeDir) }.toSet() - - pluginManager.withPlugin("idea") { - val idea = extensions.getByType() - with(idea.module) { - val protocOutput = file(generatedSourceProtoDir) - val protocTargets = protocTargets() - excludeWithNested(protocOutput.toPath(), protocTargets) - sourceDirs = filterSources(sourceDirs, protocOutput) - testSources.filter { !it.residesIn(protocOutput) } - generatedSourceDirs = generatedDir.resolve(protocTargets) - .map { it.toFile() } - .toSet() - } - } -} - -/** - * Lists target directories for Protobuf code generation. - * - * The directory names are in the following format: - * - * `/` - */ -private fun Project.protocTargets(): List { - val protobufTasks = tasks.withType(GenerateProtoTask::class.java) - val codegenTargets = sequence { - protobufTasks.forEach { task -> - val sourceSet = task.sourceSet.name - val builtins = task.builtins.map { builtin -> builtin.name } - val plugins = task.plugins.map { plugin -> plugin.name } - val combined = builtins + plugins - combined.forEach { subdir -> - yield(Paths.get(sourceSet, subdir)) - } - } - } - return codegenTargets.toList() -} - -private fun Path.resolve(subdirs: Iterable): List = - subdirs.map { - resolve(it) - } - -/** - * Excludes the given directory and its subdirectories from - * being seen as ones with the source code. - * - * The primary use of this extension is to exclude `build/generated/source/proto` and its - * subdirectories to avoid duplication of types in the generated code with those in - * produced by ProtoData under the `$projectDir/generated/` directory. - */ -private fun IdeaModule.excludeWithNested(directory: Path, subdirs: Iterable) { - excludeDirs.add(directory.toFile()) - directory.resolve(subdirs).forEach { - excludeDirs.add(it.toFile()) - } -} - -@Suppress("unused") // To be used when debugging build scripts. -private fun printExcluded(dir: Any) { - println(" [IDEA] Excluding directory: $dir") -} From 0f6be4f1505092b9dc78661edc3cf7357eba072a Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 15:55:12 +0100 Subject: [PATCH 15/25] Use `libs` as the version catalog name ... instead of `spine` to avoid the name clash with the Root Gradle Plugin extension. --- settings.gradle.kts.template | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/settings.gradle.kts.template b/settings.gradle.kts.template index 247447c..cb2bddc 100644 --- a/settings.gradle.kts.template +++ b/settings.gradle.kts.template @@ -40,14 +40,14 @@ dependencyResolutionManagement { versionCatalogs { - // String interpolation can break because of environment variable substitution. @Suppress("ConvertToStringTemplate") - create("spine") { - val compiler = version("spineCompiler", "$COMPILER_VERSION") - val validation = version("validation", "$VALIDATION_VERSION") + create("libs") { + version("spineCompiler", "$COMPILER_VERSION") + val coreJvm = version("coreJvm", "$CORE_JVM_VERSION") val coreJvmCompiler = version("coreJvmCompiler", "$CORE_JVM_COMPILER_VERSION") + val validation = version("validation", "$VALIDATION_VERSION") val baseGroup = "io.spine" val toolsGroup = baseGroup + ".tools" @@ -65,30 +65,10 @@ dependencyResolutionManagement { ).versionRef(coreJvmCompiler) library( - "server", + "coreJvmServer", baseGroup, "spine-server" ).versionRef(coreJvm) - library( - "spineCompiler.plugin", - compilerGroup, "compiler-gradle-plugin" - ).versionRef(compiler) - - library( - "spineCompiler.compiler", - compilerGroup, "compiler-backend" - ).versionRef(compiler) - - library( - "compiler.jvm", - compilerGroup, "compiler-jvm" - ).versionRef(compiler) - - library( - "validation.codegenJava", - validationGroup, "spine-validation-java-bundle" - ).versionRef(validation) - library( "validation.runtimeJava", validationGroup, "spine-validation-java-runtime" From 5f1a2db09aa849e107ecae965ec865a106f72f73 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 15:55:39 +0100 Subject: [PATCH 16/25] Add more memory and parallel GC --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 652083b..4b7c408 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,6 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -org.gradle.jvmargs=-XX:+UseParallelGC -Xmx4096M +org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+UseParallelGC # org.gradle.debug=true From 1ca6ee81992be882c5a2b761796c3938f1246130 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 15:56:10 +0100 Subject: [PATCH 17/25] Bump external dependencies --- buildSrc/build.gradle.kts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index cbcb32d..d7b3bfd 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -53,7 +53,7 @@ repositories { * Please keep this value in sync with [io.spine.dependency.lib.Jackson.version]. * It is not a requirement but would be good in terms of consistency. */ -val jacksonVersion = "2.15.3" +val jacksonVersion = "2.18.3" /** * The version of Google Artifact Registry used by `buildSrc`. @@ -75,7 +75,7 @@ val grGitVersion = "4.1.1" * This version may change from the [version of Kotlin][io.spine.dependency.lib.Kotlin.version] * used by the project. */ -val kotlinVersion = "2.1.10" +val kotlinVersion = "2.1.21" /** * The version of Guava used in `buildSrc`. @@ -83,7 +83,7 @@ val kotlinVersion = "2.1.10" * Always use the same version as the one specified in [io.spine.dependency.lib.Guava]. * Otherwise, when testing Gradle plugins, clashes may occur. */ -val guavaVersion = "32.1.3-jre" +val guavaVersion = "33.4.8-jre" /** * The version of ErrorProne Gradle plugin. @@ -93,7 +93,7 @@ val guavaVersion = "32.1.3-jre" * @see * Error Prone Gradle Plugin Releases */ -val errorPronePluginVersion = "4.1.0" +val errorPronePluginVersion = "4.2.0" /** * The version of Protobuf Gradle Plugin. @@ -103,7 +103,7 @@ val errorPronePluginVersion = "4.1.0" * @see * Protobuf Gradle Plugins Releases */ -val protobufPluginVersion = "0.9.4" +val protobufPluginVersion = "0.9.5" /** * The version of Dokka Gradle Plugins. @@ -113,7 +113,7 @@ val protobufPluginVersion = "0.9.4" * @see * Dokka Releases */ -val dokkaVersion = "1.9.20" +val dokkaVersion = "2.0.0" /** * The version of Detekt Gradle Plugin. @@ -139,7 +139,7 @@ val koverVersion = "0.7.2" * * @see Shadow Plugin releases */ -val shadowVersion = "7.1.2" +val shadowVersion = "8.3.6" configurations.all { resolutionStrategy { @@ -175,7 +175,7 @@ dependencies { "com.github.jk1:gradle-license-report:$licenseReportVersion", "com.google.guava:guava:$guavaVersion", "com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion", - "gradle.plugin.com.github.johnrengelman:shadow:${shadowVersion}", + "com.gradleup.shadow:shadow-gradle-plugin:$shadowVersion", "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion", "io.kotest:kotest-gradle-plugin:$kotestJvmPluginVersion", // https://github.com/srikanth-lingala/zip4j From 27dca2b8ad8c2bba8ed8d9199654f99315dc47da Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 15:56:42 +0100 Subject: [PATCH 18/25] Set versions of Kotlin and Java --- build.gradle.kts | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a7c296d..4116a36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,32 +28,40 @@ import io.spine.gradle.UpdateJournal import io.spine.gradle.base.build import io.spine.gradle.repo.standardToSpineSdk import java.util.function.Supplier -import org.gradle.accessors.dm.LibrariesForSpine buildscript { standardSpineSdkRepositories() - apply(from = "$rootDir/../version.gradle.kts") - val spine = the() - val coreJvmCompilerVersion: String by extra dependencies { - classpath(variantOf(spine.coreJvmCompiler) { classifier("all") }) + classpath(variantOf(libs.coreJvmCompiler) { classifier("all") }) } } plugins { java + kotlin("jvm") id("com.google.protobuf") id("com.osacky.doctor") version "0.8.1" } +kotlin { + explicitApi() + compilerOptions { + jvmTarget.set(BuildSettings.jvmTarget) + } +} + +tasks.withType().configureEach { + val javaVer = BuildSettings.javaVersion.toString() + sourceCompatibility = javaVer + targetCompatibility = javaVer +} + apply(plugin = "io.spine.core-jvm") repositories.standardToSpineSdk() -val spine = the() - dependencies { - implementation(spine.server) + implementation(libs.coreJvmServer) } val customConfigFile = "../build-speed.gradle.kts" @@ -85,10 +93,10 @@ val recordExecTime by tasks.registering(UpdateJournal::class) { startTime = Supplier { startTimeMillis!! } versions.set( mapOf( - "Compiler" to spine.versions.spineCompiler.get(), - "CoreJvmCompiler" to spine.versions.coreJvmCompiler.get(), - "CoreJvm" to spine.versions.coreJvm.get(), - "Validation" to spine.versions.validation.get(), + "Compiler" to libs.versions.spineCompiler.get(), + "CoreJvmCompiler" to libs.versions.coreJvmCompiler.get(), + "CoreJvm" to libs.versions.coreJvm.get(), + "Validation" to libs.versions.validation.get(), ) ) } From cc6a460bebf4f45b0c2c343424b04846dfc5fc52 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:01:35 +0100 Subject: [PATCH 19/25] Address deprecations in validation options --- .../speed/managementofprojects/rich_text.proto | 13 +++++-------- .../proto/spine/buildtool/speed/pm/rich_text.proto | 13 +++++-------- .../spine/buildtool/speed/pmanag/rich_text.proto | 13 +++++-------- .../spine/buildtool/speed/prjcts/rich_text.proto | 13 +++++-------- .../spine/buildtool/speed/prjmgt/rich_text.proto | 13 +++++-------- .../spine/buildtool/speed/prmn/rich_text.proto | 13 +++++-------- .../buildtool/speed/projectman/rich_text.proto | 13 +++++-------- .../spine/buildtool/speed/promag/rich_text.proto | 10 ++++------ 8 files changed, 39 insertions(+), 62 deletions(-) diff --git a/src/main/proto/spine/buildtool/speed/managementofprojects/rich_text.proto b/src/main/proto/spine/buildtool/speed/managementofprojects/rich_text.proto index 4cc495c..ba2bdd0 100644 --- a/src/main/proto/spine/buildtool/speed/managementofprojects/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/managementofprojects/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/pm/rich_text.proto b/src/main/proto/spine/buildtool/speed/pm/rich_text.proto index 6fcffb1..6f5218e 100644 --- a/src/main/proto/spine/buildtool/speed/pm/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/pm/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/pmanag/rich_text.proto b/src/main/proto/spine/buildtool/speed/pmanag/rich_text.proto index ba4f68a..c8bb879 100644 --- a/src/main/proto/spine/buildtool/speed/pmanag/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/pmanag/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/prjcts/rich_text.proto b/src/main/proto/spine/buildtool/speed/prjcts/rich_text.proto index ee6421f..281e8f8 100644 --- a/src/main/proto/spine/buildtool/speed/prjcts/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/prjcts/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/prjmgt/rich_text.proto b/src/main/proto/spine/buildtool/speed/prjmgt/rich_text.proto index a862b34..b862c8b 100644 --- a/src/main/proto/spine/buildtool/speed/prjmgt/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/prjmgt/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/prmn/rich_text.proto b/src/main/proto/spine/buildtool/speed/prmn/rich_text.proto index 5e4bb85..63962cd 100644 --- a/src/main/proto/spine/buildtool/speed/prmn/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/prmn/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/projectman/rich_text.proto b/src/main/proto/spine/buildtool/speed/projectman/rich_text.proto index 3e0b58b..f08e793 100644 --- a/src/main/proto/spine/buildtool/speed/projectman/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/projectman/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -92,20 +92,17 @@ message Hyperlink { Fragment alt_text = 1 [ (required) = true, - (validate) = true, - (if_missing).error_msg = "Hyperlink text should not be empty." + (validate) = true ]; spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +118,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; diff --git a/src/main/proto/spine/buildtool/speed/promag/rich_text.proto b/src/main/proto/spine/buildtool/speed/promag/rich_text.proto index a1f659f..8e9d752 100644 --- a/src/main/proto/spine/buildtool/speed/promag/rich_text.proto +++ b/src/main/proto/spine/buildtool/speed/promag/rich_text.proto @@ -60,7 +60,7 @@ message Color { message Font { oneof family { - option (is_required) = true; + option (choice).required = true; string name = 1; @@ -99,13 +99,11 @@ message Hyperlink { spine.net.Url url = 2 [(required) = true]; Style new_style = 3 [ - (validate) = true, - (if_invalid).error_msg = "Hyperlink style should be valid." + (validate) = true ]; Style visited_style = 4 [ - (validate) = true, - (if_invalid).error_msg = "Clicked hyperlink style should be valid." + (validate) = true ]; bool visited = 5; @@ -121,7 +119,7 @@ message Icon { message Fragment { oneof kind { - option (is_required) = true; + option (choice).required = true; Span text_span = 1 [(validate) = true]; From d30d7800c1059a592be92a70902bc544e92c9d00 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:06:21 +0100 Subject: [PATCH 20/25] Remove unused code --- .../kotlin/io/spine/gradle/testing/Logging.kt | 88 --------------- .../io/spine/gradle/testing/Multiproject.kt | 71 ------------ .../kotlin/io/spine/gradle/testing/Tasks.kt | 103 ------------------ 3 files changed, 262 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/testing/Logging.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Logging.kt b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Logging.kt deleted file mode 100644 index 6fb7eab..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Logging.kt +++ /dev/null @@ -1,88 +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.gradle.testing - -import org.gradle.api.tasks.testing.Test -import org.gradle.api.tasks.testing.TestDescriptor -import org.gradle.api.tasks.testing.TestResult -import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import org.gradle.kotlin.dsl.KotlinClosure2 - -/** - * Configures logging of this [Test] task. - * - * Enables logging of: - * 1. Standard `out` and `err` streams; - * 2. Thrown exceptions. - * - * Additionally, after all the tests are executed, a short summary would be logged. The summary - * consists of the number of tests and their results. - * - * Usage example: - * - *``` - * tasks { - * withType { - * configureLogging() - * } - * } - *``` - */ -fun Test.configureLogging() { - testLogging { - showStandardStreams = true - showExceptions = true - exceptionFormat = TestExceptionFormat.FULL - showStackTraces = true - showCauses = true - } - - fun TestResult.summary(): String = - """ - Test summary: - >> $testCount tests - >> $successfulTestCount succeeded - >> $failedTestCount failed - >> $skippedTestCount skipped - """ - - afterSuite( - - // `GroovyInteroperability` is employed as `afterSuite()` has no equivalent in Kotlin DSL. - // See issue: https://github.com/gradle/gradle/issues/5431 - - KotlinClosure2({ descriptor, result -> - - // If the descriptor has no parent, then it is the root test suite, - // i.e. it includes the info about all the run tests. - - if (descriptor.parent == null) { - logger.lifecycle(result.summary()) - } - }) - ) -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt deleted file mode 100644 index f8635e5..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Multiproject.kt +++ /dev/null @@ -1,71 +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.gradle.testing - -import org.gradle.api.Project - -/** - * Exposes the test classes of this project as a new "testArtifacts" configuration. - * - * This allows other projects to depend on the test classes from this project within a Gradle - * multi-project build. It is helpful in case the dependant projects re-use abstract test suites - * of some "parent" project. - * - * Please note that this utility requires Gradle `java` plugin to be applied. Hence, it is - * recommended to call this extension method from `java` scope. - * - * Here's an example of how to expose the test classes of "projectA": - * - * ``` - * java { - * exposeTestConfiguration() - * } - * ``` - * - * Here's an example of how to consume the exposed classes in "projectB": - * - * ``` - * dependencies { - * testImplementation(project(path = ":projectA", configuration = "testArtifacts")) - * } - * ``` - * - * Don't forget that this exposure mechanism works only for projects that reside within the same - * multi-project build. In order to share the test classes with external projects, publish a - * dedicated [testJar][io.spine.gradle.publish.SpinePublishing.testJar] artifact. - */ -@Suppress("unused") -fun Project.exposeTestConfiguration() { - - check(pluginManager.hasPlugin("java")) { - "Can't expose the test configuration because `java` plugin has not been applied." - } - - configurations.create("testArtifacts") { - extendsFrom(configurations.getByName("testRuntimeClasspath")) - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt b/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt deleted file mode 100644 index 30ac810..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/testing/Tasks.kt +++ /dev/null @@ -1,103 +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.gradle.testing - -import org.gradle.api.tasks.TaskContainer -import org.gradle.api.tasks.testing.Test -import org.gradle.kotlin.dsl.register -import org.gradle.kotlin.dsl.withType - -/** - * Registers [slowTest][SlowTest] and [fastTest][FastTest] tasks in this [TaskContainer]. - * - * Slow tests are registered to run after all fast tests. - * - * Usage example: - * - * ``` - * tasks { - * registerTestTasks() - * } - * ``` - */ -@Suppress("unused") -fun TaskContainer.registerTestTasks() { - withType().configureEach { - filter { - // There could be cases with no matching tests. - // E.g., tests could be based on Kotest, which has custom task types and names. - isFailOnNoMatchingTests = false - includeTestsMatching("*Test") - includeTestsMatching("*Spec") - } - } - register("fastTest").let { - register("slowTest") { - shouldRunAfter(it) - } - } -} - -/** - * Name of a tag for annotating a test class or method that is known to be slow and - * should not normally be run together with the main test suite. - * - * @see - * SlowTest - * @see - * Tag - */ -private const val SLOW_TAG = "slow" - -/** - * Executes JUnit tests filtering out the ones tagged as `slow`. - */ -private abstract class FastTest : Test() { - init { - description = "Executes all JUnit tests but the ones tagged as `slow`." - group = "Verification" - - this.useJUnitPlatform { - excludeTags(SLOW_TAG) - } - } -} - -/** - * Executes JUnit tests tagged as `slow`. - */ -private abstract class SlowTest : Test() { - init { - description = "Executes JUnit tests tagged as `slow`." - group = "Verification" - // No slow tests -- no problem. - filter.isFailOnNoMatchingTests = false - this.useJUnitPlatform { - includeTags(SLOW_TAG) - } - } -} From bf0c75832545075bd7ca1fc6f78fb8d720b3b08c Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:08:07 +0100 Subject: [PATCH 21/25] Remove code unused in `buildSrc` --- .../kotlin/io/spine/gradle/fs/LazyTempPath.kt | 109 ------------ .../main/kotlin/io/spine/gradle/git/Branch.kt | 43 ----- .../kotlin/io/spine/gradle/git/Repository.kt | 164 ------------------ .../kotlin/io/spine/gradle/git/UserInfo.kt | 42 ----- 4 files changed, 358 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/fs/LazyTempPath.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/git/Branch.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt delete mode 100644 buildSrc/src/main/kotlin/io/spine/gradle/git/UserInfo.kt diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/fs/LazyTempPath.kt b/buildSrc/src/main/kotlin/io/spine/gradle/fs/LazyTempPath.kt deleted file mode 100644 index f6e1777..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/fs/LazyTempPath.kt +++ /dev/null @@ -1,109 +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.gradle.fs - -import java.io.File -import java.net.URI -import java.nio.file.FileSystem -import java.nio.file.Files.createTempDirectory -import java.nio.file.LinkOption -import java.nio.file.Path -import java.nio.file.WatchEvent -import java.nio.file.WatchKey -import java.nio.file.WatchService - -/** - * A path to a temporary folder, which is not created until it is really used. - * - * After the first usage, the instances of this type delegate all calls to the internally - * created instance of [Path] created with [createTempDirectory]. - */ -@Suppress("TooManyFunctions") -class LazyTempPath(private val prefix: String) : Path { - - private val delegate: Path by lazy { createTempDirectory(prefix) } - - override fun compareTo(other: Path): Int = delegate.compareTo(other) - - override fun iterator(): MutableIterator = delegate.iterator() - - override fun register( - watcher: WatchService, - events: Array>, - vararg modifiers: WatchEvent.Modifier? - ): WatchKey = delegate.register(watcher, events, *modifiers) - - override fun register(watcher: WatchService, vararg events: WatchEvent.Kind<*>?): WatchKey = - delegate.register(watcher, *events) - - override fun getFileSystem(): FileSystem = delegate.fileSystem - - override fun isAbsolute(): Boolean = delegate.isAbsolute - - override fun getRoot(): Path = delegate.root - - override fun getFileName(): Path = delegate.fileName - - override fun getParent(): Path = delegate.parent - - override fun getNameCount(): Int = delegate.nameCount - - override fun getName(index: Int): Path = delegate.getName(index) - - override fun subpath(beginIndex: Int, endIndex: Int): Path = - delegate.subpath(beginIndex, endIndex) - - override fun startsWith(other: Path): Boolean = delegate.startsWith(other) - - override fun startsWith(other: String): Boolean = delegate.startsWith(other) - - override fun endsWith(other: Path): Boolean = delegate.endsWith(other) - - override fun endsWith(other: String): Boolean = delegate.endsWith(other) - - override fun normalize(): Path = delegate.normalize() - - override fun resolve(other: Path): Path = delegate.resolve(other) - - override fun resolve(other: String): Path = delegate.resolve(other) - - override fun resolveSibling(other: Path): Path = delegate.resolveSibling(other) - - override fun resolveSibling(other: String): Path = delegate.resolveSibling(other) - - override fun relativize(other: Path): Path = delegate.relativize(other) - - override fun toUri(): URI = delegate.toUri() - - override fun toAbsolutePath(): Path = delegate.toAbsolutePath() - - override fun toRealPath(vararg options: LinkOption?): Path = delegate.toRealPath(*options) - - override fun toFile(): File = delegate.toFile() - - override fun toString(): String = delegate.toString() -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/git/Branch.kt b/buildSrc/src/main/kotlin/io/spine/gradle/git/Branch.kt deleted file mode 100644 index a10a65f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/git/Branch.kt +++ /dev/null @@ -1,43 +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.gradle.git - -/** - * Branch names. - */ -object Branch { - - /** - * The default branch. - */ - const val master = "master" - - /** - * The branch used for publishing documentation to GitHub Pages. - */ - const val documentation = "gh-pages" -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt b/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt deleted file mode 100644 index 55ce67f..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt +++ /dev/null @@ -1,164 +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.gradle.git - -import io.spine.gradle.Cli -import io.spine.gradle.fs.LazyTempPath - -/** - * Interacts with a real Git repository. - * - * Clones the repository with the provided SSH URL in a temporal folder. Provides - * functionality to configure a user, checkout branches, commit changes and push them - * to the remote repository. - * - * It is assumed that before using this class an appropriate SSH key that has - * sufficient rights to perform described above operations was registered - * in `ssh-agent`. - * - * NOTE: This class creates a temporal folder, so it holds resources. For the proper - * release of resources please use the provided functionality inside a `use` block or - * call the `close` method manually. - */ -class Repository private constructor( - - /** - * The GitHub SSH URL to the underlying repository. - */ - private val sshUrl: String, - - /** - * Current user configuration. - * - * This configuration determines what ends up in author and committer fields of a commit. - */ - private var user: UserInfo, - - /** - * Currently checked out branch. - */ - private var currentBranch: String - -) : AutoCloseable { - - /** - * Path to the temporal folder for a clone of the underlying repository. - */ - val location = LazyTempPath("repoTemp") - - /** - * Clones the repository with [the SSH url][sshUrl] into the [temporal folder][location]. - */ - private fun clone() { - repoExecute("git", "clone", sshUrl, ".") - } - - /** - * Executes a command in the [location]. - */ - private fun repoExecute(vararg command: String): String = - Cli(location.toFile()).execute(*command) - - /** - * Checks out the branch by its name. - */ - fun checkout(branch: String) { - repoExecute("git", "checkout", branch) - - currentBranch = branch - } - - /** - * Configures the username and the email of the user. - * - * Overwrites `user.name` and `user.email` settings locally in [location] with - * values from [user]. These settings determine what ends up in author and - * committer fields of a commit. - */ - fun configureUser(user: UserInfo) { - repoExecute("git", "config", "user.name", user.name) - repoExecute("git", "config", "user.email", user.email) - - this.user = user - } - - /** - * Stages all changes and commits with the provided message. - */ - fun commitAllChanges(message: String) { - stageAllChanges() - commit(message) - } - - private fun stageAllChanges() { - repoExecute("git", "add", "--all") - } - - private fun commit(message: String) { - repoExecute( - "git", - "commit", - "--allow-empty", - "--message=${message}" - ) - } - - /** - * Pushes local repository to the remote. - */ - fun push() { - repoExecute("git", "push") - } - - override fun close() { - location.toFile().deleteRecursively() - } - - companion object Factory { - /** - * Clones the repository with the provided SSH URL in a temporal folder. - * Configures the username and the email of the Git user. See [configureUser] - * documentation for more information. Performs checkout of the branch in - * case it was passed. By default, [master][Branch.master] is checked out. - * - * @throws IllegalArgumentException if SSH URL is an empty string. - */ - fun of(sshUrl: String, user: UserInfo, branch: String = Branch.master): Repository { - require(sshUrl.isNotBlank()) { "SSH URL cannot be an empty string." } - - val repo = Repository(sshUrl, user, branch) - repo.clone() - repo.configureUser(user) - - if (branch != Branch.master) { - repo.checkout(branch) - } - - return repo - } - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/git/UserInfo.kt b/buildSrc/src/main/kotlin/io/spine/gradle/git/UserInfo.kt deleted file mode 100644 index bc9f08d..0000000 --- a/buildSrc/src/main/kotlin/io/spine/gradle/git/UserInfo.kt +++ /dev/null @@ -1,42 +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.gradle.git - -/** - * Contains information about a Git user. - * - * Determines the author and committer fields of a commit. - * - * @constructor throws an [IllegalArgumentException] if the name or the email - * is an empty string. - */ -data class UserInfo(val name: String, val email: String) { - init { - require(name.isNotBlank()) { "Name cannot be an empty string." } - require(email.isNotBlank()) { "Email cannot be an empty string." } - } -} From d190d31d3fdd8965c1228c656eb1ef55584a916e Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:11:13 +0100 Subject: [PATCH 22/25] Remove `config` submodule --- .gitmodules | 3 --- config | 1 - 2 files changed, 4 deletions(-) delete mode 160000 config diff --git a/.gitmodules b/.gitmodules index 94e8664..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "config"] - path = config - url = https://github.com/SpineEventEngine/config diff --git a/config b/config deleted file mode 160000 index 5c2820b..0000000 --- a/config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5c2820b2c23596617e9d677d44c3394d6a2b0308 From 8b973c47bd1bbd3fb9b6dbb59878f3bdf589de12 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:19:03 +0100 Subject: [PATCH 23/25] Update env. vars for dependencies --- .github/workflows/build.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f174ff..9b9c544 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,10 +26,10 @@ jobs: shell: bash run: ./substitute-settings.py env: - MC_JAVA_VERSION: "2.0.0-SNAPSHOT.266" - CORE_VERSION: "2.0.0-SNAPSHOT.201" - PROTO_DATA_VERSION: "0.92.11" - VALIDATION_VERSION: "2.0.0-SNAPSHOT.301" + COMPILER_VERSION: "2.0.0-SNAPSHOT.016" + VALIDATION_VERSION: "2.0.0-SNAPSHOT.351" + CORE_JVM_VERSION: "2.0.0-SNAPSHOT.330" + CORE_JVM_COMPILER_VERSION: "2.0.0-SNAPSHOT.007" - name: Build project shell: bash From ba0d4c362325cb6c6a6761b69339af893e7f5f09 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:19:20 +0100 Subject: [PATCH 24/25] Update measurements --- journal.log | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/journal.log b/journal.log index 25e18dd..a72d27c 100644 --- a/journal.log +++ b/journal.log @@ -7,6 +7,11 @@ # # Please do not edit this file by hand. # +2:42 :: sanders :: 2025-09-29T15:14:01.038331Z :: Compiler:2.0.0-SNAPSHOT.016;CoreJvmCompiler:2.0.0-SNAPSHOT.008;CoreJvm:2.0.0-SNAPSHOT.330;Validation:2.0.0-SNAPSHOT.351 +2:35 :: sanders :: 2025-09-29T15:03:45.379682Z :: Compiler:2.0.0-SNAPSHOT.016;CoreJvmCompiler:2.0.0-SNAPSHOT.008;CoreJvm:2.0.0-SNAPSHOT.330;Validation:2.0.0-SNAPSHOT.351 +2:40 :: sanders :: 2025-09-29T14:43:42.899204Z :: Compiler:2.0.0-SNAPSHOT.016;CoreJvmCompiler:2.0.0-SNAPSHOT.008;CoreJvm:2.0.0-SNAPSHOT.330;Validation:2.0.0-SNAPSHOT.351 +2:40 :: sanders :: 2025-09-29T14:39:46.745251Z :: Compiler:2.0.0-SNAPSHOT.016;CoreJvmCompiler:2.0.0-SNAPSHOT.008;CoreJvm:2.0.0-SNAPSHOT.330;Validation:2.0.0-SNAPSHOT.351 +2:46 :: sanders :: 2025-09-29T14:35:59.938425Z :: Compiler:2.0.0-SNAPSHOT.016;CoreJvmCompiler:2.0.0-SNAPSHOT.008;CoreJvm:2.0.0-SNAPSHOT.330;Validation:2.0.0-SNAPSHOT.351 1:32 :: sanders :: 2025-03-09T15:08:08.584716Z :: core:2.0.0-SNAPSHOT.201;ProtoData:0.92.11;Validation:2.0.0-SNAPSHOT.301;mc-java:2.0.0-SNAPSHOT.266 1:37 :: sanders :: 2025-03-09T15:04:33.724061Z :: core:2.0.0-SNAPSHOT.201;ProtoData:0.92.11;Validation:2.0.0-SNAPSHOT.301;mc-java:2.0.0-SNAPSHOT.266 4:23 :: ddashenkov :: 2023-07-03T09:49:57.699868Z :: core:2.0.0-SNAPSHOT.141;ProtoData:0.8.5;Validation:2.0.0-SNAPSHOT.81;mc-java:2.0.0-SNAPSHOT.151 From 878391a0189c691b69fb1c822bd10d5280f8e62d Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Mon, 29 Sep 2025 16:26:57 +0100 Subject: [PATCH 25/25] Remove loading `version.gradle.kts` ... as no longer needed. We take the CoreJvm Compiler version from the version catalog. --- build.gradle.kts | 3 --- 1 file changed, 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4116a36..2cd13f3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -86,9 +86,6 @@ afterEvaluate { startTimeMillis = System.currentTimeMillis() } -apply(from = "$rootDir/../version.gradle.kts") -val coreJvmCompilerVersion: String by extra - val recordExecTime by tasks.registering(UpdateJournal::class) { startTime = Supplier { startTimeMillis!! } versions.set(