Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
51 changes: 32 additions & 19 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 @@ -52,12 +49,10 @@ 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)

val mcJavaVersion: String by extra
val mcJavaVersion = "2.0.0-SNAPSHOT.83"
dependencies {
classpath("io.spine.tools:spine-mc-java:$mcJavaVersion")
}
Expand All @@ -75,8 +70,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 +91,33 @@ 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["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 +132,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 +212,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)
}
14 changes: 7 additions & 7 deletions version.gradle.kts → buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
* 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")
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
Loading