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] https://github.com/gradle/gradle/issues/1151
This commit is contained in:
		
							parent
							
								
									2f7a0c4e8d
								
							
						
					
					
						commit
						936998647e
					
				|  | @ -164,6 +164,14 @@ def syncJavaTemplates = tasks.register("syncJavaTemplates", Sync) { | ||||||
| 	inputs.properties(properties) | 	inputs.properties(properties) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | tasks.named("checkFormatMain") { | ||||||
|  | 	def generatedSources = fileTree("build/generated-sources/main") | ||||||
|  | 	// Exclude source generated from the templates as expand(properties) changes line endings on Windows | ||||||
|  | 	exclude { candidate -> generatedSources.contains(candidate.file) } | ||||||
|  | 	// Add the templates to check that the input is correctly formatted | ||||||
|  | 	source(fileTree("src/main/javaTemplates")) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| plugins.withType(EclipsePlugin) { | plugins.withType(EclipsePlugin) { | ||||||
| 	eclipse { | 	eclipse { | ||||||
| 		synchronizationTasks syncJavaTemplates | 		synchronizationTasks syncJavaTemplates | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue