The Wayback Machine - https://web.archive.org/web/20250810204344/https://github.com/diffplug/spotless/issues/875
Skip to content

2 empty lines on java google import #875

@clembo590

Description

@clembo590

Spotless maven plugin, does not format the import section correctly: it adds an empty line.

  • [ 2.11.1] gradle or maven version
  • [mac os ] operating system and version

I have created a github repo that is formatted with the google 1.10.0 formatter to reproduce/show the issue.
This is the command line I used to format the code in the repo. (which has nothing to do with spotless)

java --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -jar /PATH_TO_YOUR_GOOGLE_JAR/google-java-format-1.10.0-all-deps.jar -r $(git ls-files|grep .java$)

this is the url of my repo: (and the code is formatted by the google-java-format-1.10.0-all-deps.jar)
https://github.com/clembo590/issue_spotless.git

if you git clone the repo and then run

mvn com.diffplug.spotless:spotless-maven-plugin:2.11.1:apply

An additional line is added at the top of the file.

Is this a bug ? is there any configuration of the plugin that will produce the exact same result as the real google-java-format-1.10.0-all-deps.jar ?

Screenshot 2021-06-08 at 07 23 30

Metadata

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