Skip to content

Commit 0aeca62

Browse files
Merge pull request #239 from SpineEventEngine/draft-doc-structure
Apply latest `config` and local dependencies
2 parents 0f3f1ec + f1ce3bf commit 0aeca62

Some content is hidden

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

75 files changed

+2357
-2834
lines changed
43.3 KB
Loading
48.1 KB
Loading

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ jobs:
5858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5959
FORMAL_GIT_HUB_PAGES_AUTHOR: developers@spine.io
6060
# https://docs.github.com/en/actions/reference/environment-variables
61-
REPO_SLUG: $GITHUB_REPOSITORY # e.g. SpineEventEngine/core-java
61+
REPO_SLUG: ${{ github.repository }} # e.g. SpineEventEngine/core-jvm
6262
GOOGLE_APPLICATION_CREDENTIALS: ./maven-publisher.json
6363
NPM_TOKEN: ${{ secrets.NPM_SECRET }}

README.md

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ At build time, Spine Validation injects assertions into the generated Java class
5555
```java
5656
var card = CardNumber.newBuilder()
5757
.setDigits("invalid")
58-
.build(); <- Validates here.
58+
.build(); // <- Validates here.
59+
```
60+
61+
```kotlin
62+
val card = cardNumber {
63+
digits = "invalid"
64+
} // <- Validates here.
5965
```
6066

6167
If any constraint is violated, a `ValidationException` is thrown from `build()`.
@@ -65,7 +71,7 @@ You can also validate without throwing:
6571
```java
6672
var card = CardNumber.newBuilder()
6773
.setDigits("invalid")
68-
.buildPartial(); <- No validation.
74+
.buildPartial(); // <- No validation.
6975
var optionalError = card.validate();
7076
optionalError.ifPresent(err -> {
7177
System.out.println(err.getMessage());
@@ -76,7 +82,7 @@ optionalError.ifPresent(err -> {
7682

7783
Validation options are defined by the following files:
7884

79-
1. [options.proto](https://github.com/SpineEventEngine/base/blob/master/base/src/main/proto/spine/options.proto).
85+
1. [options.proto](https://github.com/SpineEventEngine/base-libraries/blob/master/base/src/main/proto/spine/options.proto).
8086
2. [time_options.proto](https://github.com/SpineEventEngine/time/blob/master/time/src/main/proto/spine/time_options.proto).
8187

8288
Users must import these .proto files to use the options they define.
@@ -86,32 +92,7 @@ import "spine/options.proto"; // Brings all options, except for time-related one
8692
import "spine/time_options.proto"; // Brings time-related options.
8793
```
8894

89-
## Architecture
90-
91-
The library is a set of plugins for [ProtoData](https://github.com/SpineEventEngine/ProtoData).
92-
93-
Each target language is a separate ProtoData plugin.
94-
95-
Take a look at the following diagram to grasp a high-level library structure:
96-
97-
![High-level library structure overview](.github/readme/high_level_overview.png)
98-
99-
The workflow is the following:
100-
101-
- (1), (2) – user defines Protobuf messages with validation options.
102-
- (3) – Protobuf compiler generates Java classes.
103-
- (4), (5) – policies and views build the validation model.
104-
- (6), (7) – Java plugin generates and injects validation code.
105-
106-
### Key Modules
107-
108-
| Module | Description |
109-
|-----------|----------------------------------------------------------------------|
110-
| :model | The language-agnostic model for the built-in options. |
111-
| :java | Generates and injects Java validation code based on applied options. |
112-
| :java-api | Extension API for custom options in Java. |
113-
114-
# Extending the Library
95+
# Adding custom validation
11596

11697
Users can extend the library by providing custom Protobuf options and code generation logic.
11798

build.gradle.kts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@
2626

2727
@file:Suppress("RemoveRedundantQualifierName") // To prevent IDEA replacing FQN imports.
2828

29+
import io.spine.dependency.lib.Grpc
2930
import io.spine.dependency.lib.KotlinPoet
3031
import io.spine.dependency.lib.Roaster
3132
import io.spine.dependency.local.Base
33+
import io.spine.dependency.local.Compiler
3234
import io.spine.dependency.local.CoreJava
3335
import io.spine.dependency.local.Logging
34-
import io.spine.dependency.local.Compiler
35-
import io.spine.dependency.local.Spine
36+
import io.spine.dependency.local.Time
3637
import io.spine.dependency.local.ToolBase
3738
import io.spine.gradle.publish.PublishingRepos
3839
import io.spine.gradle.publish.spinePublishing
@@ -58,6 +59,11 @@ buildscript {
5859

5960
// Make sure we have the right Protobuf Runtime by adding it explicitly.
6061
classpath(io.spine.dependency.lib.Protobuf.javaLib)
62+
63+
// For `io.spine.generated-sources` plugin.
64+
classpath(io.spine.dependency.local.ToolBase.protobufSetupPlugins)
65+
66+
classpath(io.spine.dependency.kotlinx.DateTime.lib)
6167
}
6268
}
6369

@@ -88,11 +94,6 @@ spinePublishing {
8894
)
8995
}
9096
artifactPrefix = "spine-validation-"
91-
92-
dokkaJar {
93-
java = true
94-
kotlin = true
95-
}
9697
}
9798

9899
allprojects {
@@ -108,20 +109,24 @@ allprojects {
108109
resolutionStrategy {
109110
@Suppress("DEPRECATION") // `Kotlin.stdLibJdk7` is a transitive dependency.
110111
force(
111-
Roaster.api,
112-
Roaster.jdt,
112+
Base.lib,
113113
Compiler.api,
114-
Compiler.params,
115-
Compiler.pluginLib,
116114
Compiler.backend,
115+
Compiler.gradleApi,
117116
Compiler.jvm,
118-
Base.lib,
119-
Logging.lib,
117+
Compiler.params,
118+
Compiler.pluginLib,
120119
CoreJava.client,
121120
CoreJava.server,
121+
Grpc.bom,
122+
KotlinPoet.lib,
123+
Logging.lib,
124+
Roaster.api,
125+
Roaster.jdt,
126+
Time.lib,
127+
Time.javaExtensions,
122128
ToolBase.lib,
123129
ToolBase.pluginBase,
124-
KotlinPoet.lib,
125130
)
126131
}
127132
}

buildSrc/build.gradle.kts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ plugins {
3838
`kotlin-dsl`
3939

4040
// https://github.com/jk1/Gradle-License-Report/releases
41-
id("com.github.jk1.dependency-license-report").version("2.7")
41+
id("com.github.jk1.dependency-license-report").version("2.9")
4242
}
4343

4444
repositories {
@@ -65,7 +65,7 @@ val jacksonVersion = "2.18.3"
6565
*/
6666
val googleAuthToolVersion = "2.1.5"
6767

68-
val licenseReportVersion = "2.9"
68+
val licenseReportVersion = "2.7"
6969

7070
val grGitVersion = "4.1.1"
7171

@@ -75,7 +75,7 @@ val grGitVersion = "4.1.1"
7575
* This version may change from the [version of Kotlin][io.spine.dependency.lib.Kotlin.version]
7676
* used by the project.
7777
*/
78-
val kotlinEmbeddedVersion = "2.2.20"
78+
val kotlinEmbeddedVersion = "2.2.21"
7979

8080
/**
8181
* The version of Guava used in `buildSrc`.
@@ -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.
@@ -127,11 +127,6 @@ val detektVersion = "1.23.8"
127127
*/
128128
val kotestJvmPluginVersion = "0.4.10"
129129

130-
/**
131-
* @see [io.spine.dependency.test.Kotest.MultiplatformGradlePlugin]
132-
*/
133-
val kotestMultiplatformPluginVersion = "5.9.1"
134-
135130
/**
136131
* @see [io.spine.dependency.test.Kover]
137132
*/
@@ -185,7 +180,6 @@ dependencies {
185180
"com.gradleup.shadow:shadow-gradle-plugin:$shadowVersion",
186181
"io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detektVersion",
187182
"io.kotest:kotest-gradle-plugin:$kotestJvmPluginVersion",
188-
"io.kotest:kotest-framework-multiplatform-plugin-gradle:$kotestMultiplatformPluginVersion",
189183
// https://github.com/srikanth-lingala/zip4j
190184
"net.lingala.zip4j:zip4j:2.10.0",
191185
"net.ltgt.gradle:gradle-errorprone-plugin:$errorPronePluginVersion",

buildSrc/src/main/kotlin/BuildExtensions.kt

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,15 @@ val PluginDependenciesSpec.`gradle-doctor`: PluginDependencySpec
156156
get() = id(GradleDoctor.pluginId).version(GradleDoctor.version)
157157

158158
val PluginDependenciesSpec.kotest: PluginDependencySpec
159-
get() = Kotest.MultiplatformGradlePlugin.let {
160-
return id(it.id).version(it.version)
159+
get() = Kotest.let {
160+
return id(it.gradlePluginId).version(it.version)
161161
}
162162

163163
val PluginDependenciesSpec.kover: PluginDependencySpec
164164
get() = id(Kover.id).version(Kover.version)
165165

166166
val PluginDependenciesSpec.ksp: PluginDependencySpec
167-
get() = id(Ksp.id).version(Ksp.version)
167+
get() = id(Ksp.id).version(Ksp.dogfoodingVersion)
168168

169169
val PluginDependenciesSpec.`plugin-publish`: PluginDependencySpec
170170
get() = id(PluginPublishPlugin.id).version(PluginPublishPlugin.version)
@@ -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>

0 commit comments

Comments
 (0)