diff --git a/.github/workflows/build-on-ubuntu.yml b/.github/workflows/build-on-ubuntu.yml index 0217c3220..3402891e8 100644 --- a/.github/workflows/build-on-ubuntu.yml +++ b/.github/workflows/build-on-ubuntu.yml @@ -18,6 +18,10 @@ jobs: - name: Pull config run: git submodule update --init --recursive + - name: Prepare a version catalog in Maven local + shell: bash + run: cd version-catalog && ./gradlew publishToMavenLocal + - name: Build project and run tests shell: bash run: ./gradlew build --stacktrace diff --git a/.github/workflows/build-on-windows.yml b/.github/workflows/build-on-windows.yml index a11a7daa5..c80611791 100644 --- a/.github/workflows/build-on-windows.yml +++ b/.github/workflows/build-on-windows.yml @@ -18,6 +18,10 @@ jobs: - name: Pull config run: git submodule update --init --recursive + - name: Prepare a version catalog in Maven local + shell: bash + run: cd version-catalog && ./gradlew publishToMavenLocal + - name: Build project and run tests shell: cmd # For the reason on `--no-daemon` see https://github.com/actions/cache/issues/454 diff --git a/.github/workflows/increment-guard.yml b/.github/workflows/increment-guard.yml index c96b081b0..eb01607e5 100644 --- a/.github/workflows/increment-guard.yml +++ b/.github/workflows/increment-guard.yml @@ -24,6 +24,10 @@ jobs: - name: Pull config run: git submodule update --init --recursive + - name: Prepare a version catalog in Maven local + shell: bash + run: cd version-catalog && ./gradlew publishToMavenLocal + - name: Check version is not yet published shell: bash run: ./gradlew checkVersionIncrement --stacktrace diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 809943cce..262fd5fd3 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,6 +1,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index ee2691bb8..05db95c64 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -38,10 +38,5 @@ - - - - - + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 2c0b6c997..37a4dc330 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,9 +31,6 @@ import com.google.protobuf.gradle.generateProtoTasks import com.google.protobuf.gradle.id import com.google.protobuf.gradle.protobuf import com.google.protobuf.gradle.protoc -import io.spine.internal.dependency.ErrorProne -import io.spine.internal.dependency.JUnit -import io.spine.internal.dependency.Protobuf import io.spine.internal.gradle.publish.PublishingRepos import io.spine.internal.gradle.applyGitHubPackages import io.spine.internal.gradle.applyStandard @@ -52,12 +49,19 @@ import io.spine.internal.gradle.test.registerTestTasks import org.jetbrains.kotlin.gradle.tasks.KotlinCompile buildscript { - apply(from = "$rootDir/version.gradle.kts") - io.spine.internal.gradle.doApplyStandard(repositories) - io.spine.internal.gradle.doForceVersions(configurations) + io.spine.internal.gradle.doForceVersions(configurations, libs) + + /* + Due to a bug, we can't apply scripts. + + `version.gradle.kts` file is not applied, thus the version of mcJava is + declared right here. - val mcJavaVersion: String by extra + See issue: https://github.com/gradle/gradle/issues/20717 + */ + + val mcJavaVersion = "2.0.0-SNAPSHOT.83" dependencies { classpath("io.spine.tools:spine-mc-java:$mcJavaVersion") } @@ -75,8 +79,20 @@ plugins { idea `project-report` - id(io.spine.internal.dependency.Protobuf.GradlePlugin.id) - id(io.spine.internal.dependency.ErrorProne.GradlePlugin.id) + /* + As for now, Gradle doesn't provide API for applying plugins without version. + This is why we resolve a provider by `get()`. + + See a feature request: https://github.com/gradle/gradle/issues/17968 + + Also, for these two lines below, IDEA reports a false-positive error. + + See issue in Gradle: https://github.com/gradle/gradle/issues/20839 + See issue in IDEA: https://youtrack.jetbrains.com/issue/KTIJ-19369/False-positive-can-t-be-called-in-this-context-by-implicit-recei + */ + + id(libs.plugins.protobuf.get().pluginId) + id(libs.plugins.errorProne.get().pluginId) } spinePublishing { @@ -91,27 +107,39 @@ spinePublishing { cloudArtifactRegistry ) } - dokkaJar { enabled = true } } allprojects { - apply(from = "$rootDir/version.gradle.kts") + + /* + Due to a bug, we can't apply scripts. + + `version.gradle.kts` file is not applied, thus the versions of spine libs + are declared right here. + + See issue: https://github.com/gradle/gradle/issues/20717 + */ + + /** Versions of the Spine libraries that `time` depends on. */ + extra["spineBaseVersion"] = "2.0.0-SNAPSHOT.91" + extra["javadocToolsVersion"] = "2.0.0-SNAPSHOT.75" + + /** The version of this library. */ + val versionToPublish by extra("2.0.0-SNAPSHOT.93") group = "io.spine" - version = extra["versionToPublish"]!! + version = versionToPublish } subprojects { - apply { plugin("java-library") plugin("kotlin") plugin("com.google.protobuf") plugin("net.ltgt.errorprone") - plugin("pmd") plugin("checkstyle") plugin("idea") plugin("pmd-settings") @@ -126,11 +154,20 @@ subprojects { val spineBaseVersion: String by extra dependencies { - errorprone(ErrorProne.core) + + /* + Gradle discourages cross-configuration of projects. + Thus, the direct access to `libs` in `allprojects` and `subprojects` + blocks is unavailable. But we still can use it from `rootProject`. + + See the closed issue: https://github.com/gradle/gradle/issues/16634 + */ + + errorprone(rootProject.libs.errorProne.core) api(kotlin("stdlib-jdk8")) testImplementation("io.spine.tools:spine-testlib:$spineBaseVersion") - testImplementation(JUnit.runner) + testImplementation(rootProject.libs.jUnit.runner) } /** @@ -138,7 +175,7 @@ subprojects { * [com.google.errorprone.bugpatterns.CheckReturnValue] was removed leading to breaking the API. */ configurations { - forceVersions() + forceVersions(rootProject.libs) all { resolutionStrategy { force( @@ -199,7 +236,7 @@ subprojects { protobuf { generatedFilesBaseDir = generatedRootDir protoc { - artifact = Protobuf.compiler + artifact = rootProject.libs.protobuf.compiler.get().toString() } generateProtoTasks { all().forEach { task -> @@ -218,7 +255,7 @@ subprojects { rootFolder.set(rootDir) } - // Apply the same IDEA module configuration for each of sub-projects. + // Apply the same IDEA module configuration for each of subprojects. idea { module { with(generatedSourceDirs) { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 79d04a938..da6fee6a0 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -24,19 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/** - * This script uses two declarations of the constant [licenseReportVersion] because - * currently there is no way to define a constant _before_ a build script of `buildSrc`. - * We cannot use imports or do something else before the `buildscript` or `plugin` clauses. - */ - plugins { java groovy `kotlin-dsl` pmd - val licenseReportVersion = "2.1" - id("com.github.jk1.dependency-license-report").version(licenseReportVersion) } repositories { @@ -45,105 +37,83 @@ repositories { mavenCentral() } -/** - * The version of Jackson used by `buildSrc`. - * - * Please keep this value in sync. with `io.spine.internal.dependency.Jackson.version`. - * It's not a requirement, but would be good in terms of consistency. - */ -val jacksonVersion = "2.13.0" - -val googleAuthToolVersion = "2.1.2" -val licenseReportVersion = "2.1" -val grGitVersion = "3.1.1" - -/** - * The version of the Kotlin Gradle plugin. - * - * Please check that this value matches one defined in - * [io.spine.internal.dependency.Kotlin.version]. - */ -val kotlinVersion = "1.6.21" - -/** - * The version of Guava used in `buildSrc`. - * - * Always use the same version as the one specified in [io.spine.internal.dependency.Guava]. - * Otherwise, when testing Gradle plugins, clashes may occur. - */ -val guavaVersion = "31.1-jre" - -/** - * The version of ErrorProne Gradle plugin. - * - * Please keep in sync. with [io.spine.internal.dependency.ErrorProne.GradlePlugin.version]. - * - * @see - * Error Prone Gradle Plugin Releases - */ -val errorProneVersion = "2.0.2" - -/** - * The version of Protobuf Gradle Plugin. - * - * Please keep in sync. with [io.spine.internal.dependency.Protobuf.GradlePlugin.version]. - * - * @see - * Protobuf Gradle Plugins Releases - */ -val protobufPluginVersion = "0.8.18" - -/** - * The version of Dokka Gradle Plugins. - * - * Please keep in sync with [io.spine.internal.dependency.Dokka.version]. - * - * @see - * Dokka Releases - */ -val dokkaVersion = "1.6.20" - configurations.all { resolutionStrategy { - // Force Kotlin lib versions avoiding using those bundled with Gradle. - force( - "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion", - "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion", - "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion", - "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion", - "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" - ) - } -} -val jvmVersion = JavaLanguageVersion.of(11) + /* + Failing on each conflict leads to a bit bigger `force()` block, + but eliminates warnings. Also, builds are more reproducible when dynamic + version resolution is suppressed. + */ -java { - toolchain.languageVersion.set(jvmVersion) -} + failOnVersionConflict() -tasks.withType { - kotlinOptions { - jvmTarget = jvmVersion.toString() + force( + libs.apacheHttp.core, + libs.guava, + libs.httpClient.google, + libs.jackson.core, + libs.jackson.databind, + libs.jackson.dataformatXml, + libs.jackson.moduleKotlin, + + /* + Suppressing of Kotlin libraries eliminates warnings about different + Kotlin versions on the classpath. + */ + + libs.kotlin.reflect, + libs.kotlin.stdLib, + libs.kotlin.stdLib.common, + libs.kotlin.stdLib.jdk8, + libs.kotlinX.coroutines.core, + libs.kotlinX.coroutines.core.jvm, + + libs.slf4J.api, + ) } } dependencies { - implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion") - implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion") - implementation("com.google.cloud.artifactregistry:artifactregistry-auth-common:$googleAuthToolVersion") { - exclude(group = "com.google.guava") + + /* + We add the implementation dependency on the class of `libs` extension + in order to make the generated `LibrariesForLibs` available in `main` + source set. + + It does not mean our dependencies will be available in `main` sources. + It means we can fetch them in a type-safe manner from a `Project` instance, + in which this extension is registered. + + For example: + val libs = project.extensions.getByType() + */ + + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) + + implementation(libs.errorProne.gradlePlugin) + implementation(libs.googleCloud.artifactRegistry.authCommon) + implementation(libs.grGit.core) + implementation(libs.guava) + implementation(libs.jackson.databind) + implementation(libs.jackson.dataformatXml) + implementation(libs.kotlin.gradlePlugin) + implementation(libs.licenseReport.gradlePlugin) + implementation(libs.protobuf.gradlePlugin) + + /* + Dokka uses a fat jar with Kotlin runtime inside. One more Kotlin version. + This is a reason for two warnings. + + It's not certain if we can just exclude those jars. Thus, before merge these + changes into `config`, it should be checked out on a repository, where Dokka + is used. And if not, a comment should be left here, mentioning this fact and + describing why it is so. + */ + + implementation(libs.dokka.gradlePlugin) + implementation(libs.dokka.basePlugin) { + exclude("org.jetbrains.dokka", "kotlin-analysis-compiler") + exclude("org.jetbrains.dokka", "kotlin-analysis-intellij") } - implementation("com.google.guava:guava:$guavaVersion") - api("com.github.jk1:gradle-license-report:$licenseReportVersion") - implementation("org.ajoberstar.grgit:grgit-core:${grGitVersion}") - implementation("net.ltgt.gradle:gradle-errorprone-plugin:${errorProneVersion}") - - // Add explicit dependency to avoid warning on different Kotlin runtime versions. - implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") - - implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion") - implementation("org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}") - implementation("org.jetbrains.dokka:dokka-base:${dokkaVersion}") } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 000000000..5ccbe265d --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,88 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.SpineVersionCatalog + +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + // We don't apply any plugins. + // We just put `SpineVersionCatalog` class on a classpath of settings script. + classpath("io.spine.internal:spine-version-catalog:+") + } +} + +dependencyResolutionManagement { + versionCatalogs { + + /* + `SpineVersionCatalog` is not a plugin, it just exposes a method, which + operates upon Gradle's provided `VersionCatalogBuilder`, filling it up + with items. + + It is so because we want to preserve a possibility of overwrite. + Currently, Gradle does not provide a clear way to perform overwrite for + ALREADY CREATED catalogs. Thus, a plugin can't create the catalog, and + it's a responsibility of end-users to it. + + In order to override a version, shipped by the catalog, one should + declare it BEFORE applying the catalog to the builder. Versions, + declared first, always win. + + In contrast, to override a library, plugin or bundle, one should + declare it AFTER applying the catalog to the builder. Those items, + declared last, always win. + + See the issue: https://github.com/gradle/gradle/issues/20836 + */ + + create("libs") { + + /* + An example of how to override versions. + + Two lines below declare versions of Kotlin for our build logic. + Our `SpineVersionCatalog` class also declares those versions, and + declaring them first in settings file is, actually, current way + to perform override. + + Build scripts are executed by Gradle's embedded Kotlin, and + implementing build logic with different Kotlin makes little sense. + + Primarily, it just gets rid of a multi-line warning block. + */ + + version("kotlin", "1.5.31") + version("kotlinX-coroutines", "1.5.2") + + // Fills up this builder. + SpineVersionCatalog.useIn(this) + } + } +} diff --git a/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts b/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts index 54af9f8da..9a6b17666 100644 --- a/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts +++ b/buildSrc/src/main/kotlin/dokka-for-java.gradle.kts @@ -24,11 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import io.spine.internal.dependency.Dokka import io.spine.internal.gradle.dokka.onlyJavaSources import io.spine.internal.gradle.dokka.onlyNonGeneratedSources import java.time.LocalDate +import org.gradle.accessors.dm.LibrariesForLibs import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.DokkaBaseConfiguration import org.jetbrains.dokka.gradle.DokkaTask @@ -38,6 +38,9 @@ plugins { } dependencies { + + val libs = rootProject.extensions.getByType() + /** * To generate the documentation as seen from Java perspective, the kotlin-as-java plugin was * added to the Dokka's classpath. @@ -45,7 +48,7 @@ dependencies { * @see * Dokka output formats */ - dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib) + dokkaPlugin(libs.dokka.kotlinAsJavaPlugin) /** * To exclude pieces of code annotated with `@Internal` from the documentation a custom plugin @@ -54,7 +57,7 @@ dependencies { * @see * Custom Dokka Plugins */ - dokkaPlugin(Dokka.SpineExtensions.lib) + dokkaPlugin(libs.dokka.spineExtensions) } tasks.withType().configureEach { diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CheckerFramework.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/CheckerFramework.kt deleted file mode 100644 index 75cc67f2e..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CheckerFramework.kt +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://checkerframework.org/ -object CheckerFramework { - private const val version = "3.21.3" - const val annotations = "org.checkerframework:checker-qual:${version}" - @Suppress("unused") - val dataflow = listOf( - "org.checkerframework:dataflow:${version}", - "org.checkerframework:javacutil:${version}" - ) - /** - * This is discontinued artifact, which we do not use directly. - * This is a transitive dependency for us, which we force in - * [DependencyResolution.forceConfiguration] - */ - const val compatQual = "org.checkerframework:checker-compat-qual:2.5.5" -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/ErrorProne.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/ErrorProne.kt deleted file mode 100644 index e62b4b416..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/ErrorProne.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://errorprone.info/ -@Suppress("unused") -object ErrorProne { - // https://github.com/google/error-prone - private const val version = "2.13.1" - // https://github.com/tbroyer/gradle-errorprone-plugin/blob/v0.8/build.gradle.kts - private const val javacPluginVersion = "9+181-r4173-1" - - val annotations = listOf( - "com.google.errorprone:error_prone_annotations:${version}", - "com.google.errorprone:error_prone_type_annotations:${version}" - ) - const val core = "com.google.errorprone:error_prone_core:${version}" - const val checkApi = "com.google.errorprone:error_prone_check_api:${version}" - const val testHelpers = "com.google.errorprone:error_prone_test_helpers:${version}" - const val javacPlugin = "com.google.errorprone: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 in projects 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 = "2.0.2" - const val lib = "net.ltgt.gradle:gradle-errorprone-plugin:${version}" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Grpc.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Grpc.kt deleted file mode 100644 index c9d55667c..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Grpc.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://github.com/grpc/grpc-java -@Suppress("unused") -object Grpc { - @Suppress("MemberVisibilityCanBePrivate") - const val version = "1.45.1" - const val api = "io.grpc:grpc-api:${version}" - const val auth = "io.grpc:grpc-auth:${version}" - const val core = "io.grpc:grpc-core:${version}" - const val context = "io.grpc:grpc-context:${version}" - const val stub = "io.grpc:grpc-stub:${version}" - const val okHttp = "io.grpc:grpc-okhttp:${version}" - const val protobuf = "io.grpc:grpc-protobuf:${version}" - const val protobufLite = "io.grpc:grpc-protobuf-lite:${version}" - const val protobufPlugin = "io.grpc:protoc-gen-grpc-java:${version}" - const val netty = "io.grpc:grpc-netty:${version}" - const val nettyShaded = "io.grpc:grpc-netty-shaded:${version}" -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JUnit.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/JUnit.kt deleted file mode 100644 index 0c436ce4c..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JUnit.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://junit.org/junit5/ -@Suppress("unused") -object JUnit { - const val version = "5.8.2" - private const val platformVersion = "1.8.2" - 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 = "1.5.0" - - const val legacy = "junit:junit:${legacyVersion}" - 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 pioneer = "org.junit-pioneer:junit-pioneer:${pioneerVersion}" - const val platformCommons = "org.junit.platform:junit-platform-commons:${platformVersion}" - const val platformLauncher = "org.junit.platform:junit-platform-launcher:${platformVersion}" - const val params = "org.junit.jupiter:junit-jupiter-params:${version}" -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Jackson.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Jackson.kt deleted file mode 100644 index 71f7e08c3..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Jackson.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -@Suppress("unused") -object Jackson { - private const val version = "2.13.2" - private const val databindVersion = "2.13.2.2" - // https://github.com/FasterXML/jackson-core - const val core = "com.fasterxml.jackson.core:jackson-core:${version}" - // https://github.com/FasterXML/jackson-databind - const val databind = "com.fasterxml.jackson.core:jackson-databind:${databindVersion}" - // https://github.com/FasterXML/jackson-dataformat-xml/releases - const val dataformatXml = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${version}" - // https://github.com/FasterXML/jackson-dataformats-text/releases - const val dataformatYaml = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${version}" - // https://github.com/FasterXML/jackson-module-kotlin/releases - const val moduleKotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:${version}" -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Kotlin.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Kotlin.kt deleted file mode 100644 index ecee68630..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Kotlin.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://github.com/JetBrains/kotlin -// https://github.com/Kotlin -object Kotlin { - /** - * When changing the version, also change the version used in the `buildSrc/build.gradle.kts`. - */ - @Suppress("MemberVisibilityCanBePrivate") // used directly from outside - const val version = "1.6.21" - const val reflect = "org.jetbrains.kotlin:kotlin-reflect:${version}" - const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib:${version}" - const val stdLibCommon = "org.jetbrains.kotlin:kotlin-stdlib-common:${version}" - const val stdLibJdk8 = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${version}" -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Protobuf.kt deleted file mode 100644 index 437ee2cef..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Protobuf.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://github.com/protocolbuffers/protobuf -@Suppress("MemberVisibilityCanBePrivate") // used directly from outside -object Protobuf { - private const val group = "com.google.protobuf" - const val version = "3.20.1" - val libs = listOf( - "${group}:protobuf-java:${version}", - "${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 in projects 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.8.18" - const val id = "com.google.protobuf" - const val lib = "${group}:protobuf-gradle-plugin:${version}" - } -} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Truth.kt b/buildSrc/src/main/kotlin/io/spine/internal/dependency/Truth.kt deleted file mode 100644 index 48c1f2df5..000000000 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Truth.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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.internal.dependency - -// https://github.com/google/truth -object Truth { - private const val version = "1.1.3" - 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/internal/gradle/DependencyResolution.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/DependencyResolution.kt index 168c07987..3ff4f9300 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/DependencyResolution.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/DependencyResolution.kt @@ -26,25 +26,7 @@ package io.spine.internal.gradle -import io.spine.internal.dependency.AnimalSniffer -import io.spine.internal.dependency.AutoCommon -import io.spine.internal.dependency.AutoService -import io.spine.internal.dependency.AutoValue -import io.spine.internal.dependency.CheckerFramework -import io.spine.internal.dependency.CommonsCli -import io.spine.internal.dependency.CommonsLogging -import io.spine.internal.dependency.ErrorProne -import io.spine.internal.dependency.FindBugs -import io.spine.internal.dependency.Flogger -import io.spine.internal.dependency.Gson -import io.spine.internal.dependency.Guava -import io.spine.internal.dependency.J2ObjC -import io.spine.internal.dependency.JUnit -import io.spine.internal.dependency.Kotlin -import io.spine.internal.dependency.Okio -import io.spine.internal.dependency.Plexus -import io.spine.internal.dependency.Protobuf -import io.spine.internal.dependency.Truth +import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.artifacts.Configuration import org.gradle.api.artifacts.ConfigurationContainer @@ -55,72 +37,92 @@ import org.gradle.api.artifacts.dsl.RepositoryHandler * The function to be used in `buildscript` when a fully-qualified call must be made. */ @Suppress("unused") -fun doForceVersions(configurations: ConfigurationContainer) { - configurations.forceVersions() +fun doForceVersions(configurations: ConfigurationContainer, libs: LibrariesForLibs) { + configurations.forceVersions(libs) } /** * Forces dependencies used in the project. */ -fun NamedDomainObjectContainer.forceVersions() { +fun NamedDomainObjectContainer.forceVersions(libs: LibrariesForLibs) { all { resolutionStrategy { failOnVersionConflict() cacheChangingModulesFor(0, "seconds") - forceProductionDependencies() - forceTestDependencies() - forceTransitiveDependencies() + forceProductionDependencies(libs) + forceTestDependencies(libs) + forceTransitiveDependencies(libs) } } } -private fun ResolutionStrategy.forceProductionDependencies() { +private fun ResolutionStrategy.forceProductionDependencies(libs: LibrariesForLibs) = with(libs) { @Suppress("DEPRECATION") // Force SLF4J version. force( - AnimalSniffer.lib, - AutoCommon.lib, - AutoService.annotations, - CheckerFramework.annotations, - ErrorProne.annotations, - ErrorProne.core, - Guava.lib, - FindBugs.annotations, - Flogger.lib, - Flogger.Runtime.systemBackend, - Kotlin.reflect, - Kotlin.stdLib, - Kotlin.stdLibCommon, - Kotlin.stdLibJdk8, - Protobuf.libs, - Protobuf.GradlePlugin.lib, - io.spine.internal.dependency.Slf4J.lib + animalSniffer, + checkerFramework.annotations, + errorProne.annotations, + errorProne.core, + errorProne.typeAnnotations, + findBugs.annotations, + flogger, + flogger.runtime.systemBackend, + googleAuto.common, + googleAuto.service.annotations, + guava, + kotlin.reflect, + kotlin.stdLib, + kotlin.stdLib.common, + kotlin.stdLib.jdk8, + protobuf.gradlePlugin, + + /* + Previously, we could force bundles, which we represented as iterable + of strings. But we are not allowed to force version catalog's bundles: + + `bundles.protobuf` + + It's not a bug. It's rather a design desicion, as the error clearly states: + => Only dependency accessors are supported but not plugin, bundle or version accessors for 'force()'. + + So, we have to open out the given bundle, and force three libraries independently. + */ + + protobuf.java, + protobuf.javaUtil, + protobuf.kotlin, + + slf4J, ) } -private fun ResolutionStrategy.forceTestDependencies() { +private fun ResolutionStrategy.forceTestDependencies(libs: LibrariesForLibs) = with(libs) { force( - Guava.testLib, - JUnit.api, - JUnit.platformCommons, - JUnit.platformLauncher, - JUnit.legacy, - Truth.libs + guava.testLib, + jUnit.api, + jUnit.apiGuardian, + jUnit.legacy, + jUnit.params, + jUnit.platform.commons, + jUnit.platform.launcher, + truth.java8Extension, + truth.protoExtension, ) } /** * Forces transitive dependencies of 3rd party components that we don't use directly. */ -private fun ResolutionStrategy.forceTransitiveDependencies() { +private fun ResolutionStrategy.forceTransitiveDependencies(libs: LibrariesForLibs) = with(libs) { force( - AutoValue.annotations, - Gson.lib, - J2ObjC.annotations, - Plexus.utils, - Okio.lib, - CommonsCli.lib, - CheckerFramework.compatQual, - CommonsLogging.lib + apacheCommons.cli, + apacheCommons.logging, + checkerFramework.compatQual, + googleAuto.value.annotations, + gson, + j2ObjC.annotations, + okio, + plexus.utils, ) } @@ -145,8 +147,8 @@ object DependencyResolution { "Please use `configurations.forceVersions()`.", ReplaceWith("configurations.forceVersions()") ) - fun forceConfiguration(configurations: ConfigurationContainer) { - configurations.forceVersions() + fun forceConfiguration(configurations: ConfigurationContainer, libs: LibrariesForLibs) { + configurations.forceVersions(libs) } @Deprecated( diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/Runtime.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/Runtime.kt index eced40e43..9fac53730 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/Runtime.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/Runtime.kt @@ -27,17 +27,11 @@ package io.spine.internal.gradle import com.google.common.base.Joiner -import io.spine.internal.dependency.Flogger import java.io.File import java.io.InputStream import java.io.StringWriter import java.util.* -object Runtime { - @Suppress("unused") - val flogger = Flogger.Runtime -} - /** * Executor of CLI commands. * diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/checkstyle/CheckStyleConfig.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/checkstyle/CheckStyleConfig.kt index e3a0ef29a..e1442a0ef 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/checkstyle/CheckStyleConfig.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/checkstyle/CheckStyleConfig.kt @@ -26,11 +26,12 @@ package io.spine.internal.gradle.checkstyle -import io.spine.internal.dependency.CheckStyle +import org.gradle.accessors.dm.LibrariesForLibs 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.getByType import org.gradle.kotlin.dsl.the /** @@ -58,9 +59,10 @@ object CheckStyleConfig { } val configDir = project.rootDir.resolve("config/quality/") + val libs = project.rootProject.extensions.getByType() with(project.the()) { - toolVersion = CheckStyle.version + toolVersion = libs.versions.checkStyle.get().toString() configDirectory.set(configDir) } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/DartPlugins.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/DartPlugins.kt index 061e2add2..5c8883d63 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/DartPlugins.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/DartPlugins.kt @@ -28,10 +28,12 @@ package io.spine.internal.gradle.dart.plugin import io.spine.internal.gradle.dart.DartContext import io.spine.internal.gradle.dart.DartEnvironment +import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.api.Project import org.gradle.api.plugins.ExtensionContainer import org.gradle.api.plugins.PluginContainer import org.gradle.api.tasks.TaskContainer +import org.gradle.kotlin.dsl.getByType /** * A scope for applying and configuring Dart-related plugins. @@ -40,7 +42,8 @@ import org.gradle.api.tasks.TaskContainer * * 1. [plugins]. * 2. [extensions]. - * 3. [tasks]. + * 3. [libs]. + * 4. [tasks]. * * Let's imagine one wants to apply and configure `FooBar` plugin. To do that, several steps * should be completed: @@ -79,6 +82,7 @@ class DartPlugins(dartEnv: DartEnvironment, project: Project) : DartContext(dart internal val plugins = project.plugins internal val extensions = project.extensions + internal val libs = extensions.getByType() internal val tasks = project.tasks internal fun plugins(configurations: PluginContainer.() -> Unit) = diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/Protobuf.kt index 350f0fbd3..454373b01 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/Protobuf.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/dart/plugin/Protobuf.kt @@ -31,7 +31,6 @@ import com.google.protobuf.gradle.id import com.google.protobuf.gradle.plugins import com.google.protobuf.gradle.protobuf import com.google.protobuf.gradle.remove -import io.spine.internal.dependency.Protobuf /** * Applies `protobuf` plugin and configures `GenerateProtoTask` to work with a Dart module. @@ -40,7 +39,7 @@ import io.spine.internal.dependency.Protobuf */ fun DartPlugins.protobuf() { - plugins.apply(Protobuf.GradlePlugin.id) + plugins.apply(libs.plugins.protobuf.get().pluginId) project.protobuf { generateProtoTasks.all().forEach { task -> diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/JsPlugins.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/JsPlugins.kt index 6a17820da..8fa52a6ec 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/JsPlugins.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/JsPlugins.kt @@ -28,10 +28,12 @@ package io.spine.internal.gradle.javascript.plugin import io.spine.internal.gradle.javascript.JsContext import io.spine.internal.gradle.javascript.JsEnvironment +import org.gradle.accessors.dm.LibrariesForLibs import org.gradle.api.Project import org.gradle.api.plugins.ExtensionContainer import org.gradle.api.plugins.PluginContainer import org.gradle.api.tasks.TaskContainer +import org.gradle.kotlin.dsl.getByType /** * A scope for applying and configuring JavaScript-related plugins. @@ -40,7 +42,8 @@ import org.gradle.api.tasks.TaskContainer * * 1. [plugins]. * 2. [extensions]. - * 3. [tasks]. + * 3. [libs]. + * 4. [tasks]. * * Let's imagine one wants to apply and configure `FooBar` plugin. To do that, several steps * should be completed: @@ -79,6 +82,7 @@ class JsPlugins(jsEnv: JsEnvironment, project: Project) : JsContext(jsEnv, proje internal val plugins = project.plugins internal val extensions = project.extensions + internal val libs = extensions.getByType() internal val tasks = project.tasks internal fun plugins(configurations: PluginContainer.() -> Unit) = diff --git a/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/Protobuf.kt b/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/Protobuf.kt index d99d2a288..48e6b8c01 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/Protobuf.kt +++ b/buildSrc/src/main/kotlin/io/spine/internal/gradle/javascript/plugin/Protobuf.kt @@ -32,7 +32,6 @@ import com.google.protobuf.gradle.id import com.google.protobuf.gradle.protobuf import com.google.protobuf.gradle.protoc import com.google.protobuf.gradle.remove -import io.spine.internal.dependency.Protobuf /** * Applies and configures `protobuf` plugin to work with a JavaScript module. @@ -47,7 +46,7 @@ import io.spine.internal.dependency.Protobuf fun JsPlugins.protobuf() { plugins { - apply(Protobuf.GradlePlugin.id) + apply(libs.plugins.protobuf.get().pluginId) } project.protobuf { @@ -55,7 +54,7 @@ fun JsPlugins.protobuf() { generatedFilesBaseDir = projectDir.path protoc { - artifact = Protobuf.compiler + artifact = libs.protobuf.compiler.get().toString() } generateProtoTasks { diff --git a/buildSrc/src/main/kotlin/pmd-settings.gradle.kts b/buildSrc/src/main/kotlin/pmd-settings.gradle.kts index 03e69a67e..ba0a6a620 100644 --- a/buildSrc/src/main/kotlin/pmd-settings.gradle.kts +++ b/buildSrc/src/main/kotlin/pmd-settings.gradle.kts @@ -24,14 +24,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import io.spine.internal.dependency.Pmd +import org.gradle.accessors.dm.LibrariesForLibs plugins { pmd } pmd { - toolVersion = Pmd.version + val libs = rootProject.extensions.getByType() + + toolVersion = libs.versions.pmd.get() isConsoleOutput = true incrementalAnalysis.set(true) diff --git a/license-report.md b/license-report.md index a06dc4bf1..b2bd251a0 100644 --- a/license-report.md +++ b/license-report.md @@ -1,6 +1,6 @@ -# Dependencies of `io.spine.tools:spine-testutil-time:2.0.0-SNAPSHOT.92` +# Dependencies of `io.spine.tools:spine-testutil-time:2.0.0-SNAPSHOT.93` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -266,11 +266,6 @@ * **Project URL:** [http://junit.org](http://junit.org) * **License:** [Eclipse Public License 1.0](http://www.eclipse.org/legal/epl-v10.html) -1. **Group** : net.java.dev.jna. **Name** : jna. **Version** : 5.6.0. - * **Project URL:** [https://github.com/java-native-access/jna](https://github.com/java-native-access/jna) - * **License:** [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) - * **License:** [LGPL, version 2.1](http://www.gnu.org/licenses/licenses.html) - 1. **Group** : net.sf.saxon. **Name** : Saxon-HE. **Version** : 10.6. * **Project URL:** [http://www.saxonica.com/](http://www.saxonica.com/) * **License:** [Mozilla Public License Version 2.0](http://www.mozilla.org/MPL/2.0/) @@ -380,19 +375,19 @@ * **Project URL:** [https://github.com/Kotlin/dokka](https://github.com/Kotlin/dokka) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.intellij.deps. **Name** : trove4j. **Version** : 1.0.20200330. +1. **Group** : org.jetbrains.intellij.deps. **Name** : trove4j. **Version** : 1.0.20181211. * **Project URL:** [https://github.com/JetBrains/intellij-deps-trove4j](https://github.com/JetBrains/intellij-deps-trove4j) * **License:** [GNU LESSER GENERAL PUBLIC LICENSE 2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-compiler-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-compiler-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-daemon-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-daemon-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-klib-commonizer-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-klib-commonizer-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -400,23 +395,23 @@ * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-script-runtime. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-script-runtime. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-common. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-common. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-impl-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-impl-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-jvm. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-jvm. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -437,7 +432,12 @@ * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-bom. **Version** : 1.6.0.**No license information found** +1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core. **Version** : 1.5.0.**No license information found** 1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core. **Version** : 1.6.0.**No license information found** +1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core-jvm. **Version** : 1.5.0. + * **Project URL:** [https://github.com/Kotlin/kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) + * **License:** [The Apache Software License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core-jvm. **Version** : 1.6.0. * **Project URL:** [https://github.com/Kotlin/kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) * **License:** [The Apache Software License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) @@ -512,12 +512,12 @@ The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue May 03 19:16:19 EEST 2022** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). +This report was generated on **Mon Jun 06 13:46:26 EEST 2022** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). -# Dependencies of `io.spine:spine-time:2.0.0-SNAPSHOT.92` +# Dependencies of `io.spine:spine-time:2.0.0-SNAPSHOT.93` ## Runtime 1. **Group** : com.google.code.findbugs. **Name** : jsr305. **Version** : 3.0.2. @@ -811,11 +811,6 @@ This report was generated on **Tue May 03 19:16:19 EEST 2022** using [Gradle-Lic * **Project URL:** [https://github.com/trustin/os-maven-plugin/](https://github.com/trustin/os-maven-plugin/) * **License:** [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) -1. **Group** : net.java.dev.jna. **Name** : jna. **Version** : 5.6.0. - * **Project URL:** [https://github.com/java-native-access/jna](https://github.com/java-native-access/jna) - * **License:** [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) - * **License:** [LGPL, version 2.1](http://www.gnu.org/licenses/licenses.html) - 1. **Group** : net.ltgt.gradle. **Name** : gradle-errorprone-plugin. **Version** : 2.0.2.**No license information found** 1. **Group** : net.sf.saxon. **Name** : Saxon-HE. **Version** : 10.6. * **Project URL:** [http://www.saxonica.com/](http://www.saxonica.com/) @@ -926,19 +921,19 @@ This report was generated on **Tue May 03 19:16:19 EEST 2022** using [Gradle-Lic * **Project URL:** [https://github.com/Kotlin/dokka](https://github.com/Kotlin/dokka) * **License:** [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.intellij.deps. **Name** : trove4j. **Version** : 1.0.20200330. +1. **Group** : org.jetbrains.intellij.deps. **Name** : trove4j. **Version** : 1.0.20181211. * **Project URL:** [https://github.com/JetBrains/intellij-deps-trove4j](https://github.com/JetBrains/intellij-deps-trove4j) * **License:** [GNU LESSER GENERAL PUBLIC LICENSE 2.1](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-compiler-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-compiler-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-daemon-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-daemon-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-klib-commonizer-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-klib-commonizer-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -946,23 +941,23 @@ This report was generated on **Tue May 03 19:16:19 EEST 2022** using [Gradle-Lic * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-script-runtime. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-script-runtime. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-common. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-common. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-impl-embeddable. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-compiler-impl-embeddable. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) -1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-jvm. **Version** : 1.6.21. +1. **Group** : org.jetbrains.kotlin. **Name** : kotlin-scripting-jvm. **Version** : 1.5.31. * **Project URL:** [https://kotlinlang.org/](https://kotlinlang.org/) * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) @@ -983,7 +978,12 @@ This report was generated on **Tue May 03 19:16:19 EEST 2022** using [Gradle-Lic * **License:** [The Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt) 1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-bom. **Version** : 1.6.0.**No license information found** +1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core. **Version** : 1.5.0.**No license information found** 1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core. **Version** : 1.6.0.**No license information found** +1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core-jvm. **Version** : 1.5.0. + * **Project URL:** [https://github.com/Kotlin/kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) + * **License:** [The Apache Software License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) + 1. **Group** : org.jetbrains.kotlinx. **Name** : kotlinx-coroutines-core-jvm. **Version** : 1.6.0. * **Project URL:** [https://github.com/Kotlin/kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) * **License:** [The Apache Software License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0.txt) @@ -1058,4 +1058,4 @@ This report was generated on **Tue May 03 19:16:19 EEST 2022** using [Gradle-Lic The dependencies distributed under several licenses, are used according their commercial-use-friendly license. -This report was generated on **Tue May 03 19:16:20 EEST 2022** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file +This report was generated on **Mon Jun 06 13:46:27 EEST 2022** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE). \ No newline at end of file diff --git a/pom.xml b/pom.xml index 26407f6bf..66521e38c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ all modules and does not describe the project structure per-subproject. --> io.spine spine-time -2.0.0-SNAPSHOT.92 +2.0.0-SNAPSHOT.93 2015 @@ -32,7 +32,7 @@ all modules and does not describe the project structure per-subproject. org.jetbrains.kotlin kotlin-stdlib-jdk8 - 1.6.21 + 1.5.31 compile @@ -128,17 +128,17 @@ all modules and does not describe the project structure per-subproject. org.jetbrains.kotlin kotlin-compiler-embeddable - 1.6.21 + 1.5.31 org.jetbrains.kotlin kotlin-klib-commonizer-embeddable - 1.6.21 + 1.5.31 org.jetbrains.kotlin kotlin-scripting-compiler-embeddable - 1.6.21 + 1.5.31 diff --git a/settings.gradle.kts b/settings.gradle.kts index 62cc34f1d..4faae2afe 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,6 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import io.spine.internal.catalog.SpineVersionCatalog + pluginManagement { repositories { gradlePluginPortal() @@ -37,3 +39,32 @@ include( "time", "testutil-time", ) + +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + // We don't apply any plugins. + // We just put `SpineVersionCatalog` class on a classpath of settings script. + classpath("io.spine.internal:spine-version-catalog:+") + } +} + +dependencyResolutionManagement { + versionCatalogs { + + /* + Please, check out `buildSrc/settings.gradle.kts` file. + + There is an explanation on why we don't have a plugin, which creates + a catalog on its own, and we have to create a catalog ourselves in + every settings file. + */ + + create("libs") { + SpineVersionCatalog.useIn(this) + } + } +} diff --git a/time/build.gradle.kts b/time/build.gradle.kts index bb5f13ca4..42f27a51a 100644 --- a/time/build.gradle.kts +++ b/time/build.gradle.kts @@ -24,7 +24,6 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import io.spine.internal.dependency.AutoService import io.spine.internal.gradle.publish.IncrementGuard import io.spine.internal.gradle.excludeProtobufLite @@ -36,8 +35,8 @@ apply() val spineBaseVersion: String by extra dependencies { - annotationProcessor(AutoService.processor) - compileOnly(AutoService.annotations) + annotationProcessor(libs.googleAuto.service.processor) + compileOnly(libs.googleAuto.service.annotations) api("io.spine:spine-base:$spineBaseVersion") diff --git a/version-catalog/README.md b/version-catalog/README.md new file mode 100644 index 000000000..898f6919a --- /dev/null +++ b/version-catalog/README.md @@ -0,0 +1,241 @@ +# SpineVersionCatalog + +Represents a set of dependencies used in Spine-related projects. It's assembled +and published in a form of Gradle's [Version Catalog](https://docs.gradle.org/current/userguide/platforms.html#sec:sharing-catalogs). + + +## Usage example + +In order to use this catalog, one should perform the following: + + 1. Put `spine-version-catalog` library on a classpath of `settings.gradle.kts` file. + 2. Create a new version catalog. `libs` is a conventional name to go with. + 3. Apply `SpineVersionCatalog` to a newly created catalog. + +Below is an example of how to obtain this catalog in the project. + +In `settings.gradle.kts` file of the project: + +```kotlin +import io.spine.internal.catalog.SpineVersionCatalog + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath("io.spine.internal:spine-version-catalog:2.0.0") + } +} + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + SpineVersionCatalog.useIn(this) + } + } +} +``` + + +## Adding a new dependency to the catalog + +In order to add a new dependency to this catalog, perform the following steps: + + 1. Go to `catalog` module. + 2. Open `io.spine.internal.catalog.entry` package. + 3. Create a new file there, which contains an object declaration, named after + a dependency, that is being added. + 4. Make an object inherit from `CatalogEntry`. + 5. Perform all necessary declarations within this object. + 6. Publish a new version of the catalog. + +Take a look on an example, which showcases usage of `CatalogEntry` API. Pay attention +to how entries are nested one into another. And how it reflects in their resulting accessors. + +Source code of `Dummy` dependency: + +```kotlin +internal object Dummy : CatalogEntry() { + + private const val group = "org.dummy.company" + override val module = "$group:dummy-lib" // libs.dummy + override val version = "1.0.0" // libs.versions.dummy + + val core by lib("$group:dummy-core") // libs.dummy.core + val runner by lib("$group:dummy-runner") // libs.dummy.runner + val api by lib("$group:dummy-api") // libs.dummy.api + + // In bundles, you can reference entries (which declare module), extra + // libraries, or declare them in-place. + + override val bundle = setOf( // libs.bundles.dummy + this, + core, runner, api, + lib("params", "$group:dummy-params"), // libs.dummy.params + lib("types", "$group:dummy-types"), // libs.dummy.types + ) + + // "GradlePlugin" - is a special entry name. "gradlePlugin" suffix will not + // be put for a final plugin alias. Note, that in an example below, we have + // this suffix for the version and module, and does not have for ID. + + object GradlePlugin : CatalogEntry() { + override val version = "0.0.8" // libs.versions.dummy.gradlePlugin + override val module = "$group:my-dummy-plugin" // libs.dummy.gradlePlugin + override val id = "my-dummy-plugin" // libs.plugins.dummy + } + + object Runtime : CatalogEntry() { + + // When an entry does not override the version, it will try to fetch it + // from the closest parental entry, which has one. For example, in this case, + // all libraries within "Runtime" entry will have version = "1.0.0". + + val win by lib("$group:runtime-win") // libs.dummy.runtime.win + val mac by lib("$group:runtime-mac") // libs.dummy.runtime.mac + val linux by lib("$group:runtime-linux") // libs.dummy.runtime.linux + + object Bom : CatalogEntry() { + override val version = "2.0.0" // libs.versions.dummy.runtime.bom + override val module = "$group:dummy-bom" // libs.dummy.runtime.bom + } + } + + // It's also possible to declare an extra bundle by a property delegate. + // Just like with extra modules. + + val runtime by bundle( // libs.bundles.dummy.runtime + Runtime.Bom, + Runtime.win, + Runtime.mac, + Runtime.linux, + ) +} +``` + + +## Overriding of items shipped by `SpineVersionCatalog` + +Sometimes, it happens that a project needs to override items, shipped by the catalog. +In most cases, it is needed to override one or more versions. + +Currently, Gradle does not [provide](https://github.com/gradle/gradle/issues/20836) +a clear way to perform overwrite for already created catalogs. Thus, we use approach +with creating a catalog directly in settings files. It preserves a possibility +of a local override. + +Each item in a version catalog is known by an alias. The generated accessors to +items are based on them. And in order to override an item, one should know its alias. +Out of comments do `Dummy` dependency, it's seen how an alias is formed. + +Below are examples on how to override the items of `Dummy` dependency. Instead of +applying `SpineVersionCatalog`, `DummyVersionCatalog` is used, as we are going to +override `Dummy`'s items. + +### Overriding of versions + +In order to override a version you should declare it *before* applying the catalog. +A version, declared first, always wins. All subsequent declarations of the same version +will be ignored by the builder. + +In total, `Dummy` declares three versions. + +Let's override them all: + +```kotlin +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + + // Firstly, we declare versions, we would like to use instead of ones, + // provided by `DummyVersionCatalog`. + + version("dummy", "2.0.0") // Dummy.version + version("dummy-gradlePlugin", "0.0.9") // Dummy.GradlePlugin.version + version("dummy-runtime-bom", "3.0.0") // Dummy.Runtime.Bom.version + + // Secondly, we apply the catalog. It will try to declare the versions + // above one more time, but subsequent declarations of versions are + // ignored by `VersionCatalogBuilder`. + + DummyVersionCatalog.useIn(this) + } + } +} +``` + +### Overriding of libraries, plugins and bundles + +In order to override a library, plugin or bundle, one should declare it *after* +applying the catalog. This is the opposite of what is done with versions. + +For example: + +```kotlin +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + + // Firstly, we apply the catalog. + + DummyVersionCatalog.useIn(this) + + // Secondly, we declare needed libraries, plugins and bundles one more time. + // Subsequent declarations of those items override previous declarations. + // Which is the opposite to how it works with version items. + + // For libraries, it's impossible to override only a module (group + artifact). + // They are overridden by full GAV coordinates (group + artifact + version). + // Even if the version remains the same, it should be specified as a part of GAV. + + library("dummy", "org.dummy.company:dummy-lib-patched:3.41-patched") // Dummy.module + version + library("dummy-gradlePlugin", "org.dummy.company:another-plugin:3.41-patched") // Dummy.GradlePlugin.module + version + library("dummy-runtime-mac", "org.dummy.company:runtime-linux:3.41-patched") // Dummy.Runtime.mac + version + + // The same applies to plugins. It's impossible to override only `ID`. + // Plugin's version should be necessarily specified, even if remains the same. + // Otherwise, an error will occur. + + plugin("dummy", "my-dummy-plugin-patched").version("1.0.0-patched") // Dummy.GradlePlugin.id + version + + // In bundles, the passed list consists of aliases. Each alias is meant + // to point to a library declaration. If not, an error will occur. + + bundle("dummy", listOf("dummy-runtime-bom", "dummy-runtime-win")) // Dummy.bundle + bundle("dummy-runtime", listOf("dummy", "dummy-core")) // Dummy.runtime + } + } +} +``` + + +## Modules structure + +Within this PR, `spine-version-catalog` is a resident of `time` repository, but +it is a standalone project. Meaning, it has its own Gradle's `settings` file, +and doesn't relate anyhow to `time`. + +`spine-version-catalog` consists of two modules: + +1. `catalog` – provides a facade upon Gradle's provided `VersionCatalogBuilder` + and assembles `SpineVersionCatalog`, using that facade. +2. `func-test` – performs testing of the facade with a real instance of `VersionCatalogBuilder`. + To do that, the module does the following: + + 1. Assembles a `dummy-catalog` with a single `Dummy` dependency and publishes + it to Maven local. In order to declare `Dummy`, the module depends on `:catalog`, + which exposes the declarative facade. + 2. Makes `dummy-project` use `dummy-catalog` from Maven local. + 3. Builds `dummy-project`. It has assertions in its build file. Those assertions + verify the generated type-safe accessors to `Dummy` dependency. If any of + assertions fails, the test fails accordingly. + + +## Details about Functional Testing + +We have to do a true functional testing here, because Gradle does not provide +a test fixture for `Settings`, as it does for `Project`. For this reason, we test +it on a real Gradle project, with assertions right in a build file. + +See [issue](https://github.com/gradle/gradle/issues/20807) for details. diff --git a/version-catalog/build.gradle.kts b/version-catalog/build.gradle.kts new file mode 100644 index 000000000..183608729 --- /dev/null +++ b/version-catalog/build.gradle.kts @@ -0,0 +1,58 @@ +/* + * Copyright 2022, 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 + * + * http://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. + */ + +plugins { + id("org.jetbrains.kotlin.jvm") version "1.6.21" +} + +subprojects { + group = "io.spine.internal" + version = "2.0.0-SNAPSHOT.1" + + apply { + plugin("org.jetbrains.kotlin.jvm") + } + + repositories { + mavenCentral() + } + + dependencies { + implementation(platform("org.jetbrains.kotlin:kotlin-bom")) + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") + + testImplementation("com.google.truth:truth:1.1.3") + testImplementation("com.google.truth.extensions:truth-java8-extension:1.1.3") + testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.2") + } + + tasks { + withType().configureEach { + useJUnitPlatform { includeEngines("junit-jupiter") } + testLogging { showStandardStreams = true } + } + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsCli.kt b/version-catalog/catalog/build.gradle.kts similarity index 75% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsCli.kt rename to version-catalog/catalog/build.gradle.kts index 79a4036cd..09718a481 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsCli.kt +++ b/version-catalog/catalog/build.gradle.kts @@ -24,15 +24,22 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +plugins { + `maven-publish` +} -/** - * Commons CLI is a transitive dependency which we don't use directly. - * We `force` it in [DependencyResolution.forceConfiguration]. - * - * [Commons CLI](https://commons.apache.org/proper/commons-cli/) - */ -object CommonsCli { - private const val version = "1.5.0" - const val lib = "commons-cli:commons-cli:${version}" +dependencies { + api(gradleApi()) + implementation("org.reflections:reflections:0.10.2") +} + +publishing { + publications { + create("mavenJava") { + groupId = project.group.toString() + artifactId = "spine-version-catalog" + version = project.version.toString() + from(components["java"]) + } + } } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/SpineVersionCatalog.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/SpineVersionCatalog.kt new file mode 100644 index 000000000..c88d3c9e6 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/SpineVersionCatalog.kt @@ -0,0 +1,111 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog + +import io.spine.internal.catalog.model.CatalogEntry +import org.gradle.api.initialization.dsl.VersionCatalogBuilder +import org.reflections.Reflections +import org.reflections.util.ConfigurationBuilder + +/** + * Contains dependencies, which are used in Spine-related projects. + * + * In order to use this catalog, one should perform the following: + * + * 1. Obtain this class on a classpath of `settings.gradle.kts` file. + * 2. Create a version catalog. `libs` is a conventional name to go with. + * 3. Call [useIn] on a newly created catalog. + * + * Below is an example of how to obtain this catalog in the project. + * + * In `settings.gradle.kts` file of the project: + * + * ``` + * import io.spine.internal.catalog.SpineVersionCatalog + * + * buildscript { + * repositories { + * mavenCentral() + * } + * dependencies { + * classpath("io.spine.internal:spine-version-catalog:2.0.0") + * } + * } + * + * dependencyResolutionManagement { + * versionCatalogs { + * create("libs") { + * SpineVersionCatalog.useIn(this) + * } + * } + * } + * ``` + * + * In order to add a new dependency to this catalog, create an object declaration + * that inherits from [CatalogEntry] in [io.spine.internal.catalog.entry] package. + * Take a look on a special `Dummy` dependency in README file to quickly grasp API + * of a dependency declaration. + */ +@Suppress("unused") +class SpineVersionCatalog { + companion object { + + private const val pkg = "io.spine.internal.catalog.entry" + + /** + * Fills up the given version catalog with dependencies, declared in + * this catalog. + */ + fun useIn(catalog: VersionCatalogBuilder) { + val entries = findEntries() + val records = entries.flatMap { it.allRecords() } + records.forEach { it.writeTo(catalog) } + } + + /** + * This method utilizes reflection in order to scan the package for + * declared [catalog entries][CatalogEntry]. + * + * The [Reflections] builder is configured to search for all subclasses + * of [CatalogEntry], declared in the [given package][pkg]. The found + * entries, in order to be included into the resulting set, should meet + * the following criteria: + * + * 1. Be an object declaration. Only objects can serve as concrete entries. + * 2. Be top-level declared. Only root entries can be asked for records. + */ + private fun findEntries(): Set { + val builder = ConfigurationBuilder().forPackage(pkg) + val reflections = Reflections(builder) + val result = reflections.getSubTypesOf(CatalogEntry::class.java) + .filter { it.enclosingClass == null } + .mapNotNull { it.kotlin.objectInstance } + .toSet() + return result + } + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AnimalSniffer.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AnimalSniffer.kt similarity index 77% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/AnimalSniffer.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AnimalSniffer.kt index 068ae59ce..200060b91 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AnimalSniffer.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AnimalSniffer.kt @@ -24,10 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/ -object AnimalSniffer { - private const val version = "1.21" - const val lib = "org.codehaus.mojo:animal-sniffer-annotations:${version}" +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [AnimalSniffer](https://www.mojohaus.org/animal-sniffer/animal-sniffer-maven-plugin/) + */ +@Suppress("unused") +internal object AnimalSniffer : CatalogEntry() { + override val version = "1.21" + override val module = "org.codehaus.mojo:animal-sniffer-annotations" } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ApacheCommons.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ApacheCommons.kt new file mode 100644 index 000000000..42a0f29ba --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ApacheCommons.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +@Suppress("unused") +internal object ApacheCommons : CatalogEntry() { + + /** + * [CommonsCli](https://commons.apache.org/proper/commons-cli/) + */ + object Cli : CatalogEntry() { + override val version = "1.5.0" + override val module = "commons-cli:commons-cli" + } + + /** + * [CommonsCodec](https://commons.apache.org/proper/commons-codec/changes-report.html) + */ + object Codec : CatalogEntry() { + override val version = "1.15" + override val module = "commons-codec:commons-codec" + } + + /** + * [CommonsLogging](https://commons.apache.org/proper/commons-logging/) + */ + object Logging : CatalogEntry() { + override val version = "1.2" + override val module = "commons-logging:commons-logging" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/ApacheHttp.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ApacheHttp.kt similarity index 81% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/ApacheHttp.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ApacheHttp.kt index dd518a0c0..3ee992808 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/ApacheHttp.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ApacheHttp.kt @@ -24,11 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -@Suppress("unused") -object ApacheHttp { +import io.spine.internal.catalog.model.CatalogEntry - // https://hc.apache.org/downloads.cgi - const val core = "org.apache.httpcomponents:httpcore:4.4.14" +/** + * [ApacheHttp](https://hc.apache.org/downloads.cgi) + */ +@Suppress("unused") +internal object ApacheHttp : CatalogEntry() { + override val version = "4.4.14" + val core by lib("org.apache.httpcomponents:httpcore") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/LicenseReport.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AppEngine.kt similarity index 73% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/LicenseReport.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AppEngine.kt index 8d0797631..c9d116a5f 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/LicenseReport.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AppEngine.kt @@ -24,17 +24,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://github.com/jk1/Gradle-License-Report +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [AppEngine](https://cloud.google.com/java/docs/reference) + */ @Suppress("unused") -object LicenseReport { - private const val version = "1.16" - const val lib = "com.github.jk1:gradle-license-report:${version}" +internal object AppEngine : CatalogEntry() { + + override val version = "1.9.82" + val sdk by lib("com.google.appengine:appengine-api-1.0-sdk") - object GradlePlugin { - const val version = LicenseReport.version - const val id = "com.github.jk1.dependency-license-report" - const val lib = LicenseReport.lib + object GradlePlugin : CatalogEntry() { + override val version = "2.2.0" + override val module = "com.google.cloud.tools:appengine-gradle-plugin" } } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AssertK.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AssertK.kt similarity index 85% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/AssertK.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AssertK.kt index 8d42b6193..a1522d279 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AssertK.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/AssertK.kt @@ -24,15 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** - * Assertion library for tests in Kotlin - * * [AssertK](https://github.com/willowtreeapps/assertk) */ @Suppress("unused") -object AssertK { - private const val version = "0.25" - const val libJvm = "com.willowtreeapps.assertk:assertk-jvm:${version}" +internal object AssertK : CatalogEntry() { + override val version = "0.25" + val jvm by lib("com.willowtreeapps.assertk:assertk-jvm") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/BouncyCastle.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/BouncyCastle.kt similarity index 80% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/BouncyCastle.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/BouncyCastle.kt index c0567edda..fe05363c3 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/BouncyCastle.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/BouncyCastle.kt @@ -24,10 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://www.bouncycastle.org/java.html +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [BouncyCastle](https://www.bouncycastle.org/java.html) + */ @Suppress("unused") -object BouncyCastle { - const val libPkcsJdk15 = "org.bouncycastle:bcpkix-jdk15on:1.68" +internal object BouncyCastle : CatalogEntry() { + override val version = "1.68" + val libPkcsJdk15 by lib("org.bouncycastle:bcpkix-jdk15on") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CheckStyle.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/CheckStyle.kt similarity index 84% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/CheckStyle.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/CheckStyle.kt index 1e3effbae..7932ae6d8 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CheckStyle.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/CheckStyle.kt @@ -24,11 +24,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://checkstyle.sourceforge.io/ -// See `io.spine.internal.gradle.checkstyle.CheckStyleConfig`. +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [CheckStyle](https://checkstyle.sourceforge.io/) + */ @Suppress("unused") -object CheckStyle { - const val version = "10.1" +internal object CheckStyle : CatalogEntry() { + override val version = "10.1" } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/CheckerFramework.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/CheckerFramework.kt new file mode 100644 index 000000000..da54f48c8 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/CheckerFramework.kt @@ -0,0 +1,53 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [CheckerFramework](https://checkerframework.org/) + */ +@Suppress("unused") +internal object CheckerFramework : CatalogEntry() { + + /** + * This is a discontinued artifact, which we do not use directly. + * It is a transitive dependency which we use for forcing the version. + */ + object CompatQual : CatalogEntry() { + override val version = "2.5.5" + override val module = "org.checkerframework:checker-compat-qual" + } + + override val version = "3.21.3" + val annotations by lib("org.checkerframework:checker-qual") + + val dataflow by bundle( + lib("dataflow", "org.checkerframework:dataflow"), + lib("javacUtil", "org.checkerframework:javacutil") + ) +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Dokka.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Dokka.kt similarity index 63% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Dokka.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Dokka.kt index b9f811d04..4677f433d 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Dokka.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Dokka.kt @@ -24,31 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://github.com/Kotlin/dokka -@Suppress("unused") -object Dokka { - private const val group = "org.jetbrains.dokka" +import io.spine.internal.catalog.model.CatalogEntry - /** - * When changing the version, also change the version used in the `buildSrc/build.gradle.kts`. - */ - const val version = "1.6.20" - - 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 in project's build files, only the [id] should be used. - */ - const val lib = "${group}:dokka-gradle-plugin:${version}" - } +/** + * [Dokka](https://github.com/Kotlin/dokka) + */ +@Suppress("unused") +internal object Dokka : CatalogEntry() { - object BasePlugin { - const val lib = "${group}:dokka-base:${version}" - } + private const val group = "org.jetbrains.dokka" + override val version = "1.6.20" /** * To generate the documentation as seen from Java perspective use this plugin. @@ -56,21 +43,23 @@ object Dokka { * @see * Dokka output formats */ - object KotlinAsJavaPlugin { - const val lib = "${group}:kotlin-as-java-plugin:${version}" - } + val kotlinAsJavaPlugin by lib("$group:kotlin-as-java-plugin") + val basePlugin by lib("$group:dokka-base") /** - * Custom Dokka plugins developed for Spine-specific needs like excluding by `@Internal` - * annotation. + * 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" + object SpineExtensions : CatalogEntry() { + override val version = "2.0.0-SNAPSHOT.3" + override val module = "io.spine.tools:spine-dokka-extensions" + } - const val version = "2.0.0-SNAPSHOT.3" - const val lib = "${group}:spine-dokka-extensions:${version}" + object GradlePlugin : CatalogEntry() { + override val module = "$group:dokka-gradle-plugin" + override val id = "org.jetbrains.dokka" } } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/GoogleApis.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ErrorProne.kt similarity index 51% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/GoogleApis.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ErrorProne.kt index af663dc15..582e34535 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/GoogleApis.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/ErrorProne.kt @@ -24,36 +24,41 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** - * Provides dependencies on [GoogleApis projects](https://github.com/googleapis/). + * [ErrorProne](https://github.com/google/error-prone) */ @Suppress("unused") -object GoogleApis { - - // https://github.com/googleapis/google-api-java-client - const val client = "com.google.api-client:google-api-client:1.32.2" +internal object ErrorProne : CatalogEntry() { - // https://github.com/googleapis/api-common-java - const val common = "com.google.api:api-common:2.1.1" + override val version = "2.13.1" - // https://github.com/googleapis/java-common-protos - const val commonProtos = "com.google.api.grpc:proto-google-common-protos:2.7.0" + val core by lib("com.google.errorprone:error_prone_core") + val checkApi by lib("com.google.errorprone:error_prone_check_api") + val testHelpers by lib("com.google.errorprone:error_prone_test_helpers") - // https://github.com/googleapis/gax-java - const val gax = "com.google.api:gax:2.7.1" + val annotations by bundle( + lib("annotations", "com.google.errorprone:error_prone_annotations"), + lib("typeAnnotations", "com.google.errorprone:error_prone_type_annotations") + ) - // 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" + /** + * [JavacPlugin](https://github.com/tbroyer/gradle-errorprone-plugin/blob/v0.8/build.gradle.kts) + */ + object JavacPlugin : CatalogEntry() { + override val version = "9+181-r4173-1" + override val module = "com.google.errorprone:javac" + } - // 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}" + /** + * [GradlePlugin](https://github.com/tbroyer/gradle-errorprone-plugin/releases) + */ + object GradlePlugin : CatalogEntry() { + override val version = "2.0.2" + override val module = "net.ltgt.gradle:gradle-errorprone-plugin" + override val id = "net.ltgt.errorprone" } } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/FindBugs.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/FindBugs.kt similarity index 67% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/FindBugs.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/FindBugs.kt index 52b05f758..a48cde24b 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/FindBugs.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/FindBugs.kt @@ -24,16 +24,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** - * The FindBugs project is 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. + * The FindBugs project is 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. + * + * See [this issue](https://github.com/SpineEventEngine/base/issues/108) for more details. */ -object FindBugs { - private const val version = "3.0.2" - const val annotations = "com.google.code.findbugs:jsr305:${version}" +@Suppress("unused") +internal object FindBugs : CatalogEntry() { + override val version = "3.0.2" + val annotations by lib("com.google.code.findbugs:jsr305") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Firebase.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Firebase.kt similarity index 77% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Firebase.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Firebase.kt index 5e471caad..10a673d2d 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Firebase.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Firebase.kt @@ -24,11 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry -// https://firebase.google.com/docs/admin/setup#java @Suppress("unused") -object Firebase { - private const val adminVersion = "8.1.0" - const val admin = "com.google.firebase:firebase-admin:${adminVersion}" +internal object Firebase : CatalogEntry() { + + /** + * [Firebase Admin](https://firebase.google.com/docs/admin/setup#java) + */ + object Admin : CatalogEntry() { + override val version = "8.1.0" + override val module = "com.google.firebase:firebase-admin" + } } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Flogger.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Flogger.kt new file mode 100644 index 000000000..071b6aece --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Flogger.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [Flogger](https://github.com/google/flogger) + */ +@Suppress("unused") +internal object Flogger : CatalogEntry() { + + private const val group = "com.google.flogger" + override val version = "0.7.4" + override val module = "$group:flogger" + + object Runtime : CatalogEntry() { + val systemBackend by lib("$group:flogger-system-backend") + val log4J by lib("$group:flogger-log4j") + val slf4J by lib("$group:slf4j-backend-factory") + } +} diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleApis.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleApis.kt new file mode 100644 index 000000000..d6322a84a --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleApis.kt @@ -0,0 +1,93 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [GoogleApis](https://github.com/googleapis/) + */ +@Suppress("unused") +internal object GoogleApis : CatalogEntry() { + + /** + * [Client](https://github.com/googleapis/google-api-java-client) + */ + object Client : CatalogEntry() { + override val version = "1.32.2" + override val module = "com.google.api-client:google-api-client" + } + + /** + * [Common](https://github.com/googleapis/api-common-java) + */ + object Common : CatalogEntry() { + override val version = "2.1.1" + override val module = "com.google.api:api-common" + } + + /** + * [CommonProtos](https://github.com/googleapis/java-common-protos) + */ + object CommonProtos : CatalogEntry() { + override val version = "2.7.0" + override val module = "com.google.api.grpc:proto-google-common-protos" + } + + /** + * [GAX](https://github.com/googleapis/gax-java) + */ + object Gax : CatalogEntry() { + override val version = "2.7.1" + override val module = "com.google.api:gax" + } + + /** + * [ProtoAim](https://github.com/googleapis/java-iam) + */ + object ProtoAim : CatalogEntry() { + override val version = "1.2.0" + override val module = "com.google.api.grpc:proto-google-iam-v1" + } + + /** + * [OAuthClient](https://github.com/googleapis/google-oauth-java-client) + */ + object OAuthClient : CatalogEntry() { + override val version = "1.32.1" + override val module = "com.google.oauth-client:google-oauth-client" + } + + /** + * [AuthLibrary](https://github.com/googleapis/google-auth-library-java) + */ + object AuthLibrary : CatalogEntry() { + override val version = "1.3.0" + val credentials by lib("com.google.auth:google-auth-library-credentials") + val oAuth2Http by lib("com.google.auth:google-auth-library-oauth2-http") + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/HttpClient.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleAuto.kt similarity index 63% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/HttpClient.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleAuto.kt index 849f1f4a6..0ff12c825 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/HttpClient.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleAuto.kt @@ -24,19 +24,29 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** - * Google implementations of [HTTP client](https://github.com/googleapis/google-http-java-client). + * [GoogleAuto](https://github.com/google/auto) */ @Suppress("unused") -object HttpClient { - // https://github.com/googleapis/google-http-java-client - const val version = "1.41.5" - 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}" +internal object GoogleAuto : CatalogEntry() { + + object Common : CatalogEntry() { + override val version = "1.2.1" + override val module = "com.google.auto:auto-common" + } + + object Service : CatalogEntry() { + override val version = "1.0.1" + val annotations by lib("com.google.auto.service:auto-service-annotations") + val processor by lib("com.google.auto.service:auto-service") + } - const val apache = "com.google.http-client:google-http-client-apache:2.1.2" + object Value : CatalogEntry() { + override val version = "1.9" + val annotations by lib("com.google.auto.value:auto-value-annotations") + } } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleCloud.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleCloud.kt new file mode 100644 index 000000000..d20d27bcb --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GoogleCloud.kt @@ -0,0 +1,70 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +@Suppress("unused") +internal object GoogleCloud : CatalogEntry() { + + /** + * [Core](https://github.com/googleapis/java-core) + */ + object Core : CatalogEntry() { + override val version = "2.3.3" + override val module = "com.google.cloud:google-cloud-core" + } + + /** + * [PubSubGrcpApi](https://github.com/googleapis/java-pubsub/tree/main/proto-google-cloud-pubsub-v1) + */ + object PubSubGrpcApi : CatalogEntry() { + override val version = "1.97.0" + override val module = "com.google.api.grpc:proto-google-cloud-pubsub-v1" + } + + /** + * [Trace](https://github.com/googleapis/java-trace) + */ + object Trace : CatalogEntry() { + override val version = "2.1.0" + override val module = "com.google.cloud:google-cloud-trace" + } + + /** + * [Datastore](https://github.com/googleapis/java-datastore) + */ + object Datastore : CatalogEntry() { + override val version = "2.2.1" + override val module = "com.google.cloud:google-cloud-datastore" + } + + object ArtifactRegistry : CatalogEntry() { + override val version = "2.1.2" + val authCommon by lib("com.google.cloud.artifactregistry:artifactregistry-auth-common") + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsCodec.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GrGit.kt similarity index 84% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsCodec.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GrGit.kt index 97dbed873..f7a035ae4 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsCodec.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/GrGit.kt @@ -24,11 +24,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry -// https://commons.apache.org/proper/commons-codec/changes-report.html @Suppress("unused") -object CommonsCodec { - private const val version = "1.15" - const val lib = "commons-codec:commons-codec:$version" +internal object GrGit : CatalogEntry() { + override val version = "3.1.1" + val core by lib("org.ajoberstar.grgit:grgit-core") } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Grpc.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Grpc.kt new file mode 100644 index 000000000..5fb8c2ce7 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Grpc.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [Grpc Java](https://github.com/grpc/grpc-java) + */ +@Suppress("unused") +internal object Grpc : CatalogEntry() { + override val version = "1.45.1" + val api by lib("io.grpc:grpc-api") + val auth by lib("io.grpc:grpc-auth") + val core by lib("io.grpc:grpc-core") + val context by lib("io.grpc:grpc-context") + val stub by lib("io.grpc:grpc-stub") + val okHttp by lib("io.grpc:grpc-okhttp") + val protobuf by lib("io.grpc:grpc-protobuf") + val protobufLite by lib("io.grpc:grpc-protobuf-lite") + val protobufPlugin by lib("io.grpc:protoc-gen-grpc-java") + val netty by lib("io.grpc:grpc-netty") + val nettyShaded by lib("io.grpc:grpc-netty-shaded") +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Gson.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Gson.kt similarity index 82% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Gson.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Gson.kt index e161ee1e8..efd3ce62e 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Gson.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Gson.kt @@ -24,15 +24,19 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * Gson is a transitive dependency which we don't use directly. - * We `force` it in [DependencyResolution.forceConfiguration()]. + * + * This object is used for forcing the version. * * [Gson](https://github.com/google/gson) */ -object Gson { - private const val version = "2.9.0" - const val lib = "com.google.code.gson:gson:${version}" +@Suppress("unused") +internal object Gson : CatalogEntry() { + override val version = "2.9.0" + override val module = "com.google.code.gson:gson" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Guava.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Guava.kt similarity index 81% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Guava.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Guava.kt index faaf3b8ba..7d222e107 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Guava.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Guava.kt @@ -24,7 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * The dependencies for Guava. @@ -32,10 +34,12 @@ package io.spine.internal.dependency * 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. + * + * [Guava](https://github.com/google/guava) */ -// https://github.com/google/guava -object Guava { - private const val version = "31.1-jre" - const val lib = "com.google.guava:guava:${version}" - const val testLib = "com.google.guava:guava-testlib:${version}" +@Suppress("unused") +internal object Guava : CatalogEntry() { + override val version = "31.1-jre" + override val module = "com.google.guava:guava" + val testLib by lib("com.google.guava:guava-testlib") } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/HttpClient.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/HttpClient.kt new file mode 100644 index 000000000..b3e485e07 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/HttpClient.kt @@ -0,0 +1,51 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [Google HTTP client](https://github.com/googleapis/google-http-java-client) + */ +@Suppress("unused") +internal object HttpClient : CatalogEntry() { + + /** + * [Releases](https://github.com/googleapis/google-http-java-client) + */ + override val version = "1.41.5" + + val google by lib("com.google.http-client:google-http-client") + val jackson2 by lib("com.google.http-client:google-http-client-jackson2") + val gson by lib("com.google.http-client:google-http-client-gson") + val apache2 by lib("com.google.http-client:google-http-client-apache-v2") + + object Apache : CatalogEntry() { + override val version = "2.1.2" + override val module = "com.google.http-client:google-http-client-apache" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/J2ObjC.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/J2ObjC.kt similarity index 73% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/J2ObjC.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/J2ObjC.kt index 9ed18f264..37e270809 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/J2ObjC.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/J2ObjC.kt @@ -24,18 +24,23 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * [J2ObjC](https://developers.google.com/j2objc) is a transitive dependency * which we don't use directly. This object is used for forcing the version. */ -object J2ObjC { - // https://github.com/google/j2objc/releases - // `1.3.` is the latest version available from Maven Central. - // https://search.maven.org/artifact/com.google.j2objc/j2objc-annotations - private const val version = "1.3" - const val annotations = "com.google.j2objc:j2objc-annotations:${version}" - @Deprecated("Please use `annotations` instead.", ReplaceWith("annotations")) - const val lib = annotations +@Suppress("unused") +internal object J2ObjC : CatalogEntry() { + + /** + * [Releases](https://github.com/google/j2objc/releases) + * [MavenCentral](https://search.maven.org/artifact/com.google.j2objc/j2objc-annotations) + * + * `1.3.` is the latest version available from Maven Central. + */ + override val version = "1.3" + val annotations by lib("com.google.j2objc:j2objc-annotations") } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JUnit.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JUnit.kt new file mode 100644 index 000000000..d3ccb7fa6 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JUnit.kt @@ -0,0 +1,73 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [JUnit5](https://junit.org/junit5/) + */ +@Suppress("unused") +internal object JUnit : CatalogEntry() { + + override val version = "5.8.2" + val bom by lib("org.junit:junit-bom") + val runner by lib("org.junit.jupiter:junit-jupiter-engine") + + /** + * [ApiGuardian](https://github.com/apiguardian-team/apiguardian) + */ + object ApiGuardian : CatalogEntry() { + override val version = "1.1.2" + override val module = "org.apiguardian:apiguardian-api" + } + + object Platform : CatalogEntry() { + override val version = "1.8.2" + val commons by lib("org.junit.platform:junit-platform-commons") + val launcher by lib("org.junit.platform:junit-platform-launcher") + } + + object Legacy : CatalogEntry() { + override val version = "4.13.1" + override val module = "junit:junit" + } + + /** + * [Junit-Pioneer](https://github.com/junit-pioneer/junit-pioneer) + */ + object Pioneer : CatalogEntry() { + override val version = "1.5.0" + override val module = "org.junit-pioneer:junit-pioneer" + } + + override val bundle = setOf( + lib("api", "org.junit.jupiter:junit-jupiter-api"), + lib("params", "org.junit.jupiter:junit-jupiter-params"), + ApiGuardian + ) +} diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Jackson.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Jackson.kt new file mode 100644 index 000000000..98f523bec --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Jackson.kt @@ -0,0 +1,63 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +@Suppress("unused") +internal object Jackson : CatalogEntry() { + + override val version = "2.13.2" + + /** + * [Core](https://github.com/FasterXML/jackson-core) + */ + val core by lib("com.fasterxml.jackson.core:jackson-core") + + /** + * [DataformatXml](https://github.com/FasterXML/jackson-dataformat-xml/releases) + */ + val dataformatXml by lib("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") + + /** + * [DataformatYaml](https://github.com/FasterXML/jackson-dataformats-text/releases) + */ + val dataformatYaml by lib("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") + + /** + * [ModuleKotlin](https://github.com/FasterXML/jackson-module-kotlin/releases) + */ + val moduleKotlin by lib("com.fasterxml.jackson.module:jackson-module-kotlin") + + /** + * [Databind](https://github.com/FasterXML/jackson-databind) + */ + object Databind : CatalogEntry() { + override val version = "2.13.2.2" + override val module = "com.fasterxml.jackson.core:jackson-databind" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaJwt.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaJwt.kt similarity index 86% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaJwt.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaJwt.kt index 424c45fb8..20a1faafa 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaJwt.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaJwt.kt @@ -24,7 +24,9 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * A Java implementation of JSON Web Token (JWT) - RFC 7519. @@ -32,7 +34,7 @@ package io.spine.internal.dependency * [Java JWT](https://github.com/auth0/java-jwt) */ @Suppress("unused") -object JavaJwt { - private const val version = "3.19.1" - const val lib = "com.auth0:java-jwt:${version}" +internal object JavaJwt : CatalogEntry() { + override val version = "3.19.1" + override val module = "com.auth0:java-jwt" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaPoet.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaPoet.kt similarity index 81% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaPoet.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaPoet.kt index e9bdb9b37..50fbd02da 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaPoet.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaPoet.kt @@ -24,11 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://github.com/square/javapoet +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [JavaPoet](https://github.com/square/javapoet) + */ @Suppress("unused") -object JavaPoet { - private const val version = "1.13.0" - const val lib = "com.squareup:javapoet:${version}" +internal object JavaPoet : CatalogEntry() { + override val version = "1.13.0" + override val module = "com.squareup:javapoet" } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaX.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaX.kt new file mode 100644 index 000000000..a0a19e248 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/JavaX.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +@Suppress("unused") +internal object JavaX : CatalogEntry() { + + /** + * This artifact which used to be a part of J2EE moved under Eclipse EE4J project. + * + * [Annotations](https://github.com/eclipse-ee4j/common-annotations-api) + */ + object Annotations : CatalogEntry() { + override val version = "1.3.2" + override val module = "javax.annotation:javax.annotation-api" + } + + object ServletApi : CatalogEntry() { + override val version = "3.1.0" + override val module = "javax.servlet:javax.servlet-api" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Klaxon.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Klaxon.kt similarity index 83% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Klaxon.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Klaxon.kt index 160fdbfbe..a856a4c49 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Klaxon.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Klaxon.kt @@ -24,14 +24,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** - * A JSON parser in Kotlin + * A JSON parser in Kotlin. * * [Klaxon](https://github.com/cbeust/klaxon) */ -object Klaxon { - private const val version = "5.6" - const val lib = "com.beust:klaxon:${version}" +@Suppress("unused") +internal object Klaxon : CatalogEntry() { + override val version = "5.6" + override val module = "com.beust:klaxon" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/GoogleCloud.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Kotlin.kt similarity index 68% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/GoogleCloud.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Kotlin.kt index a764af274..1814134df 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/GoogleCloud.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Kotlin.kt @@ -24,20 +24,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -@Suppress("unused") -object GoogleCloud { +import io.spine.internal.catalog.model.CatalogEntry - // https://github.com/googleapis/java-core - const val core = "com.google.cloud:google-cloud-core:2.3.3" +/** + * [Kotlin](https://github.com/JetBrains/kotlin) + */ +@Suppress("unused") +internal object Kotlin : CatalogEntry() { - // 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" + private const val group = "org.jetbrains.kotlin" + override val version = "1.6.21" - // https://github.com/googleapis/java-trace - const val trace = "com.google.cloud:google-cloud-trace:2.1.0" + val gradlePlugin by lib("$group:kotlin-gradle-plugin") + val reflect by lib("$group:kotlin-reflect") - // https://github.com/googleapis/java-datastore - const val datastore = "com.google.cloud:google-cloud-datastore:2.2.1" + object StdLib : CatalogEntry() { + override val module = "$group:kotlin-stdlib" + val common by lib("$group:kotlin-stdlib-common") + val jdk8 by lib("$group:kotlin-stdlib-jdk8") + } } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/KotlinSemver.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/KotlinSemver.kt similarity index 80% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/KotlinSemver.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/KotlinSemver.kt index 47fd7de41..1110e8cc4 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/KotlinSemver.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/KotlinSemver.kt @@ -24,11 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://github.com/z4kn4fein/kotlin-semver +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [KotlinSemver](https://github.com/z4kn4fein/kotlin-semver) + */ @Suppress("unused") -object KotlinSemver { - private const val version = "1.2.1" - const val lib = "io.github.z4kn4fein:semver:$version" +internal object KotlinSemver : CatalogEntry() { + override val version = "1.2.1" + override val module = "io.github.z4kn4fein:semver" } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/KotlinX.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/KotlinX.kt new file mode 100644 index 000000000..9e808dbf2 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/KotlinX.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +@Suppress("unused") +internal object KotlinX : CatalogEntry() { + + object Coroutines : CatalogEntry() { + + /** + * [KotlinX.Coroutines](https://github.com/Kotlin/kotlinx.coroutines) + */ + override val version = "1.6.1" + + object Core : CatalogEntry() { + override val module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" + val jvm by lib("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm") + } + } +} diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/LicenseReport.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/LicenseReport.kt new file mode 100644 index 000000000..f9d5124ce --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/LicenseReport.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [LicenseReport](https://github.com/jk1/Gradle-License-Report) + */ +@Suppress("unused") +internal object LicenseReport : CatalogEntry() { + + override val version = "1.16" + override val module = "com.github.jk1:gradle-license-report" + + object GradlePlugin : CatalogEntry() { + override val module = "com.github.jk1:gradle-license-report" + override val id = "com.github.jk1.dependency-license-report" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Netty.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Netty.kt similarity index 71% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Netty.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Netty.kt index dfcd80ef0..31cd00ff6 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Netty.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Netty.kt @@ -24,15 +24,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry @Suppress("unused") -object Netty { - // https://github.com/netty/netty/releases - private const val version = "4.1.72.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}" +internal object Netty : CatalogEntry() { + + /** + * [Releases](https://github.com/netty/netty/releases) + */ + override val version = "4.1.72.Final" + + val common by lib("io.netty:netty-common") + val buffer by lib("io.netty:netty-buffer") + val transport by lib("io.netty:netty-transport") + val handler by lib("io.netty:netty-handler") + val codecHttp by lib("io.netty:netty-codec-http") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Okio.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Okio.kt similarity index 82% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Okio.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Okio.kt index 4ad91c6fd..a35b6c676 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Okio.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Okio.kt @@ -24,14 +24,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * Okio is a transitive dependency which we don't use directly. - * We `force` it in [DependencyResolution.forceConfiguration]. + * This object is used to force the version. */ -object Okio { +@Suppress("unused") +internal object Okio : CatalogEntry() { // This is the last version before next major. - private const val version = "1.17.5" - const val lib = "com.squareup.okio:okio:${version}" + override val version = "1.17.5" + override val module = "com.squareup.okio:okio" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/OsDetector.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/OsDetector.kt similarity index 76% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/OsDetector.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/OsDetector.kt index 7f4bb16b8..c88864472 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/OsDetector.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/OsDetector.kt @@ -24,12 +24,16 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -object OsDetector { - // https://github.com/google/osdetector-gradle-plugin - const val version = "1.7.0" - const val id = "com.google.osdetector" - const val lib = "com.google.gradle:osdetector-gradle-plugin:${version}" - const val classpath = lib +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [OsDetector](https://github.com/google/osdetector-gradle-plugin) + */ +@Suppress("unused") +internal object OsDetector : CatalogEntry() { + override val version = "1.7.0" + override val module = "com.google.gradle:osdetector-gradle-plugin" + override val id = "com.google.osdetector" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Plexus.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Plexus.kt similarity index 82% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Plexus.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Plexus.kt index 27d27206a..6a8deccf3 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Plexus.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Plexus.kt @@ -24,15 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * Plexus Utils is a transitive dependency which we don't use directly. - * We `force` it in [DependencyResolution.forceConfiguration]. + * This object is used to force the version. * * [Plexus Utils](https://codehaus-plexus.github.io/plexus-utils/) */ -object Plexus { - private const val version = "3.4.0" - const val utils = "org.codehaus.plexus:plexus-utils:${version}" +@Suppress("unused") +internal object Plexus : CatalogEntry() { + override val version = "3.4.0" + val utils by lib("org.codehaus.plexus:plexus-utils") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Pmd.kt similarity index 84% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Pmd.kt index badd77174..98584b5b9 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Pmd.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Pmd.kt @@ -24,10 +24,14 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://pmd.github.io/ -@Suppress("unused") // Will be used when `config/gradle/pmd.gradle` migrates to Kotlin. -object Pmd { - const val version = "6.44.0" +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [Pmd](https://pmd.github.io/) + */ +@Suppress("unused") +internal object Pmd : CatalogEntry() { + override val version = "6.44.0" } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Protobuf.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Protobuf.kt new file mode 100644 index 000000000..cae64e348 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Protobuf.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [Protobuf](https://github.com/protocolbuffers/protobuf) + */ +@Suppress("unused") +internal object Protobuf : CatalogEntry() { + + private const val group = "com.google.protobuf" + override val version = "3.20.1" + override val bundle = setOf( + lib("java", "$group:protobuf-java"), + lib("javaUtil", "$group:protobuf-java-util"), + lib("kotlin", "$group:protobuf-kotlin"), + ) + + val compiler by lib("$group:protoc") + + /** + * [GradlePlugin](https://github.com/google/protobuf-gradle-plugin/releases) + */ + object GradlePlugin : CatalogEntry() { + override val version = "0.8.18" + override val module = "$group:protobuf-gradle-plugin" + override val id = "com.google.protobuf" + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Roaster.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Roaster.kt similarity index 78% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Roaster.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Roaster.kt index 2d2370602..ae9d3528e 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Roaster.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Roaster.kt @@ -24,21 +24,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -// https://github.com/forge/roaster +import io.spine.internal.catalog.model.CatalogEntry + +/** + * [Roaster](https://github.com/forge/roaster) + */ @Suppress("unused") -object Roaster { +internal object Roaster : CatalogEntry() { /** * Do not advance this version further because it would break compatibility with Java 8 - * projects. Starting from the following version Roaster has a shaded version of Eclipse JFace - * built with Java 11. + * projects. Starting from the following version Roaster has a shaded version of Eclipse + * JFace built with Java 11. * * Please see [this issue][https://github.com/SpineEventEngine/config/issues/220] for details. */ - private const val version = "2.24.0.Final" + override val version = "2.24.0.Final" - const val api = "org.jboss.forge.roaster:roaster-api:${version}" - const val jdt = "org.jboss.forge.roaster:roaster-jdt:${version}" + val api by lib("org.jboss.forge.roaster:roaster-api") + val jdt by lib("org.jboss.forge.roaster:roaster-jdt") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Slf4J.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Slf4J.kt similarity index 75% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Slf4J.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Slf4J.kt index 4cfa04946..fa40aafaf 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Slf4J.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Slf4J.kt @@ -24,18 +24,25 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** - * Spine used to log with SLF4J. Now we use Flogger. Whenever a choice comes up, we recommend to - * use the latter. + * Spine used to log with SLF4J. Now we use Flogger. Whenever a choice comes up, + * we recommend to use the latter. * - * Some third-party libraries may clash with different versions of the library. Thus, we specify - * this version and force it via [forceConfiguration(..)][DependencyResolution.forceConfiguration]. + * Some third-party libraries may clash with different versions of the library. + * Thus, we have to force the version. */ -@Deprecated("Use Flogger over SLF4J.", replaceWith = ReplaceWith("flogger")) -object Slf4J { - private const val version = "1.7.30" - const val lib = "org.slf4j:slf4j-api:${version}" - const val jdk14 = "org.slf4j:slf4j-jdk14:${version}" +@Suppress("unused") +@Deprecated("Use Flogger over SLF4J.", replaceWith = ReplaceWith("Flogger")) +internal object Slf4J : CatalogEntry() { + + private const val group = "org.slf4j" + override val version = "1.7.30" + override val module = "$group:slf4j-api" + + val jdk14 by lib("$group:slf4j-jdk14") + val api by lib("$group:slf4j-api") } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/TestKitTruth.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/TestKitTruth.kt similarity index 73% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/TestKitTruth.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/TestKitTruth.kt index 8d572d9b2..cd9e6fd39 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/TestKitTruth.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/TestKitTruth.kt @@ -24,19 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry /** * Gradle TestKit extension for Google Truth. * - * Source code: - * https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/tree/main/testkit-truth - * - * Usage description: - * https://dev.to/autonomousapps/gradle-all-the-way-down-testing-your-gradle-plugin-with-gradle-testkit-2hmc + * [Source Code](https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin/tree/main/testkit-truth) + * [Usage description](https://dev.to/autonomousapps/gradle-all-the-way-down-testing-your-gradle-plugin-with-gradle-testkit-2hmc) */ @Suppress("unused") -object TestKitTruth { - private const val version = "1.1" - const val lib = "com.autonomousapps:testkit-truth:$version" +internal object TestKitTruth : CatalogEntry() { + override val version = "1.1" + override val module = "com.autonomousapps:testkit-truth" } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaX.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Truth.kt similarity index 72% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaX.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Truth.kt index 9fb7bd594..18b5e85b1 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/JavaX.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/entry/Truth.kt @@ -24,13 +24,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.entry -@Suppress("unused") -object JavaX { - // This artifact which used to be a part of J2EE moved under Eclipse EE4J project. - // https://github.com/eclipse-ee4j/common-annotations-api - const val annotations = "javax.annotation:javax.annotation-api:1.3.2" +import io.spine.internal.catalog.model.CatalogEntry - const val servletApi = "javax.servlet:javax.servlet-api:3.1.0" +/** + * [Truth](https://github.com/google/truth) + */ +@Suppress("unused") +internal object Truth : CatalogEntry() { + override val version = "1.1.3" + override val module = "com.google.truth:truth" + override val bundle = setOf( + this, + lib("java8Extension", "com.google.truth.extensions:truth-java8-extension"), + lib("protoExtension", "com.google.truth.extensions:truth-proto-extension"), + ) } diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/Alias.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/Alias.kt new file mode 100644 index 000000000..02ea2cffb --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/Alias.kt @@ -0,0 +1,117 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.model + +/** + * A name, by which an item is known in a version catalog. + * + * It consists of one or more camel cased words separated by a hyphen. + * + * For example: `kotlinX-coroutines-gradlePlugin`. + * + * ### Role of aliases in the catalog + * + * Aliases perform two functions: + * + * 1. Navigation. By an alias, one can locate and access an item in the catalog. + * 2. Referencing. One item in a version catalog can use another item, and this + * linkage is done via aliases. + * + * A version catalog itself consists of four sections: versions, libraries, plugins + * and bundles (sets of libraries). Thus, an alias can point to a version, library, + * plugin or bundle. Within each section, an alias should be unique. + * + * ### Mapping to the generated accessors + * + * Below is an example of how aliases are mapped to the generated type-safe + * accessors of the catalog. + * + * Let's suppose, a catalog is named `libs` and each alias denotes a library: + * + * ``` + * "kotlinX-coroutines" => libs.kotlinX.coroutines + * "kotlinX-coroutines-gradlePlugin" => libs.kotlinX.coroutines.gradlePlugin + * "kotlinX-runtime-jvm" => libs.kotlinX.runtime.jvm + * "kotlinX-runtime-clr" => libs.kotlinX.runtime.clr + * ``` + * + * Depending on which type of item an alias points to, the resulting accessor + * may have additional prefixes. + * + * Below are accessor patterns for different types of items: + * + * 1. Library: `{catalog name}.{alias}`. + * 2. Version: `{catalog name}.versions.{alias}`. + * 3. Plugin : `{catalog name}.plugins.{alias}`. + * 4. Bundle : `{catalog name}.bundles.{alias}`. + */ +@JvmInline +value class Alias private constructor(val value: String) { + + companion object { + + /** + * Gradle's recommended separator for sub-aliases. + */ + private const val SEPARATOR = "-" + + /** + * Composes an alias for the given entry. + * + * For a top-level entry it's just a camel-cased entry's name. + * + * For a nested entry, it's a parent alias plus camel-cased entry's name. + */ + fun forEntry(entry: CatalogEntry): Alias { + val className = entry.javaClass.simpleName.replaceFirstChar { it.lowercaseChar() } + val outerEntry = entry.outerEntry + val result = if (outerEntry != null) outerEntry.alias + className else Alias(className) + return result + } + } + + /** + * Returns a copy of this [Alias] with the given suffix appended. + */ + operator fun plus(suffix: String): Alias { + val newValue = value + SEPARATOR + suffix + val result = Alias(newValue) + return result + } + + /** + * If this [Alias] ends with the given [suffix], returns a copy of this alias + * with the suffix removed. + * + * Otherwise, returns this alias. + */ + operator fun minus(suffix: String): Alias { + val newValue = value.removeSuffix(SEPARATOR + suffix) + val result = if (newValue == value) this else Alias(newValue) + return result + } +} diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/CatalogEntry.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/CatalogEntry.kt new file mode 100644 index 000000000..a31492245 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/CatalogEntry.kt @@ -0,0 +1,486 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.model + +/** + * Declaration of a dependency, which is going to become a part of a version catalog. + * + * The main idea behind the concept of entries is to provide a declarative way + * to define catalog items: versions, libraries, plugins and bundles. Entries expose + * a declarative API, leaving behind the scene all imperative code. + * + * Out of declarations, which are done within an entry, it [produces][allRecords] + * a set of [CatalogRecord]s. Once produced, the records can be directly [written][CatalogRecord.writeTo] + * into a version catalog. The relationship between an entry and records it produces + * is "one to many". It means that a single entry can produce zero, one or more records. + * + * # Usage + * + * Please note, only object declarations are meant to inherit from this class + * and serve as concrete entries. + * + * For example: + * + * ``` + * internal object MyLib : CatalogEntry() { + * // ... + * } + * ``` + * + * ## Nesting + * + * One entry can be put into another one. When an entry is [asked][allRecords] + * for records, it will propagate the request down to its nested entries. + * Thus, only root entries should be used to produce records. + * + * ## Aliasing + * + * Each item in a version catalog should have [Alias]. An entry sets aliases on + * its own for items, declared within it. Automatic aliasing takes into account + * entry's nesting. + * + * One can declare an entry, which only hosts other entries. Thus, providing + * a named scope for other declarations. + * + * Consider the following example: + * + * ``` + * internal object Runtime : CatalogEntry() { // alias = "runtime" + * object Linux : CatalogEntry() // alias = "runtime-linux" + * object Mac : CatalogEntry() // alias = "runtime-mac" + * object Win : CatalogEntry() // alias = "runtime-win" + * } + * ``` + * + * See documentation to [Alias] to see how a type-safe accessor is generated + * from an alias. + * + * ## Declaring versions + * + * An entry which declares only a bare version is a quite rare case. Such entries + * can be used to declare a version of used tools. + * + * An example of how to declare a bare version: + * + * ``` + * internal object MyTool : CatalogEntry() { + * override val version = "1.0.0" + * } + * ``` + * + * ## Declaring libraries + * + * The most common case is a declaring a library. Most entries just declare a + * single library. + * + * An example of how to declare a library: + * + * ``` + * internal object MyLib : CatalogEntry() { + * override val version = "1.0.0" + * override val module = "com.company:my-lib" + * } + * ``` + * + * Sometimes, a dependency consists of several libraries. Or even of a group + * of libraries. A group can be extracted into a nested entry, and extra libraries + * can be declared by a [delegated property][lib]. + * + * For example: + * + * ``` + * internal object MyLib : CatalogEntry() { + * private const val group = "com.company" + * override val version = "1.9.0" + * override val module = "$group:my-lib" + * + * val runner by lib("$group:my-runner") + * val linter by lib("$group:my-linter") + * + * object Adapters : CatalogEntry() { + * val html4 by lib("$group:html4-adapter") + * val html5 by lib("$group:html5-adapter") + * } + * } + * ``` + * + * Please note, that nested `Adapters` entry doesn't declare a version. In cases, + * when a version is not declared, an entry will try to fetch it from the closest + * parental entry, which has one. If the version is needed, but isn't found, + * an entry will throw an exception. + * + * ## Declaring plugins + * + * The minimum, required to declare a plugin is a [version] and [id]. + * + * For example: + * + * ``` + * internal object MyPlugin : CatalogEntry() { + * override val version = "1.0.0" + * override val id = "com.company.plugin" + * } + * ``` + * + * A standalone plugin is also a quite rare case. Usually, they are declared + * within more complex entries, which represent frameworks or big libraries. + * A plugin can also be supplemented with a library, that makes possible applying + * it from `buildSrc`. + * + * For example: + * + * ``` + * internal object MyLib : CatalogEntry() { + * private const val group = "com.company" + * // ... + * + * object GradlePlugin : CatalogEntry() { + * override val version = "1.2.3" // libs.versions.myLib.gradlePlugin + * override val module = "$group:my-plugin" // libs.myLib.gradlePlugin + * override val id = "$group.plugin" // libs.plugins.myLib (without `gradlePlugin`!) + * } + * } + * ``` + * + * In the example above, comments show the resulted generated accessors. Please note, + * that `GradlePlugin` is a special name for entries. Such an entry will not append + * `gradlePlugin` suffix for [id] item. It is done in order not to repeat yourself + * in naming. Otherwise, we would come up with this: `libs.plugins.myLib.gradlePlugin`. + * + * ## Declaring bundles + * + * A bundle is a named set of libraries. One can compose a bundle out of already + * declared extra libraries, in-place library declarations or entries, which + * declare a library. + * + * For example: + * + * ``` + * internal object MyLib : CatalogEntry() { + * private const val group = "com.company" + * override val version = "1.9.0" + * override val module = "$group:my-lib" + * + * object Adapters : CatalogEntry() { + * val html4 by lib("$group:html4-adapter") + * val html5 by lib("$group:html5-adapter") + * } + * + * object Runner : CatalogEntry() { + * override val version = "18.51.0" + * override val module = "$group:runner" + * } + * + * override val bundle = setOf( + * + * // Entries, which declare `module`. + * this, Runner, + * + * // Extra libraries, declared by `lib` delegate. + * Adapters.html4, + * Adapters.html5, + * + * // In-place declarations. + * lib("linter", "$group:linter"), + * lib("core", "$group:core"), + * ) + * } + * ``` + * + * There's also a possibility to declare extra bundles on top of the current entry. + * Just like with extra libraries, using a [property delegate][bundle]. + * + * For example: + * + * ``` + * internal object MyLib : CatalogEntry() { + * private const val group = "com.company" + * override val version = "1.9.0" + * override val module = "$group:my-lib" + * + * object Adapters : CatalogEntry() { + * val html4 by lib("$group:html4-adapter") + * val html5 by lib("$group:html5-adapter") + * } + * + * val adapters by bundle( + * Adapters.html4, + * Adapters.html5, + * ) + * } + * ``` + */ +abstract class CatalogEntry { + + private val extraLibs = mutableSetOf() + private val extraBundles = mutableSetOf() + private val versionRecord: VersionRecord by lazy { versionRecord() } + + /** + * A direct parent of this entry, if any. + */ + internal val outerEntry: CatalogEntry? = outerEntry() + + /** + * An alias of this entry. + * + * All items, declared within this entry, will receive this alias. + * + * [Extra libraries][lib] and [bundles][bundle], declared on top of this + * entry, will also use this alias as a base for their own aliases. + */ + @Suppress("LeakingThis") // `Alias.forEntry()` uses only final properties. + internal val alias: Alias = Alias.forEntry(this) + + /** + * Optionally, this entry can declare a version. + * + * In order to do that, override this property, specifying a string + * representation of a version. + * + * For example: `2.0.0-SNAPSHOT.21`. + * + * A declared version will inherit entry's [alias]. + */ + open val version: String? = null + + /** + * Optionally, this entry can declare a library. + * + * In order to do that, override this property, specifying a group and + * artifact of a library, seperated by a colon. + * + * For example: `io.spine:spine-core`. + * + * A declared library will inherit entry's [alias]. + * + * When declaring [module], make sure that this entry or any parental one + * declares [version]. A library can't be declared without version. + */ + open val module: String? = null + + /** + * Optionally, this entry can declare a plugin. + * + * In order to do that, override this property, specifying a plugin id. + * + * For example: `org.jetbrains.kotlin.jvm`. + * + * A declared plugin will inherit entry's [alias]. + * + * When declaring [id], make sure that this entry or any parental one + * declares [version]. A plugin can't be declared without version. + */ + open val id: String? = null + + /** + * Optionally, this entry can declare a bundle (named set of libraries). + * + * In order to do that, override this property, specifying a set of libraries. + * + * The following declarations are acceptable to be passed into this set: + * + * 1. [CatalogEntry]s which declare [module]. + * 2. Extra libraries, declared by a [delegated property][lib]. + * 3. Extra libraries, declared by a [method][lib] right in this set. + * + * An example snippet is present in `Declaring bundles` section of + * documentation to [CatalogEntry]. + * + * A declared bundle will inherit entry's [alias]. + */ + open val bundle: Set? = null + + /** + * Declares an extra library on top of this entry, using property delegation. + * + * An example usage: + * + * ``` + * val core by lib("my.company:core-lib") + * ``` + * + * The resulting alias fot this library is entry's [alias] followed by + * a property name. + */ + fun lib(module: String): MemoizingDelegate = + delegate { property -> lib(property.name, module) } + + /** + * Declares an extra library on top of this entry. + * + * This method allows declaring libraries right in bundle declarations: + * + * ``` + * val bundle = setOf( + * lib("core", "my.company:core-lib"), + * lib("types", "my.company:types-lib"), + * lib("lang", "my.company:lang-lib") + * ) + * ``` + * + * The resulting alias fot this library is entry's [alias] followed by + * the given name. + */ + fun lib(name: String, module: String): CatalogRecord { + val libAlias = alias + name + val record = LibraryRecord(libAlias, module, versionRecord) + return record.also { extraLibs.add(it) } + } + + /** + * Declares an extra bundle on top of this entry, using property delegation. + * + * The following declarations are acceptable to be passed into this set: + * + * 1. [CatalogEntry]s which declare [module]. + * 2. Extra libraries, declared by a [delegated property][lib]. + * 3. Extra libraries, declared by a [method][lib] right in this set. + * + * An example snippet is present in `Declaring bundles` section of + * documentation to [CatalogEntry]. + * + * The resulting alias fot this library is entry's [alias] followed by + * a property name. + */ + fun bundle(vararg libs: Any): MemoizingDelegate = + delegate { property -> + val bundleAlias = alias + property.name + val libRecords = libs.asIterable().toLibraryRecords() + val record = BundleRecord(bundleAlias, libRecords) + record.also { extraBundles.add(it) } + } + + /** + * Produces [CatalogRecord]s out of declarations, performed within this + * entry and its nested entries. + * + * When an entry is asked for records, it will propagate the request down + * to its nested entries. For this reason, this method should be called only + * on top-level (root) entries. + * + * Calling of this method on a nested entry leads to an exception. + */ + fun allRecords(): Set { + + if (outerEntry != null) { + throw IllegalStateException("Only root entries can produce records!") + } + + val allRecords = records() + return allRecords + } + + private fun records(): Set { + val fromThisEntry = recordsFromThisEntry() + val fromNested = recordsFromNested() + val result = fromThisEntry + fromNested + return result + } + + private fun recordsFromThisEntry(): Set { + val result = mutableSetOf() + + if (version != null) { + val record = VersionRecord(alias, version!!) + result.add(record) + } + + if (module != null) { + val record = LibraryRecord(alias, module!!, versionRecord) + result.add(record) + } + + if (id != null) { + val pluginAlias = alias - "gradlePlugin" + val record = PluginRecord(pluginAlias, id!!, versionRecord) + result.add(record) + } + + if (bundle != null) { + val libs = bundle!!.toLibraryRecords() + val record = BundleRecord(alias, libs) + result.add(record) + } + + extraLibs.forEach { result.add(it) } + extraBundles.forEach { result.add(it) } + + return result + } + + private fun recordsFromNested(): Set { + val result = mutableSetOf() + val nestedEntries = nestedEntries() + val fromNested = nestedEntries.flatMap { it.records() } + result.addAll(fromNested) + return result + } + + private fun nestedEntries(): Set { + val nestedClasses = this::class.nestedClasses + val nestedObjects = nestedClasses.mapNotNull { it.objectInstance } + val nestedEntries = nestedObjects.filterIsInstance() + return nestedEntries.toSet() + } + + private fun outerEntry(): CatalogEntry? { + val enclosingClass = this::class.java.enclosingClass + val enclosingInstance = enclosingClass?.kotlin?.objectInstance + + if (enclosingInstance !is CatalogEntry?) { + throw IllegalStateException("Plain objects can't nest entries!") + } + + return enclosingInstance + } + + private fun versionRecord(): VersionRecord = when { + version != null -> VersionRecord(alias, version!!) + outerEntry != null -> outerEntry.versionRecord + else -> throw IllegalStateException("Specify version in this entry or any parental one!") + } + + private fun Iterable.toLibraryRecords(): Set { + val result = map { it.toLibraryRecord() }.toSet() + return result + } + + private fun Any.toLibraryRecord(): LibraryRecord { + if (this is LibraryRecord) { + return this + } + + if (this is CatalogEntry) { + val entry = this + val record = LibraryRecord(entry.alias, entry.module!!, entry.versionRecord) + return record + } + + throw IllegalArgumentException("Unknown object has been passed: $this!") + } +} diff --git a/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/CatalogRecords.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/CatalogRecords.kt new file mode 100644 index 000000000..9c16793a5 --- /dev/null +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/CatalogRecords.kt @@ -0,0 +1,132 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.model + +import org.gradle.api.initialization.dsl.VersionCatalogBuilder + +/** + * An atomic unit, which can be written into a version catalog. + * + * Records strictly reflect the way, the information is stored in the catalog. + * Due to this fact, they don't need any preparations to be written there. + * + * This interface, doesn't represent a concrete catalog item. It serves as a common + * foundation for other records. + * + * All concrete records are internal by design. They are assembled by [CatalogEntry] + * under the hood and not meant to be exposed to end-users. All a user might need + * to do with a record is to write it into the catalog, which can be done with + * this public interface. + */ +interface CatalogRecord { + + /** + * A name, by which this record will be known in the catalog. + * + * See documentation to [Alias] to see how a type-safe accessor is generated + * from an alias. + */ + val alias: Alias + + /** + * Writes this record to the given catalog. + */ + fun writeTo(catalog: VersionCatalogBuilder) +} + +/** + * A version, which can be directly written into a version catalog. + * + * [value] is a string representation of a version. + * + * For example: `2.0.0-SNAPSHOT.21`. + */ +internal data class VersionRecord( + override val alias: Alias, + val value: String +) : CatalogRecord { + + override fun writeTo(catalog: VersionCatalogBuilder) { + catalog.version(alias.value, value) + } +} + +/** + * A library, which can be directly written into a version catalog. + * + * [module] is a group and artifact of a library, seperated by a colon. + * + * For example: `io.spine:spine-core`. + * + * A version of the library is referenced by the given [version record][version]. + */ +internal data class LibraryRecord( + override val alias: Alias, + val module: String, + val version: VersionRecord +) : CatalogRecord { + + override fun writeTo(catalog: VersionCatalogBuilder) { + val group = module.substringBefore(':') + val artifact = module.substringAfter(':') + catalog.library(alias.value, group, artifact).versionRef(version.alias.value) + } +} + +/** + * A plugin, which can be directly written into a version catalog. + * + * [id] is a unique name, by which a plugin is represented in both Gradle Plugin Portal + * and in the project. + * + * For example: `org.jetbrains.kotlin.jvm`. + * + * A version of the plugin is referenced by the given [version record][version]. + */ +internal data class PluginRecord( + override val alias: Alias, + val id: String, + val version: VersionRecord +) : CatalogRecord { + + override fun writeTo(catalog: VersionCatalogBuilder) { + catalog.plugin(alias.value, id).versionRef(version.alias.value) + } +} + +/** + * A named set of libraries, which can be directly written into a version catalog + */ +internal data class BundleRecord( + override val alias: Alias, + val libs: Set +) : CatalogRecord { + + override fun writeTo(catalog: VersionCatalogBuilder) { + catalog.bundle(alias.value, libs.map { it.alias.value }) + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsLogging.kt b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/PropertyDelegates.kt similarity index 57% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsLogging.kt rename to version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/PropertyDelegates.kt index e9d148f14..62cb8bebf 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/CommonsLogging.kt +++ b/version-catalog/catalog/src/main/kotlin/io/spine/internal/catalog/model/PropertyDelegates.kt @@ -24,14 +24,29 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog.model + +import kotlin.properties.PropertyDelegateProvider +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty + +/** + * A property delegate, which returns the same object on each access to the property. + */ +internal typealias MemoizingDelegate = PropertyDelegateProvider> /** - * [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. + * Provides a property delegate, which returns the same object on each access + * to the property. + * + * The object is obtained from the given [action]. The action will be executed + * only once, during a property initializing. Then, the resulted object is memoized + * and returned on each access to the property. */ -object CommonsLogging { - // https://commons.apache.org/proper/commons-logging/ - private const val version = "1.2" - const val lib = "commons-logging:commons-logging:${version}" -} +internal fun delegate(action: (KProperty<*>) -> T): MemoizingDelegate = + PropertyDelegateProvider { _, property -> + val obj = action(property) + memoize(obj) + } + +private fun memoize(obj: T) = ReadOnlyProperty { _, _ -> obj } diff --git a/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/CatalogEntryTest.kt b/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/CatalogEntryTest.kt new file mode 100644 index 000000000..8c940103d --- /dev/null +++ b/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/CatalogEntryTest.kt @@ -0,0 +1,253 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.model + +import com.google.common.truth.Truth.assertThat +import io.spine.internal.catalog.model.given.BundleEntry +import io.spine.internal.catalog.model.given.CatalogEntryTestEnv.Companion.bundleRecord +import io.spine.internal.catalog.model.given.CatalogEntryTestEnv.Companion.libraryRecord +import io.spine.internal.catalog.model.given.CatalogEntryTestEnv.Companion.pluginRecord +import io.spine.internal.catalog.model.given.CatalogEntryTestEnv.Companion.versionRecord +import io.spine.internal.catalog.model.given.DirectInheritingEntry +import io.spine.internal.catalog.model.given.EmptyRootEntry +import io.spine.internal.catalog.model.given.ErroneousLibraryEntry +import io.spine.internal.catalog.model.given.ErroneousPluginEntry +import io.spine.internal.catalog.model.given.ExtraBundleEntry +import io.spine.internal.catalog.model.given.ExtraLibraryEntry +import io.spine.internal.catalog.model.given.IndirectInheritingEntry +import io.spine.internal.catalog.model.given.LibraryEntry +import io.spine.internal.catalog.model.given.OuterEntry +import io.spine.internal.catalog.model.given.WithPluginEntry +import io.spine.internal.catalog.model.given.PluginEntry +import io.spine.internal.catalog.model.given.RootEntry +import io.spine.internal.catalog.model.given.VersionEntry +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Nested +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows + +@DisplayName("`CatalogEntry` should") +internal class CatalogEntryTest { + + @Nested + inner class `when is root` { + + @Nested + inner class `optionally declare` { + + @Test + fun `a version`() { + val entry = VersionEntry + val records = entry.allRecords() + assertThat(records).hasSize(1) + + val record = versionRecord(records) + assertThat(record.alias.value).isEqualTo("versionEntry") + assertThat(record.value).isEqualTo("v0.0.1") + } + + @Test + fun `a library`() { + val entry = LibraryEntry + val records = entry.allRecords() + assertThat(records).hasSize(2) + + val library = libraryRecord(records) + assertThat(library.alias.value).isEqualTo("libraryEntry") + assertThat(library.module).isEqualTo("com.company:lib") + + val version = versionRecord(records) + assertThat(library.version).isEqualTo(version) + } + + @Test + fun `an extra library`() { + val entry = ExtraLibraryEntry + val records = entry.allRecords() + assertThat(records).hasSize(2) + + val library = libraryRecord(records) + assertThat(library.alias.value).isEqualTo("extraLibraryEntry-core") + assertThat(library.module).isEqualTo("com.company:core-lib") + + val version = versionRecord(records) + assertThat(library.version).isEqualTo(version) + } + + @Test + fun `a plugin`() { + val entry = PluginEntry + val records = entry.allRecords() + assertThat(records).hasSize(2) + + val plugin = pluginRecord(records) + assertThat(plugin.alias.value).isEqualTo("pluginEntry") + assertThat(plugin.id).isEqualTo("com.company.plugin") + + val version = versionRecord(records) + assertThat(plugin.version).isEqualTo(version) + } + + @Test + fun `a bundle`() { + val entry = BundleEntry + val records = entry.allRecords() + assertThat(records).hasSize(5) + + val bundle = bundleRecord(records) + assertThat(bundle.alias.value).isEqualTo("bundleEntry") + + val expected = records.filterIsInstance().toSet() + assertThat(expected).hasSize(3) + assertThat(bundle.libs).isEqualTo(expected) + } + + @Test + fun `an extra bundle`() { + val entry = ExtraBundleEntry + val records = entry.allRecords() + assertThat(records).hasSize(5) + + val bundle = bundleRecord(records) + assertThat(bundle.alias.value).isEqualTo("extraBundleEntry-full") + + val expected = records.filterIsInstance().toSet() + assertThat(expected).hasSize(3) + assertThat(bundle.libs).isEqualTo(expected) + } + } + + @Test + fun `produce no records if empty`() { + val entry = EmptyRootEntry + val records = entry.allRecords() + assertThat(records).isEmpty() + } + + @Test + fun `ask nested entries for records`() { + val entry = RootEntry + val records = entry.allRecords() + assertThat(records).hasSize(5) + } + + @Test + fun `use object's name for alias`() { + val entry = RootEntry + val record = entry.allRecords().first() + assertThat(record.alias.value).isEqualTo("rootEntry") + } + } + + @Nested + inner class `when is nested` { + + @Nested + inner class `inherit the version from` { + + @Test + fun `direct parent`() { + val entry = DirectInheritingEntry + val records = entry.allRecords() + assertThat(records).hasSize(2) + + val library = libraryRecord(records) + assertThat(library.alias.value).isEqualTo("directInheritingEntry-inheritor") + assertThat(library.module).isEqualTo("com.company:lib") + + val version = versionRecord(records) + assertThat(library.version).isEqualTo(version) + } + + @Test + fun `indirect parent`() { + val entry = IndirectInheritingEntry + val records = entry.allRecords() + assertThat(records).hasSize(2) + + val library = libraryRecord(records) + assertThat(library.alias.value).isEqualTo("indirectInheritingEntry-separator-inheritor") + assertThat(library.module).isEqualTo("com.company:lib") + + val version = versionRecord(records) + assertThat(library.version).isEqualTo(version) + } + } + + @Nested + inner class `throw an exception if the version is needed, but not declared for` { + + @Test + fun `a library`() { + val entry = ErroneousLibraryEntry + assertThrows { entry.allRecords() } + } + + @Test + fun `a plugin`() { + val entry = ErroneousPluginEntry + assertThrows { entry.allRecords() } + } + } + + @Test + fun `not append 'GradlePlugin' suffix for plugins`() { + val entry = WithPluginEntry + val records = entry.allRecords() + assertThat(records).hasSize(2) + + val plugin = pluginRecord(records) + assertThat(plugin.alias.value).isEqualTo("withPluginEntry") + assertThat(plugin.id).isEqualTo("my.plugin") + + val version = versionRecord(records) + assertThat(plugin.version).isEqualTo(version) + assertThat(version.alias.value).isEqualTo("withPluginEntry-gradlePlugin") + } + + @Test + fun `reflect nesting in alias`() { + val entry = RootEntry + val records = entry.allRecords() + val aliases = records.map { it.alias.value } + val expected = listOf( + "rootEntry", + "rootEntry-firstChild", + "rootEntry-secondChild", + "rootEntry-thirdChild", + "rootEntry-thirdChild-grandChild", + ) + assertThat(aliases).isEqualTo(expected) + } + + @Test + fun `throw an exception on request to produce records`() { + val entry = OuterEntry.Nested + assertThrows { entry.allRecords() } + } + } +} diff --git a/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/given/CatalogEntries.kt b/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/given/CatalogEntries.kt new file mode 100644 index 000000000..d42b97063 --- /dev/null +++ b/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/given/CatalogEntries.kt @@ -0,0 +1,150 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.model.given + +import io.spine.internal.catalog.model.CatalogEntry + +internal object VersionEntry : CatalogEntry() { + override val version = "v0.0.1" +} + +internal object LibraryEntry : CatalogEntry() { + override val version = "l0.0.1" + override val module = "com.company:lib" +} + +internal object ExtraLibraryEntry : CatalogEntry() { + override val version = "el0.0.1" + + @Suppress("unused") + val core by lib("com.company:core-lib") +} + +internal object PluginEntry : CatalogEntry() { + override val version = "p0.0.1" + override val id = "com.company.plugin" +} + +@Suppress("MemberVisibilityCanBePrivate") +internal object BundleEntry : CatalogEntry() { + override val version = "b0.0.1" + override val module = "com.company:lib" + val core by lib("com.company:core-lib") + override val bundle = setOf( + this, + core, + lib("runner", "com.company:runner-lib") + ) +} + +@Suppress("MemberVisibilityCanBePrivate") +internal object ExtraBundleEntry : CatalogEntry() { + override val version = "b0.0.1" + override val module = "com.company:lib" + + val core by lib("com.company:core-lib") + + @Suppress("unused") + val full by bundle( + this, + core, + lib("runner", "com.company:runner-lib") + ) +} + +internal object EmptyRootEntry : CatalogEntry() + +internal object RootEntry : CatalogEntry() { + + override val version = "re0.0.0" + + @Suppress("unused") + object FirstChild : CatalogEntry() { + override val version = "fc0.0.0" + } + + @Suppress("unused") + object SecondChild : CatalogEntry() { + override val version = "sc0.0.0" + } + + @Suppress("unused") + object ThirdChild : CatalogEntry() { + + override val version = "tc0.0.0" + + object GrandChild : CatalogEntry() { + override val version = "gc0.0.0" + } + } +} + +internal object DirectInheritingEntry : CatalogEntry() { + override val version = "dvi0.0.1" + + @Suppress("unused") + object Inheritor : CatalogEntry() { + override val module = "com.company:lib" + } +} + +internal object IndirectInheritingEntry : CatalogEntry() { + override val version = "ivi0.0.1" + + @Suppress("unused") + object Separator : CatalogEntry() { + object Inheritor : CatalogEntry() { + override val module = "com.company:lib" + } + } +} + +internal object ErroneousLibraryEntry : CatalogEntry() { + @Suppress("unused") + object Nested : CatalogEntry() { + override val module = "com.company:lib" + } +} + +internal object ErroneousPluginEntry : CatalogEntry() { + @Suppress("unused") + object Nested : CatalogEntry() { + override val id = "com.company:lib" + } +} + +internal object WithPluginEntry : CatalogEntry() { + @Suppress("unused") + internal object GradlePlugin : CatalogEntry() { + override val version = "gp0.0.2" + override val id = "my.plugin" + } +} + +internal object OuterEntry : CatalogEntry() { + object Nested : CatalogEntry() +} diff --git a/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/given/CatalogEntryTestEnv.kt b/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/given/CatalogEntryTestEnv.kt new file mode 100644 index 000000000..f48b940a4 --- /dev/null +++ b/version-catalog/catalog/src/test/kotlin/io/spine/internal/catalog/model/given/CatalogEntryTestEnv.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.model.given + +import io.spine.internal.catalog.model.BundleRecord +import io.spine.internal.catalog.model.CatalogRecord +import io.spine.internal.catalog.model.LibraryRecord +import io.spine.internal.catalog.model.PluginRecord +import io.spine.internal.catalog.model.VersionRecord + +internal class CatalogEntryTestEnv { + companion object { + + fun versionRecord(records: Iterable): VersionRecord = typedRecord(records) + + fun libraryRecord(records: Iterable): LibraryRecord = typedRecord(records) + + fun pluginRecord(records: Iterable): PluginRecord = typedRecord(records) + + fun bundleRecord(records: Iterable): BundleRecord = typedRecord(records) + + private inline fun typedRecord(records: Iterable): T = + records.first { it is T } as T + } +} diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoValue.kt b/version-catalog/func-test/build.gradle.kts similarity index 84% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoValue.kt rename to version-catalog/func-test/build.gradle.kts index 5b630bf19..82ec59af9 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoValue.kt +++ b/version-catalog/func-test/build.gradle.kts @@ -24,10 +24,15 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +dependencies { + testImplementation(gradleTestKit()) +} -// https://github.com/google/auto -object AutoValue { - private const val version = "1.9" - const val annotations = "com.google.auto.value:auto-value-annotations:${version}" +tasks { + test { + dependsOn( + ":catalog:test", // Let's force unit tests run first. + ":func-test:dummy-catalog:publishToMavenLocal" + ) + } } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Flogger.kt b/version-catalog/func-test/dummy-catalog/build.gradle.kts similarity index 63% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/Flogger.kt rename to version-catalog/func-test/dummy-catalog/build.gradle.kts index 4332178f9..8125e26f5 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/Flogger.kt +++ b/version-catalog/func-test/dummy-catalog/build.gradle.kts @@ -24,16 +24,31 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +plugins { + `maven-publish` +} + +dependencies { + // Provides declarative API for dependencies. + // It is a facade upon Gradle's provided `VersionCatalogBuilder`. + implementation(project(":catalog")) +} + +publishing { + publications { + create("mavenJava") { + groupId = project.group.toString() + artifactId = "dummy-version-catalog" + version = project.version.toString() + from(components["java"]) + } + } +} -// https://github.com/google/flogger -object Flogger { - internal const val version = "0.7.4" - const val lib = "com.google.flogger:flogger:${version}" - @Suppress("unused") - object Runtime { - const val systemBackend = "com.google.flogger:flogger-system-backend:${version}" - const val log4J = "com.google.flogger:flogger-log4j:${version}" - const val slf4J = "com.google.flogger:slf4j-backend-factory:${version}" +tasks { + // It will be impossible to use this module from Maven local without `:catalog`. + // As this module depends on it. + named("publishToMavenLocal") { + dependsOn(":catalog:publishToMavenLocal") } } diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AppEngine.kt b/version-catalog/func-test/dummy-catalog/src/main/kotlin/io/spine/internal/catalog/DummyVersionCatalog.kt similarity index 76% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/AppEngine.kt rename to version-catalog/func-test/dummy-catalog/src/main/kotlin/io/spine/internal/catalog/DummyVersionCatalog.kt index 0d7fee394..e51c77840 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AppEngine.kt +++ b/version-catalog/func-test/dummy-catalog/src/main/kotlin/io/spine/internal/catalog/DummyVersionCatalog.kt @@ -24,16 +24,18 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +package io.spine.internal.catalog -// https://cloud.google.com/java/docs/reference -@Suppress("unused") -object AppEngine { - private const val version = "1.9.82" - const val sdk = "com.google.appengine:appengine-api-1.0-sdk:${version}" +import io.spine.internal.catalog.entry.Dummy +import org.gradle.api.initialization.dsl.VersionCatalogBuilder - object GradlePlugin { - private const val version = "2.2.0" - const val lib = "com.google.cloud.tools:appengine-gradle-plugin:${version}" +/** + * A version catalog, which is filled by a single [entry][Dummy]. + */ +@Suppress("unused") +class DummyVersionCatalog { + companion object { + fun useIn(catalog: VersionCatalogBuilder) = + Dummy.allRecords().forEach { it.writeTo(catalog) } } } diff --git a/version-catalog/func-test/dummy-catalog/src/main/kotlin/io/spine/internal/catalog/entry/Dummy.kt b/version-catalog/func-test/dummy-catalog/src/main/kotlin/io/spine/internal/catalog/entry/Dummy.kt new file mode 100644 index 000000000..81b1aeea9 --- /dev/null +++ b/version-catalog/func-test/dummy-catalog/src/main/kotlin/io/spine/internal/catalog/entry/Dummy.kt @@ -0,0 +1,100 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog.entry + +import io.spine.internal.catalog.model.CatalogEntry + +/** + * An imaginary dependency. + * + * It is used to showcase API for dependency declaration and perform true + * functional testing. + * + * Side comments to certain statements demonstrate how those lines will + * be represented in the generated type-safe accessors. `libs` is a conventional + * name for version catalogs. + * + * Source code of this dependency is shown in README file of the module. + * Thus, when modifying this dependency, put the updated code to `README.md`. + */ +@Suppress("unused", "MemberVisibilityCanBePrivate") +internal object Dummy : CatalogEntry() { + + private const val group = "org.dummy.company" + override val module = "$group:dummy-lib" // libs.dummy + override val version = "1.0.0" // libs.versions.dummy + + val core by lib("$group:dummy-core") // libs.dummy.core + val runner by lib("$group:dummy-runner") // libs.dummy.runner + val api by lib("$group:dummy-api") // libs.dummy.api + + // In bundles, you can reference entries (which declare module), extra + // libraries, or declare them in-place. + + override val bundle = setOf( // libs.bundles.dummy + this, + core, runner, api, + lib("params", "$group:dummy-params"), // libs.dummy.params + lib("types", "$group:dummy-types"), // libs.dummy.types + ) + + // "GradlePlugin" - is a special entry name. "gradlePlugin" suffix will not + // be put for a final plugin alias. Note, that in an example below, we have + // this suffix for the version and module, and does not have for ID. + + object GradlePlugin : CatalogEntry() { + override val version = "0.0.8" // libs.versions.dummy.gradlePlugin + override val module = "$group:my-dummy-plugin" // libs.dummy.gradlePlugin + override val id = "my-dummy-plugin" // libs.plugins.dummy + } + + object Runtime : CatalogEntry() { + + // When an entry does not override the version, it will try to fetch it + // from the closest parental entry, which has one. For example, in this case, + // all libraries within "Runtime" entry will have version = "1.0.0". + + val win by lib("$group:runtime-win") // libs.dummy.runtime.win + val mac by lib("$group:runtime-mac") // libs.dummy.runtime.mac + val linux by lib("$group:runtime-linux") // libs.dummy.runtime.linux + + object Bom : CatalogEntry() { + override val version = "2.0.0" // libs.versions.dummy.runtime.bom + override val module = "$group:dummy-bom" // libs.dummy.runtime.bom + } + } + + // It's also possible to declare an extra bundle by a property delegate. + // Just like with extra modules. + + val runtime by bundle( // libs.bundles.dummy.runtime + Runtime.Bom, + Runtime.win, + Runtime.mac, + Runtime.linux, + ) +} diff --git a/version-catalog/func-test/dummy-project/build.gradle.kts b/version-catalog/func-test/dummy-project/build.gradle.kts new file mode 100644 index 000000000..0c21e7554 --- /dev/null +++ b/version-catalog/func-test/dummy-project/build.gradle.kts @@ -0,0 +1,94 @@ +/* + * Copyright 2022, 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Redistribution and use in source and/or binary forms, with or without + * modification, must retain the above copyright notice and the following + * disclaimer. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.gradle.api.internal.catalog.ExternalModuleDependencyFactory +import org.gradle.api.internal.catalog.ExternalModuleDependencyFactory.BundleNotationSupplier +import org.gradle.api.internal.catalog.ExternalModuleDependencyFactory.VersionNotationSupplier + +fun assert(actual: ExternalModuleDependencyFactory.DependencyNotationSupplier, expected: String) = + assert(actual.asProvider(), expected) + +fun assert(actual: VersionNotationSupplier, expected: String) = assert(actual.asProvider(), expected) + +fun assert(actual: BundleNotationSupplier, expected: String) = assert(actual.asProvider(), expected) + +fun assert(actual: Provider<*>, expected: String) = assert(actual.get().toString(), expected) + +fun assert(actual: String, expected: String) { + if (actual != expected) { + throw IllegalStateException( + "\nAssertion failed:" + + "\nExpected: $expected" + + "\n Actual: $actual" + ) + } +} + +val group = "org.dummy.company" + +assert(libs.versions.dummy, "1.0.0") +assert(libs.dummy, "$group:dummy-lib:1.0.0") + +with(libs.dummy) { + assert(core, "$group:dummy-core:1.0.0") + assert(runner, "$group:dummy-runner:1.0.0") + assert(api, "$group:dummy-api:1.0.0") + assert(params, "$group:dummy-params:1.0.0") + assert(types, "$group:dummy-types:1.0.0") +} + +assert( + libs.bundles.dummy, "[" + + "$group:dummy-lib:1.0.0, " + + "$group:dummy-core:1.0.0, " + + "$group:dummy-runner:1.0.0, " + + "$group:dummy-api:1.0.0, " + + "$group:dummy-params:1.0.0, " + + "$group:dummy-types:1.0.0" + + "]" +) + +assert(libs.versions.dummy.gradlePlugin, "0.0.8") +assert(libs.dummy.gradlePlugin, "$group:my-dummy-plugin:0.0.8") +assert(libs.plugins.dummy, "my-dummy-plugin:0.0.8") + +assert(libs.versions.dummy.runtime.bom, "2.0.0") +with(libs.dummy.runtime) { + assert(win, "$group:runtime-win:1.0.0") + assert(mac, "$group:runtime-mac:1.0.0") + assert(linux, "$group:runtime-linux:1.0.0") + assert(bom, "$group:dummy-bom:2.0.0") +} + +assert( + libs.bundles.dummy.runtime, + "[" + + "$group:dummy-bom:2.0.0, " + + "$group:runtime-win:1.0.0, " + + "$group:runtime-mac:1.0.0, " + + "$group:runtime-linux:1.0.0" + + "]" +) diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoService.kt b/version-catalog/func-test/dummy-project/settings.gradle.kts similarity index 78% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoService.kt rename to version-catalog/func-test/dummy-project/settings.gradle.kts index 80b79975a..e12830827 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoService.kt +++ b/version-catalog/func-test/dummy-project/settings.gradle.kts @@ -24,12 +24,20 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +import io.spine.internal.catalog.DummyVersionCatalog -// https://github.com/google/auto -object AutoService { - private const val version = "1.0.1" - const val annotations = "com.google.auto.service:auto-service-annotations:${version}" - @Suppress("unused") - const val processor = "com.google.auto.service:auto-service:${version}" +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + classpath("io.spine.internal:dummy-version-catalog:+") + } +} + +dependencyResolutionManagement.versionCatalogs { + create("libs") { + DummyVersionCatalog.useIn(this) + } } diff --git a/version-catalog/func-test/src/test/kotlin/io/spine/internal/catalog/DummyVersionCatalogTest.kt b/version-catalog/func-test/src/test/kotlin/io/spine/internal/catalog/DummyVersionCatalogTest.kt new file mode 100644 index 000000000..462179d1b --- /dev/null +++ b/version-catalog/func-test/src/test/kotlin/io/spine/internal/catalog/DummyVersionCatalogTest.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2022, 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 + * + * http://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.internal.catalog + +import java.nio.file.Paths +import org.gradle.testkit.runner.GradleRunner +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertDoesNotThrow + +/** + * Verifies the generated type-safe accessors for `Dummy` dependency. + * + * `Dummy` is an imaginary dependency, which exists for two reasons: + * + * 1. Showcasing API for dependency declarations. + * 2. Functional testing in conditions, which are very close to real life. + * + * `DummyVersionCatalog` provides a set of actions upon Gradle-provided `VersionCatalogBuilder`. + * These actions fill up the passed catalog with records. And, as for now, there's + * no any other legitimate way, except for a true functional test, to check whether: + * + * 1. Those actions are successfully executed upon a real instance of the builder. + * 2. A resulted catalog, assembled from the builder, contains the expected items. + * + * See issue in Gradle: https://github.com/gradle/gradle/issues/20807 + */ +@DisplayName("`DummyVersionCatalog` should") +class DummyVersionCatalogTest { + + /** + * Triggers a `dummy-project` which uses a `dummy-catalog`. + * + * The project fetches `DummyVersionCatalog` from Maven local. Thus, the catalog + * should be published to Maven local in advance. See README file for details. + * + * A build file of `dummy-project` has assertions upon the generated accessors + * to `Dummy` dependency. When any of assertions fails, the build fails as well, + * making the test not passed. + */ + @Test + fun `fill up an existing version catalog`() { + val dummyProject = Paths.get("dummy-project").toFile() + val runner = GradleRunner.create() + .withProjectDir(dummyProject) + .withArguments("help", "--stacktrace") + + assertDoesNotThrow { + runner.build() + } + } +} diff --git a/version-catalog/gradle/wrapper/gradle-wrapper.jar b/version-catalog/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..41d9927a4 Binary files /dev/null and b/version-catalog/gradle/wrapper/gradle-wrapper.jar differ diff --git a/version-catalog/gradle/wrapper/gradle-wrapper.properties b/version-catalog/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..aa991fcea --- /dev/null +++ b/version-catalog/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/version-catalog/gradlew b/version-catalog/gradlew new file mode 100755 index 000000000..1b6c78733 --- /dev/null +++ b/version-catalog/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# 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 +# +# 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. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/version-catalog/gradlew.bat b/version-catalog/gradlew.bat new file mode 100644 index 000000000..107acd32c --- /dev/null +++ b/version-catalog/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoCommon.kt b/version-catalog/settings.gradle.kts similarity index 86% rename from buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoCommon.kt rename to version-catalog/settings.gradle.kts index 4053ef585..b21bbc4c8 100644 --- a/buildSrc/src/main/kotlin/io/spine/internal/dependency/AutoCommon.kt +++ b/version-catalog/settings.gradle.kts @@ -24,10 +24,10 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package io.spine.internal.dependency +rootProject.name = "spine-version-catalog" -// https://github.com/google/auto -object AutoCommon { - private const val version = "1.2.1" - const val lib = "com.google.auto:auto-common:${version}" -} +include( + "catalog", + "func-test", + "func-test:dummy-catalog", +) diff --git a/version.gradle.kts b/version.gradle.kts deleted file mode 100644 index 832e03902..000000000 --- a/version.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2022, 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 - * - * http://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. - */ - -/** Versions of the Spine libraries that `time` depends on. */ -val mcJavaVersion: String by extra("2.0.0-SNAPSHOT.83") -val spineBaseVersion by extra("2.0.0-SNAPSHOT.91") -val javadocToolsVersion by extra("2.0.0-SNAPSHOT.75") - -/** The version of this library. */ -val versionToPublish by extra("2.0.0-SNAPSHOT.92")