File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
conventions/src/main/kotlin Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -85,14 +85,9 @@ if (project == rootProject) {
8585 " .gitattributes" ,
8686 " .gitconfig" ,
8787 " .editorconfig" ,
88- " *.md" ,
8988 " gradle.properties" ,
90- " .github/**/*.md" ,
9189 " .github/**/*.sh" ,
92- " docs/**/*.md" ,
93- " examples/**/*.md" ,
94- " examples/**/gradle.properties" ,
95- " licenses/**/*.md"
90+ " examples/**/gradle.properties"
9691 )
9792 leadingTabsToSpaces()
9893 trimTrailingWhitespace()
Original file line number Diff line number Diff line change @@ -303,6 +303,22 @@ tasks {
303303 delete(rootProject.file(" licenses" ))
304304 }
305305
306+ val trimLicenseTrailingWhitespace by registering {
307+ val licenseFile = rootDir.toPath().resolve(" licenses/licenses.md" )
308+ val newline = System .lineSeparator()
309+ doLast {
310+ if (Files .exists(licenseFile)) {
311+ val content = String (Files .readAllBytes(licenseFile), Charsets .UTF_8 )
312+ val normalized = content.lineSequence()
313+ .map { it.trimEnd() }
314+ .toList()
315+ .dropLastWhile { it.isEmpty() }
316+ .joinToString(newline) + newline
317+ Files .write(licenseFile, normalized.toByteArray(Charsets .UTF_8 ))
318+ }
319+ }
320+ }
321+
306322 val removeLicenseDate by registering {
307323 // removing the license report date makes it idempotent
308324 val rootDirPath = rootDir.toPath()
@@ -328,7 +344,7 @@ tasks {
328344 val generateLicenseReportTask = named(" generateLicenseReport" )
329345 generateLicenseReportTask.configure {
330346 dependsOn(cleanLicenses)
331- finalizedBy(" :spotlessApply " )
347+ finalizedBy(trimLicenseTrailingWhitespace )
332348 finalizedBy(removeLicenseDate)
333349 // disable licence report generation unless this task is explicitly run
334350 // the files produced by this task are used by other tasks without declaring them as dependency
You can’t perform that action at this time.
0 commit comments