Skip to content

Commit

Permalink
Fix additionalEditorconfig property not being accounted for up-to-dat…
Browse files Browse the repository at this point in the history
…e checks and caching

Fixes JLLeitschuh#750
  • Loading branch information
m-burst committed Apr 2, 2024
1 parent d29b339 commit cc97a6e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract class BaseKtLintCheckTask @Inject constructor(
@get:Internal
internal abstract val additionalEditorconfigFile: RegularFileProperty

@get:Internal
@get:Input
internal abstract val additionalEditorconfig: MapProperty<String, String>

@get:Incremental
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ class EditorConfigTests : AbstractPluginTest() {
}
}

@DisplayName("Check task should rerun if additionalEditorconfig property changes")
@CommonTest
fun checkRerunOnAdditionalEditorconfigPropertyChange(gradleVersion: GradleVersion) {
project(gradleVersion) {
withAdditionalEditorconfigProperty(120)
withCleanSources()

build(CHECK_PARENT_TASK_NAME) {
assertThat(task(":$lintTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
}

withAdditionalEditorconfigProperty(10)

buildAndFail(CHECK_PARENT_TASK_NAME) {
assertThat(task(":$lintTaskName")?.outcome).isEqualTo(TaskOutcome.SUCCESS)
assertThat(task(":$mainSourceSetCheckTaskName")?.outcome).isEqualTo(TaskOutcome.FAILED)
}
}
}

private fun TestProject.createEditorconfigFile(
maxLineLength: Int = 120,
filePath: String = ""
Expand All @@ -168,4 +188,18 @@ class EditorConfigTests : AbstractPluginTest() {
}
createEditorconfigFile(maxLineLength)
}

private fun TestProject.withAdditionalEditorconfigProperty(
maxLineLength: Int
) {
//language=Groovy
buildGradle.appendText(
"""
ktlint {
additionalEditorconfig["max_line_length"] = "$maxLineLength"
}
""".trimIndent()
)
}
}

0 comments on commit cc97a6e

Please sign in to comment.