diff --git a/build.gradle b/build.gradle index 330a13f452..c5b5a0eb33 100644 --- a/build.gradle +++ b/build.gradle @@ -1,37 +1,11 @@ plugins { id 'org.jetbrains.kotlin.jvm' apply false - id 'com.github.breadmoirai.github-release' + alias(libs.plugins.checksum) + alias(libs.plugins.shadow) + alias(libs.plugins.githubRelease) // id 'nebula.lint' version '17.5.0' } -ext.versions = [ - 'gradle': '7.4', - 'gradle-sha256': '8cc27038d5dbd815759851ba53e70cf62e481b87494cc97cfd97982ada5ba634' -] - -ext.deps = [ - 'kotlin' : [ - 'compiler': "org.jetbrains.kotlin:kotlin-compiler-embeddable" - ], - 'klob' : 'com.github.shyiko.klob:klob:0.2.1', - ec4j : 'org.ec4j.core:ec4j-core:0.3.0', - 'picocli' : 'info.picocli:picocli:3.9.6', - 'logging' : 'io.github.microutils:kotlin-logging-jvm:2.1.21', - // Use logback-classic as the logger for kotlin-logging / slf4j as it allow changing the log level at runtime. - 'logback' : 'ch.qos.logback:logback-classic:1.2.9', - // Required for logback.xml conditional configuration - 'janino' : 'org.codehaus.janino:janino:3.1.4', - // Testing libraries - 'junit5' : 'org.junit.jupiter:junit-jupiter:5.8.2', - 'assertj' : 'org.assertj:assertj-core:3.12.2', - 'sarif4k' : 'io.github.detekt.sarif4k:sarif4k:0.0.1', - 'jimfs' : 'com.google.jimfs:jimfs:1.1' -] - -repositories { - mavenCentral() -} - def isKotlinDev = project.hasProperty('isKotlinDev') allprojects { p -> @@ -137,7 +111,7 @@ tasks.register("publishNewRelease", DefaultTask.class) { } tasks.withType(Wrapper).configureEach { - gradleVersion = versions.'gradle' - distributionSha256Sum = versions.'gradle-sha256' + gradleVersion = libs.versions.gradle + distributionSha256Sum = libs.versions.gradleSha256 distributionType = Wrapper.DistributionType.BIN } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000000..7883080347 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,26 @@ +[versions] +gradle = "7.4" +gradleSha256 = "8cc27038d5dbd815759851ba53e70cf62e481b87494cc97cfd97982ada5ba634" +kotlin = "1.6.0" + +[plugins] +kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +githubRelease = "com.github.breadmoirai.github-release:2.2.12" +checksum = "org.gradle.crypto.checksum:1.1.0" +shadow = "com.github.johnrengelman.shadow:7.1.1" + +[libraries] +kotlin-compiler = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable", version.ref = "kotlin" } +klob = "com.github.shyiko.klob:klob:0.2.1" +ec4j = "org.ec4j.core:ec4j-core:0.3.0" +picocli = "info.picocli:picocli:3.9.6" +logging = "io.github.microutils:kotlin-logging-jvm:2.1.21" +# Use logback-classic as the logger for kotlin-logging / slf4j as it allow changing the log level at runtime. +logback = "ch.qos.logback:logback-classic:1.2.9" +# Required for logback.xml conditional configuration +janino = "org.codehaus.janino:janino:3.1.4" +# Testing libraries +junit5 = "org.junit.jupiter:junit-jupiter:5.8.2" +assertj = "org.assertj:assertj-core:3.12.2" +sarif4k = "io.github.detekt.sarif4k:sarif4k:0.0.1" +jimfs = "com.google.jimfs:jimfs:1.1" diff --git a/ktlint-core/build.gradle b/ktlint-core/build.gradle index 23c5e3e010..81528b6f7e 100644 --- a/ktlint-core/build.gradle +++ b/ktlint-core/build.gradle @@ -4,14 +4,14 @@ plugins { } dependencies { - api deps.kotlin.compiler - api deps.ec4j - api deps.logging + api libs.kotlin.compiler + api libs.ec4j + api libs.logging // Standard ruleset is required for EditConfigLoaderTest only testImplementation projects.ktlintRulesetStandard testImplementation projects.ktlintTestLogging - testImplementation deps.junit5 - testImplementation deps.assertj - testImplementation deps.jimfs + testImplementation libs.junit5 + testImplementation libs.assertj + testImplementation libs.jimfs } diff --git a/ktlint-reporter-baseline/build.gradle b/ktlint-reporter-baseline/build.gradle index d1e9344399..5c575f4041 100644 --- a/ktlint-reporter-baseline/build.gradle +++ b/ktlint-reporter-baseline/build.gradle @@ -6,6 +6,6 @@ plugins { dependencies { implementation projects.ktlintCore - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-reporter-checkstyle/build.gradle b/ktlint-reporter-checkstyle/build.gradle index 63a8422661..8883fdd43a 100644 --- a/ktlint-reporter-checkstyle/build.gradle +++ b/ktlint-reporter-checkstyle/build.gradle @@ -6,6 +6,6 @@ plugins { dependencies { implementation projects.ktlintCore - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-reporter-html/build.gradle b/ktlint-reporter-html/build.gradle index 63a8422661..8883fdd43a 100644 --- a/ktlint-reporter-html/build.gradle +++ b/ktlint-reporter-html/build.gradle @@ -6,6 +6,6 @@ plugins { dependencies { implementation projects.ktlintCore - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-reporter-json/build.gradle b/ktlint-reporter-json/build.gradle index 63a8422661..8883fdd43a 100644 --- a/ktlint-reporter-json/build.gradle +++ b/ktlint-reporter-json/build.gradle @@ -6,6 +6,6 @@ plugins { dependencies { implementation projects.ktlintCore - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-reporter-plain/build.gradle b/ktlint-reporter-plain/build.gradle index 63a8422661..8883fdd43a 100644 --- a/ktlint-reporter-plain/build.gradle +++ b/ktlint-reporter-plain/build.gradle @@ -6,6 +6,6 @@ plugins { dependencies { implementation projects.ktlintCore - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-reporter-sarif/build.gradle b/ktlint-reporter-sarif/build.gradle index c8fe167c68..5623d03200 100644 --- a/ktlint-reporter-sarif/build.gradle +++ b/ktlint-reporter-sarif/build.gradle @@ -4,11 +4,11 @@ plugins { } dependencies { - implementation projects.ktlintCore - implementation deps.sarif4k + implementation projects.ktlintCore + implementation libs.sarif4k - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } jar { diff --git a/ktlint-ruleset-experimental/build.gradle b/ktlint-ruleset-experimental/build.gradle index 7853927160..348f7be512 100644 --- a/ktlint-ruleset-experimental/build.gradle +++ b/ktlint-ruleset-experimental/build.gradle @@ -8,6 +8,6 @@ dependencies { testImplementation projects.ktlintTest testImplementation projects.ktlintRulesetStandard - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-ruleset-standard/build.gradle b/ktlint-ruleset-standard/build.gradle index 970cc0d94b..957e3d80d7 100644 --- a/ktlint-ruleset-standard/build.gradle +++ b/ktlint-ruleset-standard/build.gradle @@ -5,9 +5,9 @@ plugins { dependencies { implementation projects.ktlintCore - implementation deps.logging + implementation libs.logging testImplementation projects.ktlintTest - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } diff --git a/ktlint-ruleset-template/build.gradle b/ktlint-ruleset-template/build.gradle index 761d7bc7d4..5dc1fc4478 100644 --- a/ktlint-ruleset-template/build.gradle +++ b/ktlint-ruleset-template/build.gradle @@ -32,16 +32,16 @@ dependencies { testImplementation projects.ktlintCore testImplementation projects.ktlintTest - testImplementation deps.junit5 - testImplementation deps.assertj + testImplementation libs.junit5 + testImplementation libs.assertj } test { useJUnitPlatform() } -task ktlint(type: JavaExec, dependsOn: classes) { - main = 'com.pinterest.ktlint.Main' +task ktlint(type: JavaExec, dependsOn: classes, group: LifecycleBasePlugin.VERIFICATION_GROUP) { + mainClass.set("com.pinterest.ktlint.Main") // adding compiled classes to the classpath so that ktlint would validate project's sources // using its own ruleset (in other words to dogfood) classpath = configurations.ktlint + sourceSets.main.output diff --git a/ktlint-test-logging/build.gradle b/ktlint-test-logging/build.gradle index ac1297a346..da96c4541e 100644 --- a/ktlint-test-logging/build.gradle +++ b/ktlint-test-logging/build.gradle @@ -4,6 +4,6 @@ plugins { } dependencies { - api deps.logback - api deps.janino + api libs.logback + api libs.janino } diff --git a/ktlint-test/build.gradle b/ktlint-test/build.gradle index 84f888f74e..a1b42484d0 100644 --- a/ktlint-test/build.gradle +++ b/ktlint-test/build.gradle @@ -8,6 +8,6 @@ dependencies { api projects.ktlintRulesetTest api projects.ktlintTestLogging - implementation deps.junit5 - implementation deps.assertj + implementation libs.junit5 + implementation libs.assertj } diff --git a/ktlint/build.gradle b/ktlint/build.gradle index cd9fe89812..5017b33046 100644 --- a/ktlint/build.gradle +++ b/ktlint/build.gradle @@ -3,8 +3,8 @@ import org.gradle.crypto.checksum.Checksum plugins { id 'ktlint-publication' id 'ktlint-kotlin-common' - id 'com.github.johnrengelman.shadow' - id 'org.gradle.crypto.checksum' + alias(libs.plugins.shadow) + alias(libs.plugins.checksum) id 'signing' } @@ -30,15 +30,15 @@ dependencies { implementation projects.ktlintRulesetExperimental implementation projects.ktlintRulesetStandard implementation projects.ktlintRulesetTest - implementation deps.kotlin.compiler - implementation deps.klob - implementation deps.picocli - implementation deps.logback + implementation libs.kotlin.compiler + implementation libs.klob + implementation libs.picocli + implementation libs.logback - testImplementation deps.junit5 - testImplementation deps.assertj - testImplementation deps.jimfs + testImplementation libs.junit5 + testImplementation libs.assertj + testImplementation libs.jimfs } // Implements https://github.com/brianm/really-executable-jars-maven-plugin maven plugin behaviour. diff --git a/settings.gradle b/settings.gradle index ae67e01f94..60448ba4f6 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,11 +3,11 @@ pluginManagement { mavenCentral() gradlePluginPortal() } +} - plugins { - id 'com.github.breadmoirai.github-release' version '2.2.12' - id 'com.github.johnrengelman.shadow' version '7.1.1' - id 'org.gradle.crypto.checksum' version '1.1.0' +dependencyResolutionManagement { + repositories { + mavenCentral() } }