Gradle version catalog integration

This commit is contained in:
Jakub Chrzanowski 2023-04-04 17:17:47 +02:00 committed by Jakub Chrzanowski
parent 6e4a928bbe
commit 86b921946c
4 changed files with 57 additions and 12 deletions

View File

@ -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`

View File

@ -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

View File

@ -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)

22
gradle/libs.versions.toml Normal file
View File

@ -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" }