Repository navigation
Description
with spotless and a cross platform repository it is not easily possible to enable spotless for all (windows) users.
if a Windows user has core.autocrlf=false to disable line end conversion so they end up with exactly what the repository has, then spotless falls back to assuming that \r\n should be used (which is incorrect in this case).
you can force \n on everyone by adding a .gitattributes to the repository but this will impact windows users whose default tooling may not cope well with linux line ends.
in other words - this fallback should not fallback to native but a configurable option in spotbugs (ie Unix if not changed by local git config).
If you are submitting a bug, please include the following:
Maven 3.8.6
Java 11.0.15
Windows 11
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.31.0</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
<configuration>
<java>
<endWithNewline />
<googleJavaFormat>
<style>AOSP</style>
</googleJavaFormat>
<importOrder />
<indent>
<spaces>true</spaces>
</indent>
<removeUnusedImports />
<trimTrailingWhitespace />
</java>
<pom>
<sortPom>
<encoding>UTF-8</encoding>
<lineSeparator>\n</lineSeparator>
<expandEmptyElements>false</expandEmptyElements>
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
<sortDependencies>scope,groupId,artifactId</sortDependencies>
<sortDependencyExclusions>groupId,artifactId</sortDependencyExclusions>
<sortPlugins>groupId,artifactId</sortPlugins>
<sortModules>true</sortModules>
<sortExecutions>true</sortExecutions>
</sortPom>
</pom>
</configuration>
</execution>
</executions>
</plugin>
- summary of problem
- gradle or maven version
- spotless version
- operating system and version
- [] copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
- copy-paste the full content of any console errors emitted by
gradlew spotless[Apply/Check] --stacktrace
If you're just submitting a feature request or question, no need for the above.
Activity
[-]no ability to specifiy fallback default line ending for a repo with core.autocrlf=false[/-][+]no ability to specifiy default fallback line ending for a repo with core.autocrlf=false[/+]nedtwigg commentedon Feb 6, 2023
Hmmm... You can do
<lineEndings>PLATFORM_NATIVE</lineEndings>. But also we did add support forcore.autocrlfinplugin-maven 2.20.1.core.autocrlf#1114I wonder if we somehow broke it at somepoint... We still have a test for it, so I don't think so
spotless/lib-extra/src/test/java/com/diffplug/spotless/extra/GitAttributesTest.java
Lines 93 to 103 in 05b8779
jtnord commentedon Mar 9, 2023
"autocrlf=true"but what aboutautocrlf=falsebasically checkout as is, check in as is, no line normalisation, let the user decide if they want unix line ends in a java source file locally or not. (some files will be forced by attributes to \r\n like
batfiles.in other words - if the users setup is by default not platform native but repository native... git may not have been explicitly told that default is
\n- but this can be the case. and if so I would like a configutation option to sayif
.gitattributesis not set, ifcore.autocrlfis not set and ifcore.eolis not set then as a fallback this project will be using "insert default" (or in this case - probably if none of the rest are set then perhaps the best is not to be platform native at all but to use unix line ends?nedtwigg commentedon Mar 10, 2023
My opinion on this is:
There is only one place within the spec that makes sense to me: unix everywhere ->
.gitattributesfile with just* text eol=lf.But I'm happy to support any dark corner of the spec that users are willing to write features and unit tests for :)