Skip to content

Bump Base, migrate to JSpecify, update config #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
.fleet/

# Kotlin temp directories.
**/.kotlin/**
**/.kotlin/

# IntelliJ IDEA modules and interim config files.
*.iml
Expand Down
3 changes: 2 additions & 1 deletion .idea/dictionaries/common.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import io.spine.dependency.lib.KotlinPoet
import io.spine.dependency.local.Base
import io.spine.dependency.local.BaseTypes
import io.spine.dependency.local.Change
import io.spine.dependency.local.CoreJava
import io.spine.dependency.local.Logging
import io.spine.dependency.local.ProtoData
import io.spine.dependency.local.Reflect
Expand Down Expand Up @@ -251,8 +252,6 @@ fun Subproject.defineDependencies() {
errorprone(core)
}
implementation(Validation.runtime)

testImplementation(JUnit.runner)
testImplementation(TestLib.lib)
}
}
Expand Down Expand Up @@ -345,7 +344,7 @@ fun Subproject.forceConfigurations() {
.configureProtocPlugins()` method which sets the version from resources. */
Grpc.ProtocPlugin.artifact,
Grpc.api,
JUnit.runner,
JUnit.bom,

Coroutines.core,
Coroutines.coreJvm,
Expand All @@ -366,6 +365,7 @@ fun Subproject.forceConfigurations() {
TestLib.lib,
ToolBase.lib,
ToolBase.pluginBase,
CoreJava.server,
ProtoData.api,

Grpc.core,
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repositories {
* Please keep this value in sync with [io.spine.dependency.lib.Jackson.version].
* It is not a requirement but would be good in terms of consistency.
*/
val jacksonVersion = "2.15.3"
val jacksonVersion = "2.18.3"

/**
* The version of Google Artifact Registry used by `buildSrc`.
Expand Down Expand Up @@ -83,7 +83,7 @@ val kotlinVersion = "2.1.20"
* Always use the same version as the one specified in [io.spine.dependency.lib.Guava].
* Otherwise, when testing Gradle plugins, clashes may occur.
*/
val guavaVersion = "32.1.3-jre"
val guavaVersion = "33.4.8-jre"

/**
* The version of ErrorProne Gradle plugin.
Expand All @@ -103,7 +103,7 @@ val errorPronePluginVersion = "4.1.0"
* @see <a href="https://github.com/google/protobuf-gradle-plugin/releases">
* Protobuf Gradle Plugins Releases</a>
*/
val protobufPluginVersion = "0.9.4"
val protobufPluginVersion = "0.9.5"

/**
* The version of Dokka Gradle Plugins.
Expand All @@ -113,7 +113,7 @@ val protobufPluginVersion = "0.9.4"
* @see <a href="https://github.com/Kotlin/dokka/releases">
* Dokka Releases</a>
*/
val dokkaVersion = "1.9.20"
val dokkaVersion = "2.0.0"

/**
* The version of Detekt Gradle Plugin.
Expand All @@ -130,7 +130,7 @@ val kotestJvmPluginVersion = "0.4.10"
/**
* @see [io.spine.dependency.test.Kover]
*/
val koverVersion = "0.7.2"
val koverVersion = "0.9.1"

/**
* The version of the Shadow Plugin.
Expand Down
22 changes: 21 additions & 1 deletion buildSrc/src/main/kotlin/BuildExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.spine.dependency.build.ErrorProne
import io.spine.dependency.build.GradleDoctor
import io.spine.dependency.build.Ksp
import io.spine.dependency.build.PluginPublishPlugin
import io.spine.dependency.lib.Protobuf
import io.spine.dependency.local.McJava
import io.spine.dependency.local.ProtoData
Expand Down Expand Up @@ -150,6 +151,9 @@ val PluginDependenciesSpec.kover: PluginDependencySpec
val PluginDependenciesSpec.ksp: PluginDependencySpec
get() = id(Ksp.id).version(Ksp.version)

val PluginDependenciesSpec.`plugin-publish`: PluginDependencySpec
get() = id(PluginPublishPlugin.id).version(PluginPublishPlugin.version)

/**
* Configures the dependencies between third-party Gradle tasks
* and those defined via ProtoData and Spine Model Compiler.
Expand Down Expand Up @@ -221,13 +225,29 @@ fun Project.configureTaskDependencies() {
}

/**
* Obtains all modules names of which do not have `"-tests"` as the suffix.
* Obtains all modules that do not haveg names ending with the "-tests"` suffix.
*
* By convention, such modules are for integration tests and should be treated differently.
*/
val Project.productionModules: Iterable<Project>
get() = rootProject.subprojects.filter { !it.name.contains("-tests") }

/**
* Obtains the names of the [productionModules].
*
* The extension could be useful for excluding modules from standard publishing:
* ```kotlin
* spinePublishing {
* val customModule = "my-custom-module"
* modules = productionModuleNames.toSet().minus(customModule)
* modulesWithCustomPublishing = setOf(customModule)
* //...
* }
* ```
*/
val Project.productionModuleNames: List<String>
get() = productionModules.map { it.name }

/**
* Sets the remote debug option for this [JavaExec] task.
*
Expand Down
9 changes: 5 additions & 4 deletions buildSrc/src/main/kotlin/DependencyResolution.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024, TeamDev. All rights reserved.
* Copyright 2025, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,6 +29,7 @@ import io.spine.dependency.build.CheckerFramework
import io.spine.dependency.build.Dokka
import io.spine.dependency.build.ErrorProne
import io.spine.dependency.build.FindBugs
import io.spine.dependency.build.JSpecify
import io.spine.dependency.lib.Asm
import io.spine.dependency.lib.AutoCommon
import io.spine.dependency.lib.AutoService
Expand Down Expand Up @@ -97,6 +98,7 @@ private fun ResolutionStrategy.forceProductionDependencies() {
FindBugs.annotations,
Gson.lib,
Guava.lib,
JSpecify.annotations,
Kotlin.reflect,
Kotlin.stdLib,
Kotlin.stdLibCommon,
Expand Down Expand Up @@ -140,13 +142,12 @@ private fun ResolutionStrategy.forceTransitiveDependencies() {
J2ObjC.annotations,
JUnit.Platform.engine,
JUnit.Platform.suiteApi,
JUnit.runner,
Jackson.annotations,
Jackson.bom,
Jackson.core,
Jackson.databind,
Jackson.dataformatXml,
Jackson.dataformatYaml,
Jackson.DataFormat.xml,
Jackson.DataFormat.yaml,
Jackson.moduleKotlin,
JavaDiffUtils.lib,
Kotlin.jetbrainsAnnotations,
Expand Down
58 changes: 58 additions & 0 deletions buildSrc/src/main/kotlin/DocumentationSettings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2025, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Redistribution and use in source and/or binary forms, with or without
* modification, must retain the above copyright notice and the following
* disclaimer.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/**
* The documentation settings specific to this project.
*
* @see <a href="https://kotlinlang.org/docs/dokka-gradle.html#source-link-configuration">
* Dokka source link configuration</a>
*/
@Suppress("ConstPropertyName")
object DocumentationSettings {

/**
* Settings passed to Dokka for
* [sourceLink][[org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceLinkSpec]
*/
object SourceLink {

/**
* The URL of the remote source code
* [location][org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceLinkSpec.remoteUrl].
*/
const val url: String = "https://github.com/SpineEventEngine/base/tree/master/src"

/**
* The suffix used to append the source code line number to the URL.
*
* The suffix depends on the online code repository.
*
* @see <a href="https://kotlinlang.org/docs/dokka-gradle.html#fwor0d_534">
* remoteLineSuffix</a>
*/
const val lineSuffix: String = "#L"
}
}
87 changes: 53 additions & 34 deletions buildSrc/src/main/kotlin/DokkaExts.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024, TeamDev. All rights reserved.
* Copyright 2025, TeamDev. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,13 +36,12 @@ import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.DependencyHandlerScope
import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters

/**
* To generate the documentation as seen from Java perspective, the `kotlin-as-java`
Expand All @@ -69,7 +68,7 @@ fun DependencyHandlerScope.useDokkaWithSpineExtensions() {
private fun DependencyHandler.dokkaPlugin(dependencyNotation: Any): Dependency? =
add("dokkaPlugin", dependencyNotation)

private fun Project.dokkaOutput(language: String): File {
internal fun Project.dokkaOutput(language: String): File {
val lng = language.titleCaseFirstChar()
return layout.buildDirectory.dir("docs/dokka$lng").get().asFile
}
Expand All @@ -93,51 +92,68 @@ fun Project.dokkaConfigFile(file: String): File {
* @see <a href="https://kotlin.github.io/dokka/1.8.10/user_guide/base-specific/frontend/#prerequisites">
* Dokka modifying frontend assets</a>
*/
fun AbstractDokkaTask.configureStyle() {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
customStyleSheets = listOf(project.dokkaConfigFile("styles/custom-styles.css"))
customAssets = listOf(project.dokkaConfigFile("assets/logo-icon.svg"))
separateInheritedMembers = true
footerMessage = "Copyright ${LocalDate.now().year}, TeamDev"
}
fun DokkaHtmlPluginParameters.configureStyle(project: Project) {
customAssets.from(project.dokkaConfigFile("assets/logo-icon.svg"))
customStyleSheets.from(project.dokkaConfigFile("styles/custom-styles.css"))
footerMessage.set("Copyright ${LocalDate.now().year}, TeamDev")
separateInheritedMembers.set(true)
mergeImplicitExpectActualDeclarations.set(false)
}

private fun AbstractDokkaLeafTask.configureFor(language: String) {
dokkaSourceSets.configureEach {
/**
* Configures links to the external Java documentation.
*/
jdkVersion.set(BuildSettings.javaVersion.asInt())
private fun DokkaExtension.configureFor(
project: Project,
language: String,
sourceLinkRemoveUrl: String
) {
dokkaPublications.named("html") {
suppressInheritedMembers.set(true)
failOnWarning.set(true)
}

skipEmptyPackages.set(true)
dokkaSourceSets.named("main") {
val moduleDoc = "Module.md"
if (project.file(moduleDoc).exists()) {
includes.from(moduleDoc)
}

// Please see Dokka docs for more details:
// https://kotlinlang.org/docs/dokka-gradle.html#source-link-configuration
sourceLink {
localDirectory.set(project.file("src/main/${language.lowercase()}"))
remoteUrl(sourceLinkRemoveUrl)
remoteLineSuffix.set(DocumentationSettings.SourceLink.lineSuffix)
}

includeNonPublic.set(true)
// Configures links to the external Java documentation.
jdkVersion.set(BuildSettings.javaVersion.asInt())
skipEmptyPackages.set(true)

documentedVisibilities.set(
setOf(
DokkaConfiguration.Visibility.PUBLIC,
DokkaConfiguration.Visibility.PROTECTED
VisibilityModifier.Public,
VisibilityModifier.Protected
)
)
}

outputDirectory.set(project.dokkaOutput(language))

configureStyle()
pluginsConfiguration.named("html") { this as DokkaHtmlPluginParameters
configureStyle(project)
}
}

/**
* Configures this [DokkaTask] to accept only Kotlin files.
*/
fun AbstractDokkaLeafTask.configureForKotlin() {
configureFor("kotlin")
fun DokkaExtension.configureForKotlin(project: Project, sourceLinkRemoteUrl: String) {
configureFor(project, "kotlin", sourceLinkRemoteUrl)
}

/**
* Configures this [DokkaTask] to accept only Java files.
*/
fun AbstractDokkaLeafTask.configureForJava() {
configureFor("java")
@Suppress("unused")
fun DokkaExtension.configureForJava(project: Project, sourceLinkRemoteUrl: String) {
configureFor(project, "java", sourceLinkRemoteUrl)
}

/**
Expand Down Expand Up @@ -179,14 +195,17 @@ fun Project.dokkaKotlinJar(): TaskProvider<Jar> = tasks.getOrCreate("dokkaKotlin
}

/**
* Tells if this task belongs to the execution graph which contains publishing tasks.
* Tells if this task belongs to the execution graph which contains
* the `publish` and `dokkaGenerate` tasks.
*
* The task `"publishToMavenLocal"` is excluded from the check because it is a part of
* the local testing workflow.
* This predicate could be useful for disabling publishing tasks
* when doing, e.g., `publishToMavenLocal` for the purpose of the
* integration tests that (of course) do not test the documentation
* generation proces and its resuults.
*/
fun AbstractDokkaTask.isInPublishingGraph(): Boolean =
project.gradle.taskGraph.allTasks.any {
it.name == "publish"
it.name == "publish" || it.name.contains("dokkaGenerate")
}

/**
Expand Down
Loading
Loading