From 86b921946c75531524ab6909908f198710cdd2fa Mon Sep 17 00:00:00 2001 From: Jakub Chrzanowski Date: Tue, 4 Apr 2023 17:17:47 +0200 Subject: [PATCH] Gradle version catalog integration --- CHANGELOG.md | 1 + README.md | 23 +++++++++++++++++++++++ build.gradle.kts | 23 +++++++++++------------ gradle/libs.versions.toml | 22 ++++++++++++++++++++++ 4 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 gradle/libs.versions.toml diff --git a/CHANGELOG.md b/CHANGELOG.md index b3fe31d..7eb62ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Added - Temporary workaround for Kotlin Compiler OutOfMemoryError -> https://jb.gg/intellij-platform-kotlin-oom +- Gradle version catalog integration ### Changed - Dependencies - upgrade `org.jetbrains.intellij` to `1.13.3` diff --git a/README.md b/README.md index a50ce26..cc949bc 100644 --- a/README.md +++ b/README.md @@ -368,6 +368,27 @@ All the workflow files have accurate documentation, so it's a good idea to take This Template project depends on Gradle plugins and external libraries – and during the development, you will add more of them. +All plugins and dependencies used by Gradle are managed with [Gradle version catalog][gradle-version-catalog], which defines versions and coordinates of your dependencies in the [`gradle/libs.versions.toml`][file:libs.versions.toml] file. + +> **Note** +> +> To add a new dependency to the project, in the `dependencies { ... }` block, add: +> +> ```kotlin +> dependencies { +> implementation(libs.annotations) +> } +> ``` +> +> and define the dependency in the [`gradle/libs.versions.toml`][file:libs.versions.toml] file as follows: +> ```toml +> [versions] +> annotations = "24.0.1" +> +> [libraries] +> annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } +> ``` + Keeping the project in good shape and having all the dependencies up-to-date requires time and effort, but it is possible to automate that process using [Dependabot][gh:dependabot]. Dependabot is a bot provided by GitHub to check the build configuration files and review any outdated or insecure dependencies of yours – in case if any update is available, it creates a new pull request providing [the proper change][gh:dependabot-pr]. @@ -528,6 +549,7 @@ That approach gives more possibilities for testing and debugging pre-releases, f [file:use-this-template.png]: .github/readme/use-this-template.png [file:draft-release.png]: .github/readme/draft-release.png [file:gradle.properties]: ./gradle.properties +[file:libs.versions.toml]: ./gradle/libs.versions.toml [file:run-logs.png]: .github/readme/run-logs.png [file:plugin.xml]: ./src/main/resources/META-INF/plugin.xml [file:run-debug-configurations.png]: .github/readme/run-debug-configurations.png @@ -575,6 +597,7 @@ That approach gives more possibilities for testing and debugging pre-releases, f [gradle-kotlin-dsl]: https://docs.gradle.org/current/userguide/kotlin_dsl.html [gradle-lifecycle-tasks]: https://docs.gradle.org/current/userguide/java_plugin.html#lifecycle_tasks [gradle-releases]: https://gradle.org/releases +[gradle-version-catalog]: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog [keep-a-changelog]: https://keepachangelog.com [keep-a-changelog-how]: https://keepachangelog.com/en/1.0.0/#how [semver]: https://semver.org diff --git a/build.gradle.kts b/build.gradle.kts index d5a0985..5b2ba8c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,18 +5,12 @@ fun properties(key: String) = providers.gradleProperty(key) fun environment(key: String) = providers.environmentVariable(key) plugins { - // Java support - id("java") - // Kotlin support - id("org.jetbrains.kotlin.jvm") version "1.8.20" - // Gradle IntelliJ Plugin - id("org.jetbrains.intellij") version "1.13.3" - // Gradle Changelog Plugin - id("org.jetbrains.changelog") version "2.0.0" - // Gradle Qodana Plugin - id("org.jetbrains.qodana") version "0.1.13" - // Gradle Kover Plugin - id("org.jetbrains.kotlinx.kover") version "0.6.1" + id("java") // Java support + alias(libs.plugins.kotlin) // Kotlin support + alias(libs.plugins.gradleIntelliJPlugin) // Gradle IntelliJ Plugin + alias(libs.plugins.changelog) // Gradle Changelog Plugin + alias(libs.plugins.qodana) // Gradle Qodana Plugin + alias(libs.plugins.kover) // Gradle Kover Plugin } group = properties("pluginGroup").get() @@ -27,6 +21,11 @@ repositories { mavenCentral() } +// Dependencies are managed with Gradle version catalog - read more: https://docs.gradle.org/current/userguide/platforms.html#sub:version-catalog +dependencies { +// implementation(libs.annotations) +} + // Set the JVM language level used to build the project. Use Java 11 for 2020.3+, and Java 17 for 2022.2+. kotlin { jvmToolchain(11) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..5bd1dae --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,22 @@ +[versions] +# libraries +annotations = "24.0.1" + +# plugins +dokka = "1.8.10" +kotlin = "1.8.10" +changelog = "2.0.0" +gradleIntelliJPlugin = "1.13.3" +qodana = "0.1.13" +kover = "0.6.1" + +[libraries] +annotations = { group = "org.jetbrains", name = "annotations", version.ref = "annotations" } + +[plugins] +changelog = { id = "org.jetbrains.changelog", version.ref = "changelog" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +gradleIntelliJPlugin = { id = "org.jetbrains.intellij", version.ref = "gradleIntelliJPlugin" } +kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } +qodana = { id = "org.jetbrains.qodana", version.ref = "qodana" }