Skip to content

Commit

Permalink
switch to kotlinter gradle plugin over spotless (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToppleTheNun authored Nov 30, 2022
1 parent 9743e61 commit 1553872
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 35 deletions.
14 changes: 2 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
`maven-publish`
id("com.diffplug.spotless")
id("org.jmailen.kotlinter")
id("io.gitlab.arturbosch.detekt")
id("org.jetbrains.dokka")
id("com.gradle.plugin-publish")
Expand Down Expand Up @@ -83,16 +83,6 @@ pluginBundle {
tags = listOf("kotlin", "pixeloutlaw", "convention")
}

spotless {
ratchetFrom("origin/main")
kotlin {
ktlint("0.47.1")
}
kotlinGradle {
ktlint("0.47.1")
}
}

tasks {
// get dokkaJavadoc task and make javadocJar depend on it
val dokkaJavadoc by this
Expand Down Expand Up @@ -142,7 +132,7 @@ dependencies {
implementation("io.gitlab.arturbosch.detekt:detekt-gradle-plugin:_")

// ktlint plugin
implementation("com.diffplug.spotless:spotless-plugin-gradle:_")
implementation("org.jmailen.gradle:kotlinter-gradle:_")

// gradle nexus publish plugin
implementation("io.github.gradle-nexus:publish-plugin:_")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package dev.mythicdrops.gradle.conventions

import com.diffplug.gradle.spotless.SpotlessExtension
import com.diffplug.gradle.spotless.SpotlessPlugin
import io.gitlab.arturbosch.detekt.DetektPlugin
import org.gradle.api.Project
import org.gradle.api.tasks.bundling.Jar
Expand All @@ -14,6 +12,10 @@ import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.file.File
import org.jmailen.gradle.kotlinter.KotlinterPlugin
import org.jmailen.gradle.kotlinter.tasks.FormatTask
import org.jmailen.gradle.kotlinter.tasks.LintTask

/**
* Plugin that configures Kotlin for JDK 16, enables Detekt, and enables/configures KTLint to use 0.46.0.
Expand All @@ -25,7 +27,7 @@ open class MythicDropsKotlinJvmPlugin : DependentPlugin("Kotlin JVM", "org.jetbr
// apply plugins
target.pluginManager.apply(DetektPlugin::class.java)
target.pluginManager.apply(DokkaPlugin::class.java)
target.pluginManager.apply(SpotlessPlugin::class.java)
target.pluginManager.apply(KotlinterPlugin::class.java)

// configure kotlin to use JDK 16
target.configure<KotlinJvmProjectExtension> {
Expand All @@ -34,23 +36,12 @@ open class MythicDropsKotlinJvmPlugin : DependentPlugin("Kotlin JVM", "org.jetbr
}
}

// set ktlint version to 0.47.1
target.configure<SpotlessExtension> {
ratchetFrom("origin/main")
kotlin {
ktlint("0.47.1")
target(
target.fileTree(target.projectDir) {
include("**/*.kt")
exclude("**/build/generated/**")
exclude("**/build/kspCaches/**")
exclude("**/build/generated-sources/**")
}
)
}
kotlinGradle {
ktlint("0.47.1")
}
// exclude files from the build directory from being linted or formatted
target.tasks.withType<FormatTask> {
exclude { fte -> fte.file.absolutePath.contains("${File.separator}build${File.separator}") }
}
target.tasks.withType<LintTask> {
exclude { fte -> fte.file.absolutePath.contains("${File.separator}build${File.separator}") }
}

target.tasks.withType<KotlinCompile> {
Expand Down
2 changes: 1 addition & 1 deletion version.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=3.2.*
version=3.3.*
4 changes: 2 additions & 2 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugin.io.gitlab.arturbosch.detekt=1.22.0

plugin.org.jetbrains.dokka=1.7.20

plugin.com.diffplug.spotless=6.12.0
plugin.org.jmailen.kotlinter=3.12.0

plugin.org.shipkit.shipkit-auto-version=1.2.2

Expand All @@ -37,7 +37,7 @@ version.com.netflix.nebula..nebula-project-plugin=10.0.1

version.io.gitlab.arturbosch.detekt..detekt-gradle-plugin=1.22.0

version.com.diffplug.spotless..spotless-plugin-gradle=6.12.0
version.org.jmailen.gradle..kotlinter-gradle=3.12.0

version.io.github.gradle-nexus..publish-plugin=1.1.0

Expand Down

0 comments on commit 1553872

Please sign in to comment.