Skip to content

Commit 9369986

Browse files
committed
Work around Gradle changing line endings during property expansion
There's a known issue [1] where property expansion changes the input files line endings to the operating system's default. This causes problems for us on Windows as the line endings become \r\n which breaks our formatting checks. This commit tunes the checkFormatMain task to exclude the generated source files from checking. In their place, the original templates are added. This ensures that the inputs are correctly formatted and, therefore, that the output should be too (other than the line endings on Windows). Closes gh-30039 [1] gradle/gradle#1151
1 parent 2f7a0c4 commit 9369986

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

spring-boot-project/spring-boot/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ def syncJavaTemplates = tasks.register("syncJavaTemplates", Sync) {
164164
inputs.properties(properties)
165165
}
166166

167+
tasks.named("checkFormatMain") {
168+
def generatedSources = fileTree("build/generated-sources/main")
169+
// Exclude source generated from the templates as expand(properties) changes line endings on Windows
170+
exclude { candidate -> generatedSources.contains(candidate.file) }
171+
// Add the templates to check that the input is correctly formatted
172+
source(fileTree("src/main/javaTemplates"))
173+
}
174+
167175
plugins.withType(EclipsePlugin) {
168176
eclipse {
169177
synchronizationTasks syncJavaTemplates

0 commit comments

Comments
 (0)