Skip to content

Commit bdfe550

Browse files
Merge pull request #57 from SpineEventEngine/migrate-to-reaction-api
Adopt new documentation build scripts
2 parents 75ae6fc + 7c3764f commit bdfe550

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+819
-1044
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@
77
This repository hosts the plugins to the Spine Compiler that the Core JVM library offers for
88
building a client or a server application.
99

10-
### Environment
10+
## Environment
1111

1212
The modules in this repository are built with Java 17.
1313

14+
For the versions of other dependencies, refer to the Kotlin source code under
15+
[io.spine.dependency](./buildSrc/src/main/kotlin/io/spine/dependency).
16+
17+
## Testing modules in the project structure
18+
19+
### Integration testing
20+
21+
Please refer to [TESTING.md](./TESTING.md).
22+
1423
### Performance testing
1524

1625
This repo includes the `BuildSpeed` submodule with the performance tests for the Spine tools.

base/src/main/kotlin/io/spine/tools/core/jvm/settings/Patterns.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public fun Pattern.matches(type: MessageType): Boolean {
5353
* Tells if this type pattern matches the given type.
5454
*
5555
* @see Pattern.matches
56-
* @see io.spine.protodata.ast.FilePattern.matches
56+
* @see io.spine.tools.compiler.ast.FilePattern.matches
5757
*/
5858
public fun TypePattern.matches(type: MessageType): Boolean {
5959
val qualifiedName = type.qualifiedName

buildSrc/build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ val protobufPluginVersion = "0.9.5"
113113
* @see <a href="https://github.com/Kotlin/dokka/releases">
114114
* Dokka Releases</a>
115115
*/
116-
val dokkaVersion = "2.0.0"
116+
val dokkaVersion = "2.1.0"
117117

118118
/**
119119
* The version of Detekt Gradle Plugin.
@@ -122,6 +122,11 @@ val dokkaVersion = "2.0.0"
122122
*/
123123
val detektVersion = "1.23.8"
124124

125+
/**
126+
* @see [io.spine.dependency.test.Kotest]
127+
*/
128+
val kotestJvmPluginVersion = "0.4.10"
129+
125130
/**
126131
* @see [io.spine.dependency.test.Kover]
127132
*/
@@ -174,6 +179,7 @@ dependencies {
174179
"com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion",
175180
"com.gradleup.shadow:shadow-gradle-plugin:$shadowVersion",
176181
"io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion",
182+
"io.kotest:kotest-gradle-plugin:$kotestJvmPluginVersion",
177183
// https://github.com/srikanth-lingala/zip4j
178184
"net.lingala.zip4j:zip4j:2.10.0",
179185
"net.ltgt.gradle:gradle-errorprone-plugin:$errorPronePluginVersion",

buildSrc/src/main/kotlin/BuildExtensions.kt

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -199,43 +199,34 @@ fun Project.configureTaskDependencies() {
199199
}
200200

201201
afterEvaluate {
202-
val launchProtoData = "launchProtoData"
203-
val launchTestProtoData = "launchTestProtoData"
204202
val generateProto = "generateProto"
205203
val createVersionFile = "createVersionFile"
206204
val compileKotlin = "compileKotlin"
207205
compileKotlin.run {
208206
dependOn(generateProto)
209-
dependOn(launchProtoData)
210207
}
211208
val compileTestKotlin = "compileTestKotlin"
212-
compileTestKotlin.dependOn(launchTestProtoData)
213209
val sourcesJar = "sourcesJar"
214210
val kspKotlin = "kspKotlin"
215211
sourcesJar.run {
216212
dependOn(generateProto)
217-
dependOn(launchProtoData)
218213
dependOn(kspKotlin)
219214
dependOn(createVersionFile)
220215
dependOn("prepareProtocConfigVersions")
221216
}
222-
val dokkaHtml = "dokkaHtml"
223-
dokkaHtml.run {
217+
val dokkaGenerate = "dokkaGenerate"
218+
dokkaGenerate.run {
224219
dependOn(generateProto)
225-
dependOn(launchProtoData)
226-
dependOn(kspKotlin)
227-
}
228-
val dokkaJavadoc = "dokkaJavadoc"
229-
dokkaJavadoc.run {
230-
dependOn(launchProtoData)
231220
dependOn(kspKotlin)
232221
}
222+
val dokkaGeneratePublicationJavadoc = "dokkaGeneratePublicationJavadoc"
223+
dokkaGeneratePublicationJavadoc.dependOn(kspKotlin)
233224
"publishPluginJar".dependOn(createVersionFile)
234225
compileKotlin.dependOn(kspKotlin)
235226
compileTestKotlin.dependOn("kspTestKotlin")
236227
"compileTestFixturesKotlin".dependOn("kspTestFixturesKotlin")
237-
"javadocJar".dependOn(dokkaHtml)
238-
"dokkaKotlinJar".dependOn(dokkaJavadoc)
228+
"javadocJar".dependOn(dokkaGeneratePublicationJavadoc)
229+
"htmlDocsJar".dependOn(dokkaGenerate)
239230
}
240231
}
241232

buildSrc/src/main/kotlin/DocumentationSettings.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
import org.gradle.api.Project
28+
2729
/**
2830
* The documentation settings specific to this project.
2931
*
@@ -33,6 +35,36 @@
3335
@Suppress("ConstPropertyName")
3436
object DocumentationSettings {
3537

38+
/**
39+
* The organization infix for the Spine SDK.
40+
*/
41+
private const val orgPath = "github.com/SpineEventEngine"
42+
43+
/**
44+
* The organization URL of the Spine SDK.
45+
*/
46+
private const val orgUrl = "https://$orgPath"
47+
48+
/**
49+
* Obtains the repository URL for the given project.
50+
*/
51+
fun repoUrl(project: Project) = "https://${repoPath(project)}"
52+
53+
/**
54+
* Obtains the repository path for the given project.
55+
*/
56+
private fun repoPath(project: Project) = "$orgPath/${project.rootProject.name}"
57+
58+
/**
59+
* Obtains the connection URL for the given project.
60+
*/
61+
fun connectionUrl(project: Project) = "scm:git:git://${repoPath(project)}.git"
62+
63+
/**
64+
* Obtains the developer connection URL for the given project.
65+
*/
66+
fun developerConnectionUrl(project: Project) = "scm:git:ssh://${repoPath(project)}.git"
67+
3668
/**
3769
* Settings passed to Dokka for
3870
* [sourceLink][[org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceLinkSpec]
@@ -43,12 +75,16 @@ object DocumentationSettings {
4375
* The URL of the remote source code
4476
* [location][org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceLinkSpec.remoteUrl].
4577
*/
46-
const val url: String = "https://github.com/SpineEventEngine/base/tree/master/src"
78+
fun url(project: Project): String {
79+
val root = project.rootProject.name
80+
val module = project.name
81+
return "$orgUrl/$root/tree/master/$module/src/main/kotlin"
82+
}
4783

4884
/**
4985
* The suffix used to append the source code line number to the URL.
5086
*
51-
* The suffix depends on the online code repository.
87+
* The value depends on the online code repository and is set for GitHub (`#L`).
5288
*
5389
* @see <a href="https://kotlinlang.org/docs/dokka-gradle.html#fwor0d_534">
5490
* remoteLineSuffix</a>

buildSrc/src/main/kotlin/DokkaExts.kt

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,18 @@ import io.spine.gradle.publish.getOrCreate
2929
import java.io.File
3030
import java.time.LocalDate
3131
import org.gradle.api.Project
32+
import org.gradle.api.Task
3233
import org.gradle.api.artifacts.Dependency
3334
import org.gradle.api.artifacts.dsl.DependencyHandler
34-
import org.gradle.api.file.FileCollection
3535
import org.gradle.api.tasks.TaskContainer
3636
import org.gradle.api.tasks.TaskProvider
3737
import org.gradle.api.tasks.bundling.Jar
3838
import org.gradle.kotlin.dsl.DependencyHandlerScope
39-
import org.jetbrains.dokka.gradle.AbstractDokkaTask
4039
import org.jetbrains.dokka.gradle.DokkaExtension
41-
import org.jetbrains.dokka.gradle.DokkaTask
42-
import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder
4340
import org.jetbrains.dokka.gradle.engine.parameters.DokkaSourceSetSpec
4441
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
4542
import org.jetbrains.dokka.gradle.engine.plugins.DokkaHtmlPluginParameters
4643

47-
/**
48-
* To generate the documentation as seen from Java perspective, the `kotlin-as-java`
49-
* plugin was added to the Dokka classpath.
50-
*
51-
* @see <a href="https://github.com/Kotlin/dokka#output-formats">
52-
* Dokka output formats</a>
53-
*/
54-
fun DependencyHandlerScope.useDokkaForKotlinAsJava() {
55-
dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib)
56-
}
57-
5844
/**
5945
* To exclude pieces of code annotated with `@Internal` from the documentation
6046
* a custom plugin is added to the Dokka classpath.
@@ -72,9 +58,8 @@ private fun DependencyHandler.dokkaPlugin(dependencyNotation: Any): Dependency?
7258
/**
7359
* Resolves the directory where Dokka outputs HTML documentation for the given language.
7460
*/
75-
internal fun Project.dokkaOutput(language: String): File {
76-
val lng = language.titleCaseFirstChar()
77-
return layout.buildDirectory.dir("docs/dokka$lng").get().asFile
61+
internal fun Project.dokkaHtmlOutput(): File {
62+
return layout.buildDirectory.dir("dokka/html").get().asFile
7863
}
7964

8065
/**
@@ -187,54 +172,42 @@ private fun DokkaSourceSetSpec.configureSourceSet(config: SourceSetConfig) {
187172
}
188173

189174
/**
190-
* Configures this [DokkaTask] to accept only Kotlin files.
175+
* Configures this [DokkaExtension] to accept only Kotlin files.
191176
*/
192177
fun DokkaExtension.configureForKotlin(project: Project, sourceLinkRemoteUrl: String) {
193178
configureFor(project, "kotlin", sourceLinkRemoteUrl)
194179
}
195180

196181
/**
197-
* Configures this [DokkaTask] to accept only Java files.
182+
* Configures this [DokkaExtension] to accept only Java files.
198183
*/
199184
@Suppress("unused")
200185
fun DokkaExtension.configureForJava(project: Project, sourceLinkRemoteUrl: String) {
201186
configureFor(project, "java", sourceLinkRemoteUrl)
202187
}
203188

204189
/**
205-
* Finds the `dokkaHtml` Gradle task.
190+
* Finds the `dokkaGenerateHtml` Gradle task.
206191
*/
207-
fun TaskContainer.dokkaHtmlTask(): DokkaTask? = this.findByName("dokkaHtml") as DokkaTask?
192+
fun TaskContainer.dokkaHtmlTask(): Task? = this.findByName("dokkaGeneratePublicationHtml")
208193

209194
/**
210-
* Returns only Java source roots out of all present in the source set.
211-
*
212-
* It is a helper method for generating documentation by Dokka only for Java code.
213-
* It is helpful when both Java and Kotlin source files are present in a source set.
214-
* Dokka can properly generate documentation for either Kotlin or Java depending on
215-
* the configuration, but not both.
195+
* Finds the `dokkaGeneratePublicationJavadoc` Gradle task.
216196
*/
217-
@Suppress("unused")
218-
internal fun GradleDokkaSourceSetBuilder.onlyJavaSources(): FileCollection {
219-
return sourceRoots.filter(File::isJavaSourceDirectory)
220-
}
221-
222-
private fun File.isJavaSourceDirectory(): Boolean {
223-
return isDirectory && name == "java"
224-
}
197+
fun TaskContainer.dokkaJavadocTask(): Task? = this.findByName("dokkaGeneratePublicationJavadoc")
225198

226199
/**
227-
* Locates or creates `dokkaKotlinJar` task in this [Project].
200+
* Locates or creates `htmlDocsJar` task in this [Project].
228201
*
229202
* The output of this task is a `jar` archive. The archive contains the Dokka output, generated upon
230203
* Kotlin sources from `main` source set. Requires Dokka to be configured in the target project by
231-
* applying `dokka-for-kotlin` plugin.
204+
* applying `dokka-setup` plugin.
232205
*/
233-
fun Project.dokkaKotlinJar(): TaskProvider<Jar> = tasks.getOrCreate("dokkaKotlinJar") {
234-
archiveClassifier.set("dokka")
235-
from(files(dokkaOutput("kotlin")))
206+
fun Project.htmlDocsJar(): TaskProvider<Jar> = tasks.getOrCreate("htmlDocsJar") {
207+
archiveClassifier.set("html-docs")
208+
from(files(dokkaHtmlOutput()))
236209

237-
tasks.dokkaHtmlTask()?.let{ dokkaTask ->
210+
tasks.dokkaHtmlTask()?.let { dokkaTask ->
238211
this@getOrCreate.dependsOn(dokkaTask)
239212
}
240213
}
@@ -246,29 +219,13 @@ fun Project.dokkaKotlinJar(): TaskProvider<Jar> = tasks.getOrCreate("dokkaKotlin
246219
* This predicate could be useful for disabling publishing tasks
247220
* when doing, e.g., `publishToMavenLocal` for the purpose of the
248221
* integration tests that (of course) do not test the documentation
249-
* generation proces and its resuults.
222+
* generation process and its results.
250223
*/
251-
fun AbstractDokkaTask.isInPublishingGraph(): Boolean =
224+
fun Task.isInPublishingGraph(): Boolean =
252225
project.gradle.taskGraph.allTasks.any {
253226
it.name == "publish" || it.name.contains("dokkaGenerate")
254227
}
255228

256-
/**
257-
* Locates or creates `dokkaJavaJar` task in this [Project].
258-
*
259-
* The output of this task is a `jar` archive. The archive contains the Dokka output, generated upon
260-
* Kotlin sources from `main` source set. Requires Dokka to be configured in the target project by
261-
* applying `dokka-for-java` and/or `dokka-for-kotlin` script plugin.
262-
*/
263-
fun Project.dokkaJavaJar(): TaskProvider<Jar> = tasks.getOrCreate("dokkaJavaJar") {
264-
archiveClassifier.set("dokka-java")
265-
from(files(dokkaOutput("java")))
266-
267-
tasks.dokkaHtmlTask()?.let{ dokkaTask ->
268-
this@getOrCreate.dependsOn(dokkaTask)
269-
}
270-
}
271-
272229
/**
273230
* Disables Dokka and Javadoc tasks in this `Project`.
274231
*

buildSrc/src/main/kotlin/dokka-for-kotlin.gradle.kts

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)