diff --git a/build-logic/build.gradle.kts b/build-logic/build.gradle.kts index f9f52af1e7..10155ed965 100644 --- a/build-logic/build.gradle.kts +++ b/build-logic/build.gradle.kts @@ -12,6 +12,7 @@ dependencies { implementation(libs.dokka.gradlePlugin) implementation(libs.develocity) implementation(libs.gradleDoctor) + implementation(libs.kotlinter) // A hack to make version catalogs accessible from buildSrc sources // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 diff --git a/build-logic/src/main/kotlin/ktorbuild.codestyle.gradle.kts b/build-logic/src/main/kotlin/ktorbuild.codestyle.gradle.kts new file mode 100644 index 0000000000..ba083467a3 --- /dev/null +++ b/build-logic/src/main/kotlin/ktorbuild.codestyle.gradle.kts @@ -0,0 +1,15 @@ +/* + * Copyright 2014-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +import ktorbuild.internal.ktorBuild + +plugins { + id("org.jmailen.kotlinter") +} + +kotlinter { + // Don't fail lint tasks on CI as we don't want TeamCity to show a build failure in addition to an actual lint report + ignoreLintFailures = ktorBuild.isCI.get() + reporters = arrayOf("checkstyle", "plain") +} diff --git a/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts b/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts index 21fdaa0895..3257c37335 100644 --- a/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts +++ b/build-logic/src/main/kotlin/ktorbuild.kmp.gradle.kts @@ -14,6 +14,7 @@ plugins { id("ktorbuild.base") kotlin("multiplatform") id("org.jetbrains.kotlinx.atomicfu") + id("ktorbuild.codestyle") } kotlin { diff --git a/build.gradle.kts b/build.gradle.kts index ffdc0a91a8..f5bef25610 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -52,8 +52,6 @@ subprojects { } else { apply(plugin = "ktorbuild.project.internal") } - - configureCodestyle() } println("Using Kotlin compiler version: ${libs.versions.kotlin.get()}") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7678470ae4..a18b88dd34 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -10,8 +10,6 @@ dependencies { implementation(libs.kotlin.gradlePlugin) implementation(libs.kotlin.serialization) - implementation(libs.kotlinter) - // A hack to make version catalogs accessible from buildSrc sources // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) diff --git a/buildSrc/src/main/kotlin/Codestyle.kt b/buildSrc/src/main/kotlin/Codestyle.kt deleted file mode 100644 index 663b9030dc..0000000000 --- a/buildSrc/src/main/kotlin/Codestyle.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2014-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. - */ -import org.gradle.api.* -import org.gradle.api.tasks.* -import org.gradle.kotlin.dsl.* -import org.jmailen.gradle.kotlinter.tasks.* - -fun Project.configureCodestyle() { - apply(plugin = "org.jmailen.kotlinter") - - kotlinter.apply { - ignoreLintFailures = true - reporters = arrayOf("checkstyle", "plain") - } - - val editorconfigFile = rootProject.file(".editorconfig") - tasks.withType().configureEach { - inputs.file(editorconfigFile).withPathSensitivity(PathSensitivity.RELATIVE) - } -} diff --git a/buildSrc/src/main/kotlin/KotlinExtensions.kt b/buildSrc/src/main/kotlin/KotlinExtensions.kt index f88a4535d6..93e56ee5d9 100644 --- a/buildSrc/src/main/kotlin/KotlinExtensions.kt +++ b/buildSrc/src/main/kotlin/KotlinExtensions.kt @@ -7,7 +7,6 @@ import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.the import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -import org.jmailen.gradle.kotlinter.KotlinterExtension fun Project.kotlin(block: KotlinMultiplatformExtension.() -> Unit) { configure(block) @@ -15,8 +14,6 @@ fun Project.kotlin(block: KotlinMultiplatformExtension.() -> Unit) { val Project.kotlin: KotlinMultiplatformExtension get() = the() -val Project.kotlinter: KotlinterExtension get() = the() - fun NamedDomainObjectContainer.commonMain(block: KotlinSourceSet.() -> Unit) { val sourceSet = getByName("commonMain") block(sourceSet)