You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add option to preserve line ending during check/formatting #2277
Currently the lineEndings option does only allow to configure which line endings to expect. There is no single option which works on non-Git based source code (i.e. extracted from a ZIP source archive) accepting both line endings (Windows and Unix).
This is crucial though because by default source archives created with maven-source-plugin are not normalized with respect to line endings, i.e. the archives end up with Windows endings on a Windows machine and Unix endings on all other machines. As the spotless configuration is part of the source archive, building should not fail with spotless errors irrespective of the line ending.
No, you have arbitrary line endings in the source and it should work with the same config to do spotless:check in Windows and Unix machines. PLATFORM_NATIVE only works if source was created with the same platform, but not if created on a platform with another line ending.
In this case I would just throw an exception. This is IMHO never acceptable.
However for performance reasons I would probably just check for the first line ending in a file (and not check all) therefore the first line ending in a file determines the outcome.
changed the title [-]Add option to normalize line ending prior checking or ignore during check[/-][+]Add option to preserve line ending during check/formatting[/+]on Oct 3, 2024
Activity
nedtwigg commentedon Sep 27, 2024
PLATFORM_NATIVE should work here, yeah?
kwin commentedon Sep 28, 2024
No, you have arbitrary line endings in the source and it should work with the same config to do
spotless:checkin Windows and Unix machines. PLATFORM_NATIVE only works if source was created with the same platform, but not if created on a platform with another line ending.nedtwigg commentedon Oct 2, 2024
I'm open to a
PRESERVEoption here:spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 45 to 50 in b2a2cbb
spotless/lib/src/main/java/com/diffplug/spotless/LineEnding.java
Lines 134 to 136 in b2a2cbb
Two ambiguous cases:
My vote is that both these cases round to "UNIX", but print a warning message.
kwin commentedon Oct 3, 2024
I agree with all you said except for the case
In this case I would just throw an exception. This is IMHO never acceptable.
However for performance reasons I would probably just check for the first line ending in a file (and not check all) therefore the first line ending in a file determines the outcome.
[-]Add option to normalize line ending prior checking or ignore during check[/-][+]Add option to preserve line ending during check/formatting[/+]SLING-12485 Update spotless to accept all line endings
SLING-12485 Update spotless to accept all line endings
Update to spotless-m-p 2.44.0.BETA4
Accept all line endings in spotless (#217)