Skip to content
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

Drop duplicated dependencies from pom.xml #182

Merged
merged 10 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 1 addition & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ plugins {
jacoco
kotlin("jvm")
idea
pmd
`project-report`
@Suppress("RemoveRedundantQualifierName") // Cannot use imports here.
io.spine.internal.dependency.Protobuf.GradlePlugin.apply {
Expand Down Expand Up @@ -145,7 +144,6 @@ subprojects {
plugin("kotlin")
plugin("com.google.protobuf")
plugin("net.ltgt.errorprone")
plugin("pmd")
plugin("maven-publish")

// Apply custom Kotlin script plugins.
Expand Down Expand Up @@ -290,7 +288,7 @@ fun NamedDomainObjectContainer<Configuration>.forceTransitiveDependencies() = al
GoogleApis.AuthLibrary.credentials,
GoogleApis.AuthLibrary.oAuth2Http,

J2ObjC.lib,
J2ObjC.annotations,

HttpClient.google,
HttpClient.jackson2,
Expand Down
47 changes: 44 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ val grGitVersion = "3.1.1"
* Please check that this value matches one defined in
* [io.spine.internal.dependency.Kotlin.version].
*/
val kotlinVersion = "1.6.10"
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.0.1-jre"
val guavaVersion = "31.1-jre"

/**
* The version of ErrorProne Gradle plugin.
Expand All @@ -93,6 +93,41 @@ val errorProneVersion = "2.0.2"
*/
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"
)
}
}

val jvmVersion = JavaLanguageVersion.of(11)

java {
toolchain.languageVersion.set(jvmVersion)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = jvmVersion.toString()
}
}

dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jacksonVersion")
Expand All @@ -103,6 +138,12 @@ dependencies {
api("com.github.jk1:gradle-license-report:$licenseReportVersion")
implementation("org.ajoberstar.grgit:grgit-core:${grGitVersion}")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:${errorProneVersion}")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")

// 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}")
}
96 changes: 96 additions & 0 deletions buildSrc/src/main/kotlin/dokka-for-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2022, 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
*
* http://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.
*/

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

plugins {
id("org.jetbrains.dokka")
}

dependencies {
/**
* 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)

/**
* To exclude pieces of code annotated with `@Internal` from the documentation a custom plugin
* is added to the Dokka's classpath.
*
* @see <a href="https://github.com/SpineEventEngine/dokka-tools/tree/master/dokka-extensions">
* Custom Dokka Plugins</a>
*/
dokkaPlugin(Dokka.SpineExtensions.lib)
}

tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
sourceRoots.setFrom(
onlyJavaSources()
)

sourceRoots.setFrom(
onlyNonGeneratedSources()
)

skipEmptyPackages.set(true)
}

outputDirectory.set(buildDir.resolve("docs/dokka"))

val dokkaConfDir = rootDir.resolve("buildSrc/src/main/resources/dokka")

