Don't reformat 'javadoc' comments that appear before package/imports, to avoid mangling license headers
The use case is license headers added by, for instance, maven license plugins. These headers are not by default formatted in the way that google-java-format requires, and since neither (for good reasons - neither code styles nor licenses should be changed lightly) are very configurable, conflicts are hard to avoid. (The mycila license plugin allows configuration, and with a bit of effort, you can make it create license headers that don't get reformatted - I haven't succeeded to do that with the Codehaus plugin).
Creating this issue as a different one than #139, which is about javadoc comments.
Do you have an example of a license header with >100 column lines that get wrapped by the formatter?
I have an example with <100 line columns that gets reformatted: https://github.com/pettermahlen/format-example.
I wasn't able to reproduce it easily this morning, but I also ran into a situation where lines < 100 columns got reformatted, at the same time introducing <p> tags where there were empty lines. This was also with the exact same Apache license data, and the reformatting involved meant the lines were made longer, closer to 100 columns, I would expect, though I didn't verify that.
In that example it's removing trailing whitespace from the lines before and after the line containing http://www.apache.org/licenses/LICENSE-2.0.
The other behaviour you describe (adding <p> tags and reflowing lines) would only happen if the license header was a javadoc comment, not a block comment.
Ah, yes, that makes sense. The mycila plugin uses javadoc formatting for license headers by default so it would have happened when I was experimenting with that.
And the reason for trying the mycila plugin out was because it doesn't add trailing whitespace, btw.
Would it be a good change if google-java-format refused to reformat any block comment that comes before the package/import statements?
That sounds pragmatic to me.