Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,9 @@ if (project == rootProject) {
".gitattributes",
".gitconfig",
".editorconfig",
"*.md",
"gradle.properties",
".github/**/*.md",
".github/**/*.sh",
"docs/**/*.md",
"examples/**/*.md",
"examples/**/gradle.properties",
"licenses/**/*.md"
"examples/**/gradle.properties"
)
leadingTabsToSpaces()
trimTrailingWhitespace()
Expand Down
18 changes: 17 additions & 1 deletion javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ tasks {
delete(rootProject.file("licenses"))
}

val trimLicenseTrailingWhitespace by registering {
val licenseFile = rootDir.toPath().resolve("licenses/licenses.md")
val newline = System.lineSeparator()
doLast {
if (Files.exists(licenseFile)) {
val content = String(Files.readAllBytes(licenseFile), Charsets.UTF_8)
val normalized = content.lineSequence()
.map { it.trimEnd() }
.toList()
.dropLastWhile { it.isEmpty() }
.joinToString(newline) + newline
Files.write(licenseFile, normalized.toByteArray(Charsets.UTF_8))
}
}
}

val removeLicenseDate by registering {
// removing the license report date makes it idempotent
val rootDirPath = rootDir.toPath()
Expand All @@ -328,7 +344,7 @@ tasks {
val generateLicenseReportTask = named("generateLicenseReport")
generateLicenseReportTask.configure {
dependsOn(cleanLicenses)
finalizedBy(":spotlessApply")
finalizedBy(trimLicenseTrailingWhitespace)
finalizedBy(removeLicenseDate)
// disable licence report generation unless this task is explicitly run
// the files produced by this task are used by other tasks without declaring them as dependency
Expand Down
Loading