Skip to content

Commit

Permalink
Enable version catalogs (pinterest#1428)
Browse files Browse the repository at this point in the history
* Enable version catalogs
* Move repo into settings.gradle
* Correct ktlint task in ruleset-template
  • Loading branch information
Goooler authored Apr 7, 2022
1 parent 0034335 commit c426471
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 77 deletions.
36 changes: 5 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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 ->
Expand Down Expand Up @@ -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
}
26 changes: 26 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 6 additions & 6 deletions ktlint-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions ktlint-reporter-baseline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plugins {
dependencies {
implementation projects.ktlintCore

testImplementation deps.junit5
testImplementation deps.assertj
testImplementation libs.junit5
testImplementation libs.assertj
}
4 changes: 2 additions & 2 deletions ktlint-reporter-checkstyle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plugins {
dependencies {
implementation projects.ktlintCore

testImplementation deps.junit5
testImplementation deps.assertj
testImplementation libs.junit5
testImplementation libs.assertj
}
4 changes: 2 additions & 2 deletions ktlint-reporter-html/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plugins {
dependencies {
implementation projects.ktlintCore

testImplementation deps.junit5
testImplementation deps.assertj
testImplementation libs.junit5
testImplementation libs.assertj
}
4 changes: 2 additions & 2 deletions ktlint-reporter-json/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plugins {
dependencies {
implementation projects.ktlintCore

testImplementation deps.junit5
testImplementation deps.assertj
testImplementation libs.junit5
testImplementation libs.assertj
}
4 changes: 2 additions & 2 deletions ktlint-reporter-plain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ plugins {
dependencies {
implementation projects.ktlintCore

testImplementation deps.junit5
testImplementation deps.assertj
testImplementation libs.junit5
testImplementation libs.assertj
}
8 changes: 4 additions & 4 deletions ktlint-reporter-sarif/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions ktlint-ruleset-experimental/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ dependencies {

testImplementation projects.ktlintTest
testImplementation projects.ktlintRulesetStandard
testImplementation deps.junit5
testImplementation deps.assertj
testImplementation libs.junit5
testImplementation libs.assertj
}
6 changes: 3 additions & 3 deletions ktlint-ruleset-standard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 4 additions & 4 deletions ktlint-ruleset-template/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions ktlint-test-logging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ plugins {
}

dependencies {
api deps.logback
api deps.janino
api libs.logback
api libs.janino
}
4 changes: 2 additions & 2 deletions ktlint-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ dependencies {
api projects.ktlintRulesetTest
api projects.ktlintTestLogging

implementation deps.junit5
implementation deps.assertj
implementation libs.junit5
implementation libs.assertj
}
18 changes: 9 additions & 9 deletions ktlint/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand All @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down

0 comments on commit c426471

Please sign in to comment.