Skip to content

google-java-format: Reflow long strings does not give same output #2338

Open
@blacksails

Description

The following input

public class Test {
    private String longString = "asdf asdf asdf asdf asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa";
}

Becomes

public class Test {
    private String longString =
            "asdf asdf asdf asdf"
                + " asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa";
}

Using google-java-format AOSP

When using the gradle task ./gradlew spotlessApply this becomes

public class Test {
    private String longString =
            "asdf asdf asdf asdf"
                    + " asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfa";
}

Gradle version: 8.10.2
Spotless version: 6.25.0 and 7.0.0.BETA4 (same result)
Operating system: macOS 15.0.1

Spotless config:

extensions.configure<com.diffplug.gradle.spotless.SpotlessExtension> {
    java {
        googleJavaFormat("1.24.0").aosp().reorderImports(true)
    }
}

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions