Skip to content

Commit 27aef68

Browse files
Merge pull request #182 from SpineEventEngine/drop-duplicates-pom
Drop duplicated dependencies from `pom.xml`
2 parents 962feef + 0445b0b commit 27aef68

25 files changed

+1366
-185
lines changed

build.gradle.kts

+9-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ plugins {
9595
jacoco
9696
kotlin("jvm")
9797
idea
98-
pmd
9998
`project-report`
10099
@Suppress("RemoveRedundantQualifierName") // Cannot use imports here.
101100
io.spine.internal.dependency.Protobuf.GradlePlugin.apply {
@@ -120,6 +119,9 @@ spinePublishing {
120119
cloudArtifactRegistry
121120
)
122121
}
122+
dokkaJar {
123+
enabled = true
124+
}
123125
}
124126

125127
allprojects {
@@ -145,11 +147,11 @@ subprojects {
145147
plugin("kotlin")
146148
plugin("com.google.protobuf")
147149
plugin("net.ltgt.errorprone")
148-
plugin("pmd")
149150
plugin("maven-publish")
150151

151152
// Apply custom Kotlin script plugins.
152153
plugin("pmd-settings")
154+
plugin("dokka-for-java")
153155
}
154156

155157
repositories {
@@ -290,7 +292,7 @@ fun NamedDomainObjectContainer<Configuration>.forceTransitiveDependencies() = al
290292
GoogleApis.AuthLibrary.credentials,
291293
GoogleApis.AuthLibrary.oAuth2Http,
292294

293-
J2ObjC.lib,
295+
J2ObjC.annotations,
294296

295297
HttpClient.google,
296298
HttpClient.jackson2,
@@ -306,6 +308,10 @@ fun NamedDomainObjectContainer<Configuration>.forceTransitiveDependencies() = al
306308

307309
Jackson.core,
308310
Jackson.databind,
311+
Jackson.bom,
312+
Jackson.annotations,
313+
Jackson.moduleKotlin,
314+
Jackson.dataformatXml,
309315

310316
CommonsCodec.lib,
311317
CommonsCollections.lib,

buildSrc/build.gradle.kts

+44-3
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ val grGitVersion = "3.1.1"
6363
* Please check that this value matches one defined in
6464
* [io.spine.internal.dependency.Kotlin.version].
6565
*/
66-
val kotlinVersion = "1.6.10"
66+
val kotlinVersion = "1.6.21"
6767

6868
/**
6969
* The version of Guava used in `buildSrc`.
7070
*
7171
* Always use the same version as the one specified in [io.spine.internal.dependency.Guava].
7272
* Otherwise, when testing Gradle plugins, clashes may occur.
7373
*/
74-
val guavaVersion = "31.0.1-jre"
74+
val guavaVersion = "31.1-jre"
7575

7676
/**
7777
* The version of ErrorProne Gradle plugin.
@@ -93,6 +93,41 @@ val errorProneVersion = "2.0.2"
9393
*/
9494
val protobufPluginVersion = "0.8.18"
9595

96+
/**
97+
* The version of Dokka Gradle Plugins.
98+
*
99+
* Please keep in sync with [io.spine.internal.dependency.Dokka.version].
100+
*
101+
* @see <a href="https://github.com/Kotlin/dokka/releases">
102+
* Dokka Releases</a>
103+
*/
104+
val dokkaVersion = "1.6.20"
105+
106+
configurations.all {
107+
resolutionStrategy {
108+
// Force Kotlin lib versions avoiding using those bundled with Gradle.
109+
force(
110+
"org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion",
111+
"org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion",
112+
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion",
113+
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion",
114+
"org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
115+
)
116+
}
117+
}
118+
119+
val jvmVersion = JavaLanguageVersion.of(11)
120+
121+
java {
122+
toolchain.languageVersion.set(jvmVersion)
123+
}
124+
125+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
126+
kotlinOptions {
127+
jvmTarget = jvmVersion.toString()
128+
}
129+
}
130+
96131
dependencies {
97132
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
98133
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion")
@@ -103,6 +138,12 @@ dependencies {
103138
api("com.github.jk1:gradle-license-report:$licenseReportVersion")
104139
implementation("org.ajoberstar.grgit:grgit-core:${grGitVersion}")
105140
implementation("net.ltgt.gradle:gradle-errorprone-plugin:${errorProneVersion}")
106-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
141+
142+
// Add explicit dependency to avoid warning on different Kotlin runtime versions.
143+
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
144+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
145+
107146
implementation("gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:$protobufPluginVersion")
147+
implementation("org.jetbrains.dokka:dokka-gradle-plugin:${dokkaVersion}")
148+
implementation("org.jetbrains.dokka:dokka-base:${dokkaVersion}")
108149
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright 2022, TeamDev. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Redistribution and use in source and/or binary forms, with or without
11+
* modification, must retain the above copyright notice and the following
12+
* disclaimer.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
*/
26+
27+
import io.spine.internal.dependency.Dokka
28+
import io.spine.internal.gradle.dokka.onlyJavaSources
29+
import io.spine.internal.gradle.dokka.onlyNonGeneratedSources
30+
31+
import java.time.LocalDate
32+
import org.jetbrains.dokka.base.DokkaBase
33+
import org.jetbrains.dokka.base.DokkaBaseConfiguration
34+
import org.jetbrains.dokka.gradle.DokkaTask
35+
36+
plugins {
37+
id("org.jetbrains.dokka")
38+
}
39+
40+
dependencies {
41+
/**
42+
* To generate the documentation as seen from Java perspective, the kotlin-as-java plugin was
43+
* added to the Dokka's classpath.
44+
*
45+
* @see <a href="https://github.com/Kotlin/dokka#output-formats">
46+
* Dokka output formats</a>
47+
*/
48+
dokkaPlugin(Dokka.KotlinAsJavaPlugin.lib)
49+
50+
/**
51+
* To exclude pieces of code annotated with `@Internal` from the documentation a custom plugin
52+
* is added to the Dokka's classpath.
53+
*
54+
* @see <a href="https://github.com/SpineEventEngine/dokka-tools/tree/master/dokka-extensions">
55+
* Custom Dokka Plugins</a>
56+
*/
57+
dokkaPlugin(Dokka.SpineExtensions.lib)
58+
}
59+
60+
tasks.withType<DokkaTask>().configureEach {
61+
dokkaSourceSets.configureEach {
62+
sourceRoots.setFrom(
63+
onlyJavaSources()
64+
)
65+
66+
sourceRoots.setFrom(
67+
onlyNonGeneratedSources()
68+
)
69+
70+
skipEmptyPackages.set(true)
71+
}
72+
73+
outputDirectory.set(buildDir.resolve("docs/dokka"))
74+
75+
val dokkaConfDir = rootDir.resolve("buildSrc/src/main/resources/dokka")
76+
77+
/**
78+
* Dokka Base plugin allows to set a few properties to customize the output:
79+
*
80+
* - `customStyleSheets` property to which we can pass our css files overriding styles generated
81+
* by Dokka;
82+
* - `customAssets` property to provide resources. We need to provide an image with the name
83+
* "logo-icon.svg" to overwrite the default one used by Dokka;
84+
* - `separateInheritedMembers` when set to `true`, creates a separate tab in type-documentation
85+
* for inherited members.
86+
*
87+
* @see <a href="https://kotlin.github.io/dokka/1.6.10/user_guide/base-specific/frontend/#prerequisites">
88+
* Dokka modifying frontend assets</a>
89+
*/
90+
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
91+
customStyleSheets = listOf(file("${dokkaConfDir.resolve("styles/custom-styles.css")}"))
92+
customAssets = listOf(file("${dokkaConfDir.resolve("assets/logo-icon.svg")}"))
93+
separateInheritedMembers = true
94+
footerMessage = "Copyright ${LocalDate.now().year}, TeamDev"
95+
}
96+
}

buildSrc/src/main/kotlin/io/spine/internal/dependency/Dokka.kt

+44-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,48 @@ package io.spine.internal.dependency
2929
// https://github.com/Kotlin/dokka
3030
@Suppress("unused")
3131
object Dokka {
32-
const val version = "1.6.10"
33-
const val pluginId = "org.jetbrains.dokka"
32+
private const val group = "org.jetbrains.dokka"
33+
34+
/**
35+
* When changing the version, also change the version used in the `buildSrc/build.gradle.kts`.
36+
*/
37+
const val version = "1.6.20"
38+
39+
object GradlePlugin {
40+
const val id = "org.jetbrains.dokka"
41+
42+
/**
43+
* The version of this plugin is already specified in `buildSrc/build.gradle.kts` file.
44+
* Thus, when applying the plugin in project's build files, only the [id] should be used.
45+
*/
46+
const val lib = "${group}:dokka-gradle-plugin:${version}"
47+
}
48+
49+
object BasePlugin {
50+
const val lib = "${group}:dokka-base:${version}"
51+
}
52+
53+
/**
54+
* To generate the documentation as seen from Java perspective use this plugin.
55+
*
56+
* @see <a href="https://github.com/Kotlin/dokka#output-formats">
57+
* Dokka output formats</a>
58+
*/
59+
object KotlinAsJavaPlugin {
60+
const val lib = "${group}:kotlin-as-java-plugin:${version}"
61+
}
62+
63+
/**
64+
* Custom Dokka plugins developed for Spine-specific needs like excluding by `@Internal`
65+
* annotation.
66+
*
67+
* @see <a href="https://github.com/SpineEventEngine/dokka-tools/tree/master/dokka-extensions">
68+
* Custom Dokka Plugins</a>
69+
*/
70+
object SpineExtensions {
71+
private const val group = "io.spine.tools"
72+
73+
const val version = "2.0.0-SNAPSHOT.3"
74+
const val lib = "${group}:spine-dokka-extensions:${version}"
75+
}
3476
}

buildSrc/src/main/kotlin/io/spine/internal/dependency/Grpc.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ package io.spine.internal.dependency
3030
@Suppress("unused")
3131
object Grpc {
3232
@Suppress("MemberVisibilityCanBePrivate")
33-
const val version = "1.45.0"
33+
const val version = "1.45.1"
3434
const val api = "io.grpc:grpc-api:${version}"
3535
const val auth = "io.grpc:grpc-auth:${version}"
3636
const val core = "io.grpc:grpc-core:${version}"

buildSrc/src/main/kotlin/io/spine/internal/dependency/Jackson.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ package io.spine.internal.dependency
2828

2929
@Suppress("unused")
3030
object Jackson {
31-
private const val version = "2.13.2"
32-
private const val databindVersion = "2.13.2.2"
31+
const val version = "2.13.2"
32+
const val databindVersion = "2.13.2.2"
3333
// https://github.com/FasterXML/jackson-core
3434
const val core = "com.fasterxml.jackson.core:jackson-core:${version}"
3535
// https://github.com/FasterXML/jackson-databind
@@ -40,4 +40,8 @@ object Jackson {
4040
const val dataformatYaml = "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${version}"
4141
// https://github.com/FasterXML/jackson-module-kotlin/releases
4242
const val moduleKotlin = "com.fasterxml.jackson.module:jackson-module-kotlin:${version}"
43+
// https://github.com/FasterXML/jackson-bom
44+
const val bom = "com.fasterxml.jackson:jackson-bom:${version}"
45+
// https://github.com/FasterXML/jackson-annotations
46+
const val annotations = "com.fasterxml.jackson.core:jackson-annotations:${version}"
4347
}

buildSrc/src/main/kotlin/io/spine/internal/dependency/Kotlin.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ package io.spine.internal.dependency
2929
// https://github.com/JetBrains/kotlin
3030
// https://github.com/Kotlin
3131
object Kotlin {
32+
/**
33+
* When changing the version, also change the version used in the `buildSrc/build.gradle.kts`.
34+
*/
3235
@Suppress("MemberVisibilityCanBePrivate") // used directly from outside
33-
const val version = "1.6.10"
36+
const val version = "1.6.21"
3437
const val reflect = "org.jetbrains.kotlin:kotlin-reflect:${version}"
3538
const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib:${version}"
3639
const val stdLibCommon = "org.jetbrains.kotlin:kotlin-stdlib-common:${version}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2022, TeamDev. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Redistribution and use in source and/or binary forms, with or without
11+
* modification, must retain the above copyright notice and the following
12+
* disclaimer.
13+
*
14+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
*/
26+
27+
package io.spine.internal.gradle.dokka
28+
29+
import java.io.File
30+
import org.gradle.api.file.FileCollection
31+
import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder
32+
33+
/**
34+
* Returns only Java source roots out of all present in the source set.
35+
*
36+
* It is a helper method for generating documentation by Dokka only for Java code.
37+
* It is helpful when both Java and Kotlin source files are present in a source set.
38+
* Dokka can properly generate documentation for either Kotlin or Java depending on
39+
* the configuration, but not both.
40+
*/
41+
internal fun GradleDokkaSourceSetBuilder.onlyJavaSources(): FileCollection {
42+
return sourceRoots.filter(File::isJavaSourceDirectory)
43+
}
44+
45+
private fun File.isJavaSourceDirectory(): Boolean {
46+
return isDirectory && name == "java"
47+
}
48+
49+
/**
50+
* Returns only non-generated source roots out of all present in the source set.
51+
*
52+
* It is a helper method for generating documentation by Dokka only for non-generated code.
53+
* It helps to filter out source files generated by`Protoc`.
54+
*/
55+
internal fun GradleDokkaSourceSetBuilder.onlyNonGeneratedSources(): FileCollection {
56+
return sourceRoots.filter(File::isNonGeneratedDirectory)
57+
}
58+
59+
private fun File.isNonGeneratedDirectory(): Boolean {
60+
return isDirectory && !path.contains("/generated/")
61+
}

buildSrc/src/main/kotlin/io/spine/internal/gradle/kotlin/KotlinConfig.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,19 @@ fun KotlinJvmProjectExtension.applyJvmToolchain(version: String) =
5252
/**
5353
* Opts-in to experimental features that we use in our codebase.
5454
*/
55+
@Suppress("unused")
5556
fun KotlinCompile.setFreeCompilerArgs() {
5657
kotlinOptions {
5758
freeCompilerArgs = listOf(
5859
"-Xskip-prerelease-check",
5960
"-Xjvm-default=all",
60-
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
61-
"-Xopt-in=kotlin.ExperimentalStdlibApi"
61+
"-Xinline-classes",
62+
"-opt-in=" +
63+
"kotlin.contracts.ExperimentalContracts," +
64+
"kotlin.io.path.ExperimentalPathApi," +
65+
"kotlin.ExperimentalUnsignedTypes," +
66+
"kotlin.ExperimentalStdlibApi," +
67+
"kotlin.experimental.ExperimentalTypeInference",
6268
)
6369
}
6470
}

0 commit comments

Comments
 (0)