/**
* Dokka Base plugin allows to set a few properties to customize the output:
*
* - `customStyleSheets` property to which we can pass our css files overriding styles generated
* by Dokka;
* - `customAssets` property to provide resources. We need to provide an image with the name
* "logo-icon.svg" to overwrite the default one used by Dokka;
* - `separateInheritedMembers` when set to `true`, creates a separate tab in type-documentation
* for inherited members.
*
* @see <a href="https://kotlin.github.io/dokka/1.6.10/user_guide/base-specific/frontend/#prerequisites">
* Dokka modifying frontend assets</a>
*/
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
customStyleSheets = listOf(file("${dokkaConfDir.resolve("styles/custom-styles.css")}"))
customAssets = listOf(file("${dokkaConfDir.resolve("assets/logo-icon.svg")}"))
separateInheritedMembers = true
footerMessage = "Copyright ${LocalDate.now().year}, TeamDev"
}
}
46 changes: 44 additions & 2 deletions buildSrc/src/main/kotlin/io/spine/internal/dependency/Dokka.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,48 @@ package io.spine.internal.dependency
// https://github.com/Kotlin/dokka
@Suppress("unused")
object Dokka {
const val version = "1.6.10"
const val pluginId = "org.jetbrains.dokka"
private const val group = "org.jetbrains.dokka"

/**
* When changing the version, also change the version used in the `buildSrc/build.gradle.kts`.
*/
const val version = "1.6.20"

object GradlePlugin {
const val id = "org.jetbrains.dokka"

/**
* The version of this plugin is already specified in `buildSrc/build.gradle.kts` file.
* Thus, when applying the plugin in project's build files, only the [id] should be used.
*/
const val lib = "${group}:dokka-gradle-plugin:${version}"
}

object BasePlugin {
const val lib = "${group}:dokka-base:${version}"
}

/**
* To generate the documentation as seen from Java perspective use this plugin.
*
* @see <a href="https://github.com/Kotlin/dokka#output-formats">
* Dokka output formats</a>
*/
object KotlinAsJavaPlugin {
const val lib = "${group}:kotlin-as-java-plugin:${version}"
}

/**
* Custom Dokka plugins developed for Spine-specific needs like excluding by `@Internal`
* annotation.
*
* @see <a href="https://github.com/SpineEventEngine/dokka-tools/tree/master/dokka-extensions">
* Custom Dokka Plugins</a>
*/
object SpineExtensions {
private const val group = "io.spine.tools"

const val version = "2.0.0-SNAPSHOT.3"
const val lib = "${group}:spine-dokka-extensions:${version}"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ package io.spine.internal.dependency
@Suppress("unused")
object Grpc {
@Suppress("MemberVisibilityCanBePrivate")
const val version = "1.45.0"
const val version = "1.45.1"
const val api = "io.grpc:grpc-api:${version}"
const val auth = "io.grpc:grpc-auth:${version}"
const val core = "io.grpc:grpc-core:${version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ package io.spine.internal.dependency
// https://github.com/JetBrains/kotlin
// https://github.com/Kotlin
object Kotlin {
/**
* When changing the version, also change the version used in the `buildSrc/build.gradle.kts`.
*/
@Suppress("MemberVisibilityCanBePrivate") // used directly from outside
const val version = "1.6.10"
const val version = "1.6.21"
const val reflect = "org.jetbrains.kotlin:kotlin-reflect:${version}"
const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib:${version}"
const val stdLibCommon = "org.jetbrains.kotlin:kotlin-stdlib-common:${version}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright 2022, 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
*
* http://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.
*/

package io.spine.internal.gradle.dokka

import java.io.File
import org.gradle.api.file.FileCollection
import org.jetbrains.dokka.gradle.GradleDokkaSourceSetBuilder

/**
* Returns only Java source roots out of all present in the source set.
*
* It is a helper method for generating documentation by Dokka only for Java code.
* It is helpful when both Java and Kotlin source files are present in a source set.
* Dokka can properly generate documentation for either Kotlin or Java depending on
* the configuration, but not both.
*/
internal fun GradleDokkaSourceSetBuilder.onlyJavaSources(): FileCollection {
return sourceRoots.filter(File::isJavaSourceDirectory)
}

private fun File.isJavaSourceDirectory(): Boolean {
return isDirectory && name == "java"
}

/**
* Returns only non-generated source roots out of all present in the source set.
*
* It is a helper method for generating documentation by Dokka only for non-generated code.
* It helps to filter out source files generated by`Protoc`.
*/
internal fun GradleDokkaSourceSetBuilder.onlyNonGeneratedSources(): FileCollection {
return sourceRoots.filter(File::isNonGeneratedDirectory)
}

private fun File.isNonGeneratedDirectory(): Boolean {
return isDirectory && !path.contains("/generated/")
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ fun KotlinJvmProjectExtension.applyJvmToolchain(version: String) =
/**
* Opts-in to experimental features that we use in our codebase.
*/
@Suppress("unused")
fun KotlinCompile.setFreeCompilerArgs() {
kotlinOptions {
freeCompilerArgs = listOf(
"-Xskip-prerelease-check",
"-Xjvm-default=all",
"-Xopt-in=kotlin.contracts.ExperimentalContracts",
"-Xopt-in=kotlin.ExperimentalStdlibApi"
"-Xinline-classes",
"-opt-in=" +
"kotlin.contracts.ExperimentalContracts," +
"kotlin.io.path.ExperimentalPathApi," +
"kotlin.ExperimentalUnsignedTypes," +
"kotlin.ExperimentalStdlibApi," +
"kotlin.experimental.ExperimentalTypeInference",
)
}
}
Loading