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

Fix additionalEditorconfig property not being accounted for up-to-date checks and caching #758

Merged
merged 2 commits into from
Apr 4, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

- fix [#544](https://github.com/JLLeitschuh/ktlint-gradle/issues/544): make git filter work
with any os [#738](https://github.com/JLLeitschuh/ktlint-gradle/pull/738)
- fix [#750](https://github.com/JLLeitschuh/ktlint-gradle/issues/750): additionalEditorconfig property not being
accounted for up-to-date checks and caching [#758](https://github.com/JLLeitschuh/ktlint-gradle/pull/758)

## [12.1.0] - 2024-01-09

Expand Down
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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made sure that the test fails if val additionalEditorconfig is @Internal before changing it to @Input

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()
)
}
}
Loading