Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ktlint to 1.0.0 🎉 #110

Merged
merged 2 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ plugins {

| plugin version | min gradle version | min ktlint version |
|----------------|--------------------|--------------------|
| 0.5.0+ | 7.6 | 1.0.0 |
| 0.4.0+ | 7.6 | 0.50.0 |
| 0.3.0+ | 7.6 | 0.49.0 |
| 0.1.0+ | 7.6 | 0.48.0 |
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ gradle-doctor = "0.8.1"
google-agp = "8.1.1"
maven-junit = "5.10.0"
maven-assertj = "3.24.2"
maven-ktlint = "0.50.0"
maven-ktlint = "1.0.0"
maven-commons = "2.13.0"

[libraries]
agp-gradle = { module = "com.android.tools.build:gradle", version.ref = "google-agp" }
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin" }
ktlint-rule-engine = { module = "com.pinterest.ktlint:ktlint-rule-engine", version.ref = "maven-ktlint" }
ktlint-cli-ruleset-core = { module = "com.pinterest.ktlint:ktlint-cli-ruleset-core", version.ref = "maven-ktlint" }
ktlint-cli-reporter = { module = "com.pinterest.ktlint:ktlint-cli-reporter", version.ref = "maven-ktlint" }
ktlint-reporter-baseline = { module = "com.pinterest.ktlint:ktlint-reporter-baseline", version.ref = "maven-ktlint" }
ktlint-cli-reporter-core = { module = "com.pinterest.ktlint:ktlint-cli-reporter-core", version.ref = "maven-ktlint" }
ktlint-cli-reporter-baseline = { module = "com.pinterest.ktlint:ktlint-cli-reporter-baseline", version.ref = "maven-ktlint" }
junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "maven-junit" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "maven-junit" }
assertj-core = { module = "org.assertj:assertj-core", version.ref = "maven-assertj" }
Expand Down
4 changes: 2 additions & 2 deletions ktlint-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ dependencies {
compileOnly(libs.agp.gradle)
compileOnly(libs.ktlint.rule.engine)
compileOnly(libs.ktlint.cli.ruleset.core)
compileOnly(libs.ktlint.cli.reporter)
compileOnly(libs.ktlint.reporter.baseline)
compileOnly(libs.ktlint.cli.reporter.core)
compileOnly(libs.ktlint.cli.reporter.baseline)

testRuntimeOnly(libs.junit.jupiter.engine)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@ public class KtlintGradlePlugin : Plugin<Project> {

val dependencyProvider = provider {
val ktlintVersion = pluginExtension.ktlintVersion.get()
[email protected]("com.pinterest:ktlint:$ktlintVersion")
val ktlintDependency = if (ktlintVersion.startsWith("0.")) {
"com.pinterest:ktlint:$ktlintVersion"
} else {
"com.pinterest.ktlint:ktlint-cli:$ktlintVersion"
}
[email protected](ktlintDependency)
}

dependencies.addLater(dependencyProvider)
Expand Down Expand Up @@ -141,4 +146,4 @@ public class KtlintGradlePlugin : Plugin<Project> {
internal val String.id: String
get() = split(" ").first()

internal fun Project.reportFile(name: String): File = file("$buildDir/reports/ktlint/$name")
internal fun Project.reportFile(name: String): File = file("${layout.buildDirectory.get()}/reports/ktlint/$name")
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class BaselineTest : WithGradleTest.Kotlin() {
</file>
<file name="src/main/kotlin/CustomClass.kt">
<error line="2" column="21" source="standard:curly-spacing" />
<error line="2" column="21" source="standard:function-signature" />
</file>
</baseline>

Expand All @@ -103,6 +104,7 @@ class BaselineTest : WithGradleTest.Kotlin() {
}
buildAndFail("lintKotlin").apply {
assertThat(output).contains("CustomClass.kt:2:22: Lint error > [standard:no-multi-spaces]")
assertThat(output).contains("CustomClass.kt:2:23: Lint error > [standard:function-signature]")
}

projectRoot.resolve("config/baseline.xml") {
Expand All @@ -116,6 +118,7 @@ class BaselineTest : WithGradleTest.Kotlin() {
</file>
<file name="src/main/kotlin/CustomClass.kt">
<error line="2" column="22" source="standard:no-multi-spaces" />
<error line="2" column="23" source="standard:function-signature" />
</file>
</baseline>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.assertj.core.api.Assertions.assertThat
import org.gradle.internal.impldep.org.bouncycastle.asn1.x500.style.RFC4519Style.name
import org.gradle.testkit.runner.TaskOutcome
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import java.io.File

Expand Down Expand Up @@ -101,6 +102,7 @@ internal class KotlinProjectTest : WithGradleTest.Kotlin() {
}

@Test
@Disabled("I'm not aware of any experimental rule")
fun `lintKotlin succeeds when experimental rules are not enabled and code contains experimental rules violations`() {
settingsFile()
buildFile()
Expand Down
2 changes: 1 addition & 1 deletion test-project-android/custom-ktlint-rules/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ plugins {
}

dependencies {
compileOnly("com.pinterest.ktlint:ktlint-cli-ruleset-core:0.50.0")
compileOnly("com.pinterest.ktlint:ktlint-cli-ruleset-core:1.0.0")
}
Loading