From fe44f089940141f599369aca9a0b9fa33ecdd427 Mon Sep 17 00:00:00 2001 From: Felipe Zorzo Date: Tue, 16 Jul 2024 13:22:43 -0300 Subject: [PATCH] chore: Move dependencies to version catalog --- build.gradle.kts | 18 ++++----- buildSrc/src/main/kotlin/Dependencies.kt | 28 ------------- gradle/libs.versions.toml | 51 ++++++++++++++++++++++++ sonar-zpa-plugin/build.gradle.kts | 20 +++++----- zpa-checks/build.gradle.kts | 10 ++--- zpa-core/build.gradle.kts | 6 +-- zpa-toolkit/build.gradle.kts | 8 ++-- 7 files changed, 82 insertions(+), 59 deletions(-) delete mode 100644 buildSrc/src/main/kotlin/Dependencies.kt create mode 100644 gradle/libs.versions.toml diff --git a/build.gradle.kts b/build.gradle.kts index 62f6ffea..a8f84ef6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,11 +8,11 @@ plugins { `maven-publish` signing jacoco - kotlin("jvm") version "2.0.0" - id("org.jetbrains.dokka") version ("1.9.20") - id("com.github.hierynomus.license") version "0.16.1" - id("org.sonarqube") version "5.0.0.4638" - id("org.jreleaser") version "1.13.1" + alias(libs.plugins.kotlin.jvm) + alias(libs.plugins.dokka) + alias(libs.plugins.license) + alias(libs.plugins.sonarqube) + alias(libs.plugins.jreleaser) } allprojects { @@ -44,9 +44,9 @@ subprojects { dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) - testImplementation(Libs.assertj) - testImplementation(Libs.mockito) - testImplementation(Libs.mockito_kotlin) + testImplementation(rootProject.libs.assertj) + testImplementation(rootProject.libs.mockito) + testImplementation(rootProject.libs.mockito.kotlin) } configurations { @@ -67,7 +67,7 @@ subprojects { suites { configureEach { if (this is JvmTestSuite) { - useJUnitJupiter(Versions.junit) + useJUnitJupiter(rootProject.libs.versions.junit) } } } diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt deleted file mode 100644 index 3938638a..00000000 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ /dev/null @@ -1,28 +0,0 @@ -object Versions { - const val junit = "5.10.2" - const val assertj = "3.25.3" - const val mockito = "5.12.0" - const val mockito_kotlin = "5.3.1" - const val flr = "1.4.0" - const val jackson = "2.17.1" - const val jsoup = "1.17.2" - const val min_sonarqube = "9.9.0.65466" - const val min_sonarqube_api = "9.14.0.375" - const val sonarqube_orchestrator = "5.0.0.2065" - const val woodstox = "6.6.2" - - const val plugin_shadow = "8.1.7" -} - -object Libs { - const val assertj = "org.assertj:assertj-core:${Versions.assertj}" - const val mockito = "org.mockito:mockito-core:${Versions.mockito}" - const val mockito_kotlin = "org.mockito.kotlin:mockito-kotlin:${Versions.mockito_kotlin}" - const val flr_core = "com.felipebz.flr:flr-core:${Versions.flr}" - const val flr_xpath = "com.felipebz.flr:flr-xpath:${Versions.flr}" - const val flr_toolkit = "com.felipebz.flr:flr-toolkit:${Versions.flr}" - const val flr_testing_harness = "com.felipebz.flr:flr-testing-harness:${Versions.flr}" - const val jackson = "com.fasterxml.jackson.core:jackson-databind:${Versions.jackson}" - const val jackson_xml = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${Versions.jackson}" - const val woodstox = "com.fasterxml.woodstox:woodstox-core:${Versions.woodstox}" -} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..9339dfbb --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,51 @@ +[versions] +kotlin = "2.0.0" +dokka = "1.9.20" +download = "5.6.0" +jreleaser = "1.13.1" +license = "0.16.1" +shadow = "8.1.7" +sonarscanner = "5.0.0.4638" + +# libs +flatlaf = "3.4.1" +flr = "1.4.0" +jackson = "2.17.1" +jsoup = "1.17.2" +min-sonarqube = "9.9.0.65466" +min-sonarqubeapi = "9.14.0.375" +woodstox = "6.6.2" + +# testing +assertj = "3.25.3" +junit = "5.10.2" +mockito = "5.12.0" +mockito-kotlin = "5.3.1" +sonarqube-orchestrator = "5.0.0.2065" + +[libraries] +assertj = { module = "org.assertj:assertj-core", version.ref = "assertj" } +flatlaf = { module = "com.formdev:flatlaf", version.ref = "flatlaf" } +flr-core = { module = "com.felipebz.flr:flr-core", version.ref = "flr" } +flr-testing-harness = { module = "com.felipebz.flr:flr-testing-harness", version.ref = "flr" } +flr-toolkit = { module = "com.felipebz.flr:flr-toolkit", version.ref = "flr" } +flr-xpath = { module = "com.felipebz.flr:flr-xpath", version.ref = "flr" } +jackson = { module = "com.fasterxml.jackson.core:jackson-databind", version.ref = "jackson" } +jackson-xml = { module = "com.fasterxml.jackson.dataformat:jackson-dataformat-xml", version.ref = "jackson" } +jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" } +mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" } +mockito-kotlin = { module = "org.mockito.kotlin:mockito-kotlin", version.ref = "mockito-kotlin" } +woodstox = { module = "com.fasterxml.woodstox:woodstox-core", version.ref = "woodstox" } +sonar-plugin-api = { module = "org.sonarsource.api.plugin:sonar-plugin-api", version.ref = "min-sonarqubeapi" } +sonar-plugin-api-impl = { module = "org.sonarsource.sonarqube:sonar-plugin-api-impl", version.ref = "min-sonarqube" } +sonar-ws = { module = "org.sonarsource.sonarqube:sonar-ws", version.ref = "min-sonarqube" } +sonar-orchestrator = { module = "org.sonarsource.orchestrator:sonar-orchestrator-junit5", version.ref = "sonarqube-orchestrator" } + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } +download = { id = "de.undercouch.download", version.ref = "download" } +jreleaser = { id = "org.jreleaser", version.ref = "jreleaser" } +license = { id = "com.github.hierynomus.license", version.ref = "license" } +shadow = { id = "io.github.goooler.shadow", version.ref = "shadow" } +sonarqube = { id = "org.sonarqube", version.ref = "sonarscanner" } diff --git a/sonar-zpa-plugin/build.gradle.kts b/sonar-zpa-plugin/build.gradle.kts index 8c9026b5..a43d232f 100644 --- a/sonar-zpa-plugin/build.gradle.kts +++ b/sonar-zpa-plugin/build.gradle.kts @@ -7,18 +7,18 @@ import java.time.format.DateTimeFormatter import java.util.* plugins { - id("io.github.goooler.shadow") version Versions.plugin_shadow + alias(libs.plugins.shadow) } dependencies { - implementation(Libs.flr_core) - implementation(Libs.jackson_xml) - implementation(Libs.woodstox) + implementation(libs.flr.core) + implementation(libs.jackson.xml) + implementation(libs.woodstox) implementation(project(":zpa-core")) implementation(project(":zpa-checks")) implementation(project(":zpa-checks-testkit")) - compileOnly("org.sonarsource.api.plugin:sonar-plugin-api:${Versions.min_sonarqube_api}") - testImplementation("org.sonarsource.sonarqube:sonar-plugin-api-impl:${Versions.min_sonarqube}") + compileOnly(libs.sonar.plugin.api) + compileOnly(libs.sonar.plugin.api.impl) } testing { @@ -27,9 +27,9 @@ testing { testType.set(TestSuiteType.INTEGRATION_TEST) dependencies { - implementation(Libs.assertj) - implementation("org.sonarsource.sonarqube:sonar-ws:${Versions.min_sonarqube}") - implementation("org.sonarsource.orchestrator:sonar-orchestrator-junit5:${Versions.sonarqube_orchestrator}") + implementation(libs.assertj) + implementation(libs.sonar.ws) + implementation(libs.sonar.orchestrator) } targets { @@ -78,7 +78,7 @@ val shadowJar = tasks.named("shadowJar") { "Plugin-OrganizationUrl" to "https://felipezorzo.com.br", "Plugin-SourcesUrl" to "https://github.com/felipebz/zpa", "Plugin-Version" to project.version, - "Sonar-Version" to Versions.min_sonarqube, + "Sonar-Version" to libs.versions.min.sonarqube, "SonarLint-Supported" to "false", "Plugin-RequiredForLanguages" to "plsqlopen" )) diff --git a/zpa-checks/build.gradle.kts b/zpa-checks/build.gradle.kts index bf281a99..10a7f53b 100644 --- a/zpa-checks/build.gradle.kts +++ b/zpa-checks/build.gradle.kts @@ -1,12 +1,12 @@ import de.undercouch.gradle.tasks.download.Download plugins { - id("de.undercouch.download") version "5.6.0" + alias(libs.plugins.download) } dependencies { - implementation(Libs.flr_core) - implementation(Libs.flr_xpath) + implementation(libs.flr.core) + implementation(libs.flr.xpath) implementation(project(":zpa-core")) testImplementation(project(":zpa-checks-testkit")) } @@ -36,9 +36,9 @@ testing { dependencies { implementation(layout.projectDirectory.dir("tools/sqlcl/lib").asFileTree) implementation(project()) - implementation(Libs.jackson) + implementation(libs.jackson) implementation(project(":zpa-core")) - implementation("org.jsoup:jsoup:${Versions.jsoup}") + implementation(libs.jsoup) } } } diff --git a/zpa-core/build.gradle.kts b/zpa-core/build.gradle.kts index 302e0573..aab45d2c 100644 --- a/zpa-core/build.gradle.kts +++ b/zpa-core/build.gradle.kts @@ -1,7 +1,7 @@ dependencies { - api(Libs.flr_core) - implementation(Libs.jackson) - testImplementation(Libs.flr_testing_harness) + api(libs.flr.core) + implementation(libs.jackson) + testImplementation(libs.flr.testing.harness) } description = "Z PL/SQL Analyzer :: Core" diff --git a/zpa-toolkit/build.gradle.kts b/zpa-toolkit/build.gradle.kts index 6d006fe1..fa8bff39 100644 --- a/zpa-toolkit/build.gradle.kts +++ b/zpa-toolkit/build.gradle.kts @@ -1,13 +1,13 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { - id("io.github.goooler.shadow") version Versions.plugin_shadow + alias(libs.plugins.shadow) } dependencies { - implementation(Libs.flr_xpath) - implementation(Libs.flr_toolkit) - implementation("com.formdev:flatlaf:3.4.1") + implementation(libs.flr.xpath) + implementation(libs.flr.toolkit) + implementation(libs.flatlaf) implementation(project(":zpa-core")) }