Skip to content
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,7 +52,7 @@ 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)

val mcJavaVersion: String by extra
dependencies {
Expand All @@ -75,8 +72,13 @@ 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

id(libs.plugins.protobuf.get().pluginId)
id(libs.plugins.errorProne.get().pluginId)
}

spinePublishing {
Expand All @@ -91,27 +93,34 @@ spinePublishing {
cloudArtifactRegistry
)
}

dokkaJar {
enabled = true
}
}

allprojects {
apply(from = "$rootDir/version.gradle.kts")

// Due to a bug, we can't apply scripts.
// See: https://github.com/gradle/gradle/issues/20717

/** Versions of the Spine libraries that `time` depends on. */
extra["mcJavaVersion"] = "2.0.0-SNAPSHOT.83"
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")
Expand All @@ -126,19 +135,26 @@ subprojects {

val spineBaseVersion: String by extra
dependencies {
errorprone(ErrorProne.core)
api(kotlin("stdlib-jdk8"))

// 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(rootProject.libs.kotlin.stdLib.jdk8)

testImplementation("io.spine.tools:spine-testlib:$spineBaseVersion")
testImplementation(JUnit.runner)
testImplementation(rootProject.libs.junit.runner)
}

/**
* Force Error Prone dependencies to `2.10.0`, because in `2.11.0` an empty constructor in
* [com.google.errorprone.bugpatterns.CheckReturnValue] was removed leading to breaking the API.
*/
configurations {
forceVersions()
forceVersions(rootProject.libs)
all {
resolutionStrategy {
force(
Expand Down Expand Up @@ -199,7 +215,7 @@ subprojects {
protobuf {
generatedFilesBaseDir = generatedRootDir
protoc {
artifact = Protobuf.compiler
artifact = rootProject.libs.protobuf.compiler.get().toString()
}
generateProtoTasks {
all().forEach { task ->
Expand Down
124 changes: 22 additions & 102 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,126 +24,46 @@
* 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.
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
java
groovy
`kotlin-dsl`
pmd
val licenseReportVersion = "2.1"
id("com.github.jk1.dependency-license-report").version(licenseReportVersion)
}

repositories {
mavenCentral()
mavenLocal()
gradlePluginPortal()
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 <a href="https://github.com/tbroyer/gradle-errorprone-plugin/releases">
* Error Prone Gradle Plugin Releases</a>
*/
val errorProneVersion = "2.0.2"
kotlin {
val jvmVersion = JavaLanguageVersion.of(11)

/**
* The version of Protobuf Gradle Plugin.
*
* Please keep in sync. with [io.spine.internal.dependency.Protobuf.GradlePlugin.version].
*
* @see <a href="https://github.com/google/protobuf-gradle-plugin/releases">
* Protobuf Gradle Plugins Releases</a>
*/
val protobufPluginVersion = "0.8.18"

/**
* The version of Dokka Gradle Plugins.
*
* Please keep in sync with [io.spine.internal.dependency.Dokka.version].
*
* @see <a href="https://github.com/Kotlin/dokka/releases">
* Dokka Releases</a>
*/
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"
)
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(jvmVersion)
}
}

val jvmVersion = JavaLanguageVersion.of(11)

java {
toolchain.languageVersion.set(jvmVersion)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = jvmVersion.toString()
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = jvmVersion.toString()
}
}
}

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")
}
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}")
api(libs.licenseReport)
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.jackson.databind)
implementation(libs.jackson.dataformatXml)
implementation(libs.google.artifactRegistry.authCommon)
implementation(libs.guava)
implementation(libs.grgit)
implementation(libs.errorProne.gradlePlugin)
implementation(libs.kotlin.gradlePlugin)
implementation(libs.protobuf.gradlePlugin)
implementation(libs.dokka.gradlePlugin)
implementation(libs.dokka.basePlugin)
}
33 changes: 33 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*/

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
9 changes: 6 additions & 3 deletions buildSrc/src/main/kotlin/dokka-for-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,31 @@
* 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.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.DokkaTask
import org.gradle.accessors.dm.LibrariesForLibs

plugins {
id("org.jetbrains.dokka")
}

dependencies {

val libs = rootProject.extensions.getByType<LibrariesForLibs>()

/**
* To generate the documentation as seen from Java perspective, the kotlin-as-java plugin was
* added to the Dokka's classpath.
*
* @see <a href="https://github.com/Kotlin/dokka#output-formats">
* Dokka output formats</a>
*/
dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib)
dokkaPlugin(libs.dokka.kotlinAsJava)

/**
* To exclude pieces of code annotated with `@Internal` from the documentation a custom plugin
Expand All @@ -54,7 +57,7 @@ dependencies {
* @see <a href="https://github.com/SpineEventEngine/dokka-tools/tree/master/dokka-extensions">
* Custom Dokka Plugins</a>
*/
dokkaPlugin(Dokka.SpineExtensions.lib)
dokkaPlugin(libs.dokka.spineExtensions)
}

tasks.withType<DokkaTask>().configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ package io.spine.internal.dependency
// See `io.spine.internal.gradle.checkstyle.CheckStyleConfig`.
@Suppress("unused")
object CheckStyle {
// We can't migrate just a version to a TOML file.
const val version = "10.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ package io.spine.internal.dependency
// https://pmd.github.io/
@Suppress("unused") // Will be used when `config/gradle/pmd.gradle` migrates to Kotlin.
object Pmd {
// We can't migrate just a version to a TOML file.
const val version = "6.44.0"
}
Loading