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

Adding a space before a comment makes method chaining appear as multi-line in Gradle #517

Open
robifr opened this issue Sep 23, 2024 · 0 comments

Comments

@robifr
Copy link

robifr commented Sep 23, 2024

Adding a comment with a single space (the space is important) at the end of a method chain in a Gradle build script will cause the code to be incorrectly formatted, making it appear as multi-line or folded instead of staying on one line.

Expected behavior:
Place this code at the very end of build.gradle.kts. Even an empty file containing only this code can reproduce the bug.

tasks.named("preBuild").dependsOn("test")

//


Actual behavior:
Inside build.gradle.kts

tasks
    .named("preBuild")
    .dependsOn(
        "test")

// Removing this comment will make the formatting work as expected.


I tested this on an Android project using Spotless with Gradle.

My root build.gradle.kts

allprojects {
  apply<SpotlessPlugin>()
  extensions.configure<SpotlessExtension> {
    kotlinGradle {
      target("*.gradle.kts")
      ktfmt()
    }  
    ...
}
$ ./gradlew spotlessApply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant