revelc / formatter-maven-plugin

Formatter Maven Plugin
https://code.revelc.net/formatter-maven-plugin
Apache License 2.0
291 stars 91 forks source link

Xml comments are formatted after upgrade 2.17.0 -> 2.24.1 #936

Open martinaldrin opened 2 months ago

martinaldrin commented 2 months ago

Describe the bug We have started to get comments in xml formatted after we uplift the version and we can not find any configuration to disable this.

Versions (OS, Maven, Java, and others, as appropriate): Maven 3.9.9 Java 21 Readhat 8

To Reproduce Steps to reproduce the behavior (or a link to an example repository that reproduces the problem): Comment out xml tags .

Expected behavior to not remove the indentation of comment out xml tags. or a property to disable this feature

Screenshots If applicable, add screenshots to help explain your problem. image

In eclipse it is possible to configure if we want to format comments or not, and this configuration I miss in the maven formatter. image

Additional context

hazendaz commented 1 month ago

This is the default config file. If you need different, you need to override the default.

https://github.com/revelc/formatter-maven-plugin/blob/main/src/main/resources/formatter-maven-plugin/eclipse/xml.properties

See https://code.revelc.net/formatter-maven-plugin/examples.html on how to override.

martinaldrin commented 1 month ago

Hi, yes I’m aware of that file, but I can not find any configuration which is related to the sort of comments. Is there any descriptions of the properties?

hazendaz commented 1 month ago

What is your override config if any? If none, its treating tabs as spaces by default. The items while slight variations in name match up to what you see in Eclipse. In fact the code was lifted from eclipse years ago when it was added here. Code for it is here https://github.com/revelc/xml-formatter/.

See https://github.com/revelc/xml-formatter/releases, there was a bug with formatting fixed which is in 2.24.1. Have you tried others post 2.17.0 to isolate where it started?

martinaldrin commented 1 month ago

This is our current configuration, it is based on the https://github.com/revelc/formatter-maven-plugin/blob/main/src/main/resources/formatter-maven-plugin/eclipse/xml.properties a few years ago. it has not been updated with latest. No I have not tried to pinpoint where the fault started, I can try to do that.

maxLineLength=300 splitMultiAttrs=false tabInsteadOfSpaces=false tabWidth=4 wellFormedValidation=WARN wrapLongLines=false

martinaldrin commented 1 month ago

I have now tested all version between 2.17.0 and 2.24.1, the problem started with 2.24.1, so it seems to work fine with 2.24.0

hazendaz commented 1 month ago

Thanks for confirming. I'll use your example to find a fix. I suspect its due to tabs which where most likely not accounted for in fixing a separate spacing issue.

Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: martinaldrin @.> Sent: Wednesday, September 11, 2024 7:54:53 AM To: revelc/formatter-maven-plugin @.> Cc: Jeremy Landis @.>; Comment @.> Subject: Re: [revelc/formatter-maven-plugin] Xml comments are formatted after upgrade 2.17.0 -> 2.24.1 (Issue #936)

I have now tested all version between 2.17.0 and 2.24.1, the problem started with 2.24.1, so it seems to work fine with 2.24.0

— Reply to this email directly, view it on GitHubhttps://github.com/revelc/formatter-maven-plugin/issues/936#issuecomment-2343461097, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAHODI7DIX7ZJQZCHMN7DEDZWAVQ3AVCNFSM6AAAAABNVZD7AGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBTGQ3DCMBZG4. You are receiving this because you commented.Message ID: @.***>

hazendaz commented 1 month ago

Not sure when I can get to this. I think you want to stick to 2.23.0 for time being as there was a bug in 2.24.0. I'm sorry we don't have release notes up here, I have been unable to get consensus as to why that is so utterly important. All we are left with is digging through this milestones which may not be entirely accurate https://github.com/revelc/formatter-maven-plugin/milestones?state=closed.

The real issue here is not the formatter here but xml-formatter project and we do have to get a number of components out to even get the eclipse 2024-06 release out and now 2024-09 is out from eclipse. So we are a bit behind here. I've been sick last few days and was hoping to address this weekend but not looking like I'll get to it. I just want to make sure you can work successfully for now until this is remediated. Thanks.

martinaldrin commented 1 month ago

2.23.0 can not be used either, it is broken for xml formatting. 2.24.0 can not be used at all.

So I will try to use 2.22.0 for now

hazendaz commented 1 month ago

ok thanks. Do report back what ends up working for you temporarily to help others.