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

Java Formatter triggered by Maven #50

Closed
svanteschubert opened this issue Jun 21, 2020 · 5 comments
Closed

Java Formatter triggered by Maven #50

svanteschubert opened this issue Jun 21, 2020 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@svanteschubert
Copy link
Contributor

There is a lot of noise in the Java Sources of different editors doing different formatting. Therefore I would love to stabilize the syntax by a normalized.
Especially, I would like to make the differences between the sources of 0.9.0 and 1.0.0 less noisy.

Remember:
The version 0.9.0 - on the master branch - is basically our Apache (incubator) version. While the 1.0.0 - on the 1_0_0_SHAPSHOT branch - is the result of a painful manual merge of my work on a fork at Open-XChange with the Apache branch and on top the results of my work sponsored by the PrototypeFund.
Therefore, I started today testing with the Google Java Formatter:
https:/google/google-java-format 
In particular, I started with the following Maven plugin:
https:/Cosium/maven-git-code-format
Where I can do manual formatting on the command line via:

mvn git-code-format:format-code -Dgcf.globPattern=**/*

There are a few things I do not like very much on the result:

  1. Changes within the copyright header
  2. The manual formatting breaks with an out of heap error

I committed this example to a feature branch called: 
feature-formatter_variant-1_Cosium/git-code-format-maven-plugin  ;-)

@svanteschubert svanteschubert added enhancement New feature or request help wanted Extra attention is needed labels Jun 21, 2020
@svanteschubert svanteschubert added this to the 0.9 milestone Jun 21, 2020
@svanteschubert
Copy link
Contributor Author

Someone reported already our problem:
google/google-java-format#413

odfdom\src\main\java\org\odftoolkit\odfdom\pkg\OdfManifestSaxHandler.java
is always the last class being processed before memory exception.

@svanteschubert
Copy link
Contributor Author

The class OdfManifestSaxHandler.java was all a single comment.
I removed it for 0.9.0 and the format finishes successfully.
Committed all formatted source files for review purpose on the branch.

Would this suit you?

@svanteschubert svanteschubert added the review wanted Four eyes notice more than two label Jun 21, 2020
@svanteschubert svanteschubert self-assigned this Jun 21, 2020
@sebkur
Copy link
Contributor

sebkur commented Jun 22, 2020

Having a formatting standard for the project sound like a very good idea to me!

Going with the Google Java Style Guide and its tools seems to be a sound choice. There are formatter plugins for all major IDEs (Eclipse and IntelliJ) and also for all major build systems (Maven, Gradle).

@sebkur
Copy link
Contributor

sebkur commented Jun 22, 2020

It's a bit of a pity to apply a reformatting an such a big codebase, but since there has not been any formatting standard in place up to now, I don't really see a way forward without such an action if we want to introduce this at some point. Doing it has the advantage that in the future history and comparison between branches will be a lot easier and cleaner. But it also has the disadvantage of introducing a lot of noise in the history with this one big commit with lots and lots of changes. Still in favor of using a formatting standard and applying it though.

@svanteschubert
Copy link
Contributor Author

I fully agree, Sebastian.
As there is a big noise when we "copy over" the fork being done 8 years ago over the 0.9.0 branch, we might even be able to reduce this noise by normalization. Solely the quite last 0.9.0 commit will be very noisy. The copy from 1.0.0 will be with less noise and in the future, we should no longer have this problem.
Okay, I will enable the code normalization and releasing 0.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants