Skip to content

Update 'google-java-format' 1.7 -> 1.9 #64

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

Closed
zziga opened this issue Nov 21, 2020 · 0 comments · Fixed by zziga/git-code-format-maven-plugin#2 or #66
Closed

Update 'google-java-format' 1.7 -> 1.9 #64

zziga opened this issue Nov 21, 2020 · 0 comments · Fixed by zziga/git-code-format-maven-plugin#2 or #66

Comments

@zziga
Copy link
Contributor

zziga commented Nov 21, 2020

What steps will reproduce the problem?
Steps to reproduce the behavior:

  1. mvn git-code-format:format-code; git add . ; git commit -m"Apply code format"
  2. mvn spotless:apply // to test reformat

What is the expected output?
No changes.

$ git status
> ... nothing to commit, working tree clean

What happens instead?
Code got reformatted.

$ git status
> ... modified: Foo.java

Environment:

  • OS: macOS 11.0.1
  • Git version: 2.28.0
  • git-code-format-maven-plugin version: 2.7
  • Maven version: 3.6.3
  • Java version: 11

Here's plugins configuration:

<project>
<build>
<plugins>
...
<plugin>
  <groupId>com.cosium.code</groupId>
  <artifactId>git-code-format-maven-plugin</artifactId>
  <version>2.7</version>
</plugin>
<plugin>
  <groupId>com.diffplug.spotless</groupId>
  <artifactId>spotless-maven-plugin</artifactId>
  <version>2.6.0</version>
  <configuration>
    <java>
      <googleJavaFormat/>
    </java>
  </configuration>
</plugin>
...

Link to a git repository that can be cloned to reproduce the problem:
Private repository, but if I'll manage to replicate it on a public repo, I'll add it in here.

Additional context
Being up to date with latest google-java-format version, saves clarifications when google-java-format IDE plugins or other formatting plugins 'change' formatting.

There is a formatting change around stram() which changed in google-java-format 1.8.

    // google-java-format 1.7
    xxx xxx =
        xxx.xxx().xxx().xxx()
            .stream()
            .xxx()
            .xxx();

    // google-java-format 1.8 and 1.9
    xxx xxx =
        xxx
            .xxx()
            .xxx()
            .xxx()
            .stream()
            .xxx()
            .xxx();

For a test, I've upgraded google-java-format version (https://github.com/Cosium/git-code-format-maven-plugin/blob/master/pom.xml#L43) to 1.8 and 1.9 and reformatted with snapshot build of git-code-format-maven-plugin and got same format as with the other plugin (spotless uses 1.9).

Note that google-java-format requires JDK 11 at runtime.

zziga added a commit to zziga/git-code-format-maven-plugin that referenced this issue Dec 5, 2020
zziga added a commit to zziga/git-code-format-maven-plugin that referenced this issue Dec 5, 2020
@reda-alaoui reda-alaoui reopened this Dec 5, 2020
zziga added a commit to zziga/git-code-format-maven-plugin that referenced this issue Dec 14, 2020
- bump major version to 3.x
- add 'Breaking changes section 2.x to 3.x' to README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants