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 #750
  • Loading branch information
m-burst authored and wakingrufus committed Apr 4, 2024
1 parent d29b339 commit ca43270
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 ca43270

Please sign in to comment